Jump to content

Recommended Posts

Posted (edited)
  On 7/26/2015 at 4:40 PM, guinness said:

Are you telling me the warnings don't make sense? You're using advanced parameters for Au3Check, one of which is telling you about when a variable has been declared but not used. I don't know how to make the warnings anymore clearer.

This is why it's important that UDF creators (like me, you or everyone) run their UDF against these checks, as when someone like you or I decides to use this directive in our code, we don't get warnings. So the fix is to remove those variables and for those you can't remove like $iMsg or $hWnd, then use #forceref (search the help file for its usage).

Thank you for addressing the "warnings" question, @guinness.  I modified my code and the UDF's "_InputMask" function as shown below. These steps eliminated all the warnings when I compile my code snippet.

Are you feeling generous enough to sniff test the code snippet I posted above?

Func _InputMask($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $wParam, $lParam
    Local $iPrecision, $iDecimal, $Read_Input, $Point1, $Point2, $Keep_Input, $aLocation
    #forceref $iPrecision, $iDecimal

 

Edited by timmy2
#forceref additional variables in UDF
Posted

Too busy right now. Sorry.

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

  • 2 months later...
Posted

How can I prevent Umlauts from being inserted into input fields?

I tried the following, but it did not work:

_Inputmask_add($MyInputField, "[öäüÖÄÜ]", 500)

 

Posted

I think the UDF works the other way round.
You have to specify the valid characters like "[^A-Za-z0-9]" for all alphanumeric characters (or you could use $iIM_ALPHANUMERIC instead).

My UDFs and Tutorials:

  Reveal hidden contents

 

Posted

In another Input field I disallow semicolon and some other characters with

_Inputmask_add($MyInputField, "[; p P a A]", 500)

and it works. Just with Umlauts it did not work.

Posted

Does it work if you specify the unicode codes as described here?

My UDFs and Tutorials:

  Reveal hidden contents

 

Posted

I'm out of ideas now. Maybe Greencan knows how to solve the problem.

My UDFs and Tutorials:

  Reveal hidden contents

 

Posted

To prevent öäüÖÄÜß just use this:

_Inputmask_add($MyInputField, "[\x{00c4} \x{00e4} \x{00d6} \x{00f6} \x{00dc} \x{00fc} \x{00df}]", 500)

The idea with the unicode was close :D

Posted

But that's unicode, isn't it?

My UDFs and Tutorials:

  Reveal hidden contents

 

  • 10 months later...
Posted

When running the example code I am getting this error.

 

"C:\Manual\Development\AutoIt\Include\_inputmask.au3"(91,107) : error: _Iif(): undefined function.
                        If StringLen($Read_Input) - StringInStr($Read_Input, "-") - _Iif(StringInStr($Read_Input, "."), 1, 0)
                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

 

Posted (edited)

The _Iif() function has been removed from Autoit a while back.

You can modify that line using the ternary operator, or use a local function like the one proposed in another thread:

; #FUNCTION# ====================================================================================================================
; Name...........: _Iif
; Description ...: Perform a boolean test within an expression.
; Syntax.........: _Iif($fTest, $vTrueVal, $vFalseVal)
; Parameters ....: $fTest     - Boolean test.
;                  $vTrueVal  - Value to return if $fTest is true.
;                  $vFalseVal - Value to return if $fTest is false.
; Return values .: True         - $vTrueVal
;                  False        - $vFalseVal
; Author ........: Dale (Klaatu) Thompson
; Modified.......:
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================
Func _Iif($fTest, $vTrueVal, $vFalseVal)
    If $fTest Then
        Return $vTrueVal
    Else
        Return $vFalseVal
    EndIf
EndFunc   ;==>_Iif

That should help.

Edited by kyo
Posted

Here's an _iif func equivalent using the ternary operator as mentioned by kyo

Func _Iif($vExpression, $vTrue, $vFalse)
 Return ($vExpression) ? $vTrue : $vFalse
EndFunc

 

  • 9 months later...
Posted

Hi

 

I have a problem and im unable to solve it

 

Upon setting the InputMask i have a variable $iMaxValue which is i.e. 30 and i want to allow only positive numeric integers between 1 and this variable

Does anybody of you know how can i do this?

 

_Inputmask_add($idi1, $iIM_POSITIVE_INTEGER, 0, "", 2)

-> 2 digits allowd (values from 1 to 99) but like i said i need from 1 to $iMaxValue

 

Best,

Thomy

  • 6 months later...
Posted (edited)

hi

how to set input mask number string with  separator

ex : stringlen($st) from 1 to 12

$st = 453              ->   $st = 453

$st = 12345678   ->   $st =  12,345,678

$st = 123456789  ->  $st = 123,456,789

.... 

Thank 

 

 

 

Edited by 123disconnect

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...