willie_g_homie Posted November 17, 2006 Share Posted November 17, 2006 (edited) Hello, new to Autoit. Have done the following in VB and VBA so know it can be done. question is how does Autoit syntax do it??? Want to reference any number of similar variables in for loop. i.e. ; example from VBA: ptv = varint(r("PT" & s)) Func fSetGUIbyINI() Local $Trax, $Step, $STR = "" Local $ArrayRow = 0 Const $NumOfTrax = 4; remove after testing Const $NumOfStep = 13; " " " Local $TraxNumber[$NumOfTrax] = [1, 2, 3, 4] Local $TraxLetter[$NumOfStep] = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m"] $intMaxSteps = $NumOfStep * $NumOfTrax For $Step = 0 to UBound($TraxNumber,1) - 1 For $Trax = 0 to UBound($TraxLetter,1) - 1 $STR = "$Trk" & $TraxNumber[$Step] & "Compl" & $TraxLetter[$Trax]; <-problem GUICtrlSetState($STR, _iif($ATrax_Steps[$ArrayRow][2], $GUI_CHECKED, $GUI_UNCHECKED)) $ArrayRow += 1 Next Next EndFunc Edited November 17, 2006 by willie_g_homie Link to comment Share on other sites More sharing options...
Valuater Posted November 17, 2006 Share Posted November 17, 2006 (edited) Welcome to the forums....I cannot find an Autoit error on this line $STR = "$Trk" & $TraxNumber[$Step] & "Compl" & $TraxLetter[$Trax] ; <-problemand this seems to pass the SciTE editors syntax check#include <Misc.au3> #include <GUIConstants.au3> ;Func fSetGUIbyINI() Local $Trax, $Step, $STR = "" Local $ArrayRow = 0 Const $NumOfTrax = 4 ; remove after testing Const $NumOfStep = 13; " " " Local $TraxNumber[$NumOfTrax] = [1, 2, 3, 4] Local $TraxLetter[$NumOfStep] = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m"] $intMaxSteps = $NumOfStep * $NumOfTrax For $Step = 0 to UBound($TraxNumber,1) - 1 For $Trax = 0 to UBound($TraxLetter,1) - 1 $STR = "$Trk" & $TraxNumber[$Step] & "Compl" & $TraxLetter[$Trax] ; <-problem ;GUICtrlSetState($Trk1Compla, _iif($ATrax_Steps[$ArrayRow][2], $GUI_CHECKED, $GUI_UNCHECKED)) $ArrayRow += 1 Next Next ;EndFuncHowever, if $STR = "$Trk" &...where $Trk is a varaiable ( undefined in the scriplet ) then it would be$STR = $Trk & $TraxNumber[$Step] & "Compl" & $TraxLetter[$Trax] ; <-problemwithout the quotes(")8) Edited November 17, 2006 by Valuater Link to comment Share on other sites More sharing options...
willie_g_homie Posted November 17, 2006 Author Share Posted November 17, 2006 Hmmm. Interesting. Thanks for the welcome and quick response. In all fairness, i edited the script after you copied it. oops! Compiling always works. but the action doesn't. i have several checkboxes i want to manipulate. i.e.: $Trax1Compla = GUICtrlCreateCheckbox(.................. $Trax1Complb $Trax1Complc .... ... .. and so on. so how do i use a string to reference these in a loop? And "$Trax" is part of the GUI variable name as illustrated above. String concatenate rule aplies. The & operator for adding strings is said to be unambiguous since it's limited to performing the string concatenation even when the data types are not string. Basically, i wish to get this result: ; $STR = "$Trk" & $TraxNumber[$Step] & "Compl" & $TraxLetter[$Trax] ; or $STR = "$Trax1Compla" GUICtrlSetState($STR, _iif($ATrax_Steps[$ArrayRow][2], $GUI_CHECKED, $GUI_UNCHECKED)) However, if $STR = "$Trk" &... where $Trk is a varaiable ( undefined in the scriplet ) then it would be $STR = $Trk & $TraxNumber[$Step] & "Compl" & $TraxLetter[$Trax] ; <-problem without the quotes(") 8) Link to comment Share on other sites More sharing options...
Valuater Posted November 17, 2006 Share Posted November 17, 2006 (edited) maybe.. Dim $Trax1Comp[4] $Trax1Comp[1] = GUICtrlCreateCheckbox(.................. $Trax1Comp[2] $Trax1Comp[3] .... for $x = 1 to UBound($Trax1Comp) -1 GUISetState($Trax1Comp[$x], $GUI_CHECKED) next 8) Edited November 17, 2006 by Valuater Link to comment Share on other sites More sharing options...
willie_g_homie Posted November 17, 2006 Author Share Posted November 17, 2006 Looks good. should've thought of that. haste make waste. thanks. maybe.. Dim $Trax1Comp[4] $Trax1Comp[1] = GUICtrlCreateCheckbox(.................. $Trax1Comp[2] $Trax1Comp[3] .... for $x = 1 to UBound($Trax1Comp) -1 GUISetState($Trax1Comp[$x], $GUI_CHECKED) next 8) Link to comment Share on other sites More sharing options...
Valuater Posted November 17, 2006 Share Posted November 17, 2006 Welcome... I can see you have a great ability/knowledge of programming in fact i had never seen _iif() before .... Look forward to great stuff from you 8) Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now