i.e.
Code: Select all
loop 6
square%A_Index% := A_Index * A_Index
MsgBox square2
MsgBox square3
MsgBox square6
Code: Select all
loop 6
square%A_Index% := A_Index * A_Index
MsgBox square2
MsgBox square3
MsgBox square6
Indeed, the warning is triggered at parsing (loading time) and these vars exist at runtime. Well, its the same issue as output variables (#45) - we might need some keywords (e.g. dyn and out) to mark dynamically generated variables and output vars so as to skip this warning for them.
Code: Select all
square:=[]
loop(6)
square.push(a_index*a_index)
msgbox(square[2])
msgbox(square[3])
msgbox(square[6])
That doesn't dereference a number,It seems that using square%2% works, but what does dereferencing a number actually do?
Cheers.%Expr% dynamically retrieves a variable by name. The result of the sub-expression Expr must be the name or partial name of the variable to be retrieved.
Its not possible to check run-time created vars at load time. I would like to keep that warning, too - I found quite a few sleeping errors in my scripts with it. The best we could do (as a temporary workaround) is to have AHK skipping checkups for all the var%var% syntax instances. Or implement some keywords to tell the parser to skip checkups for some variables (that's what I suggest).
point is u initialize pseudo-array members at runtime and at load time AHK tries to check every addressing to those not-yet-existing vars. That's why we might need to add some special declarations for them to skip such check-ups.
First, you do not use pseudo-arrays.point is u initialize pseudo-array members
I disagree. If you use dynamic variable references, you are either going to reference them only dynamically, or both dynamically and non-dynamically. For the latter case you will have to initialise them appropriately.we might need to add some special declarations for them to skip such check-ups.
Damn it, u r right again. varX%varY% gives a load-time warning if varY is not initialized somewhere else, but it gives no load-time warnings otherwise (OK).
Code: Select all
i:=a_tickcount ;if we comment this line, it gives a load-time warning on the next line "i: this var appears to never be assigned a value" (OK)
msgbox(array%i%)
I agree on that. So its fine as it is.or both dynamically and non-dynamically. For the latter case you will have to initialise them appropriately.
two thumbs up. its batch-style remnants.
It is. IT companies might keep legacy code for compatibility reasons mainly.
Code: Select all
for /d %%i in ("%PROGRAMFILES%") do (
set PROGRAMFILESSHORT=%%~si
)
for /f "eol=# delims== tokens=1,2" %%i in (%SETTINGSFILE%) do (
set %%i=%%j
)
if %1 == 1 (
exit /b
)
set /a PARAM=%1 - 1
call :factorial %PARAM%
arguably is arguably the only thing we can agree on herePsuedo arrays would arguably also be good for unique, unusual, or creative situations.
By populate programmatically I meant loop with obj.keyN:=valueN over obj:={"keyN":"valueN"} JSON-like syntax.
Oh, I missed that defineprop method. It does seem way too verbose (as the majority of Lexikos' recently added functions). Well, %var%DOS environment variables-like syntax feels bad.the point is, its a shorthand.
Could u elaborate please? The current documentation even puts both syntax variations together:2. except %fn%() and fn.Call() do different things
Func.Call(Param1, Param2, ...)
%Func%(Param1, Param2, ...)
https://lexikos.github.io/v2/docs/objects/Func.htm#Call
Meta-functions are not called in the following cases:
x[y]: Using square brackets without a property name only invokes the __Item property.
%x%(): Calling the object itself only invokes the Call method. This includes internal calls made by built-in functions such as SetTimer and Hotkey.
Internal calls to other meta-functions or double-underscore methods do not trigger __Call.
Return to “AutoHotkey Development”
Users browsing this forum: No registered users and 52 guests