Champak Posted March 24, 2008 Share Posted March 24, 2008 (edited) Can someone show me a better way of doing the following....condense it down to maybe one loop. (probably part 1 of a couple of things I'm cleaning up) expandcollapse popup$FunctionKeys1ColumnName = "cat, dog, rat, mouse, hat, ........" $FunctionKeys1ColumnName = StringSplit($FunctionKeys1ColumnName, ",") $FunctionKeys2ColumnName = "car, boat, truck, bike, van,........" $FunctionKeys2ColumnName = StringSplit($FunctionKeys2ColumnName, ",") ;Column 1 $H=45 For $i = 1 To 13 GUICtrlCreateLabel($FunctionKeys1ColumnName[$i], $FL1, $H, $WidthL, $HeightL) GUICtrlSetFont(-1, $FS, $FW, "") GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) $AppFunctionsArray[$i][1] = GUICtrlCreateInput($AppFunctionsArray[$i][0], $FL2, $H, $WidthI, $HeightI) $H +=24 Next For $i = 14 To 15 GUICtrlCreateLabel($FunctionKeys1ColumnName[$i], $FL1, $H+14, $WidthL, $HeightL) GUICtrlSetFont(-1, $FS, $FW, "") GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) $AppFunctionsArray[$i][1] = GUICtrlCreateInput($AppFunctionsArray[$i][0], $FL2, $H+14, $WidthI, $HeightI) $H +=24 Next ;Column 2 $H=45 $j = 16 For $i = 1 To 13 GUICtrlCreateLabel($FunctionKeys2ColumnName[$i], $FL3, $H, $WidthL, $HeightL) GUICtrlSetFont(-1, $FS, $FW, "") GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) $AppFunctionsArray[$j][1] = GUICtrlCreateInput($AppFunctionsArray[$j][0], $FL4, $H, $WidthI, $HeightI) $H +=24 $j +=1 Next For $i = 14 To 15 GUICtrlCreateLabel($FunctionKeys2ColumnName[$i], $FL3, $H+14, $WidthL, $HeightL) GUICtrlSetFont(-1, $FS, $FW, "") GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) $AppFunctionsArray[$j][1] = GUICtrlCreateInput($AppFunctionsArray[$j][0], $FL4, $H+14, $WidthI, $HeightI) $H +=24 $j +=1 Next Edited March 24, 2008 by Champak Link to comment Share on other sites More sharing options...
martin Posted March 24, 2008 Share Posted March 24, 2008 (edited) Can someone show me a better way of doing the following....condense it down to maybe one loop. (probably part 1 of a couple of things I'm cleaning up) expandcollapse popup$FunctionKeys1ColumnName = "cat, dog, rat, mouse, hat, ........" $FunctionKeys1ColumnName = StringSplit($FunctionKeys1ColumnName, ",") $FunctionKeys2ColumnName = "car, boat, truck, bike, van,........" $FunctionKeys2ColumnName = StringSplit($FunctionKeys2ColumnName, ",") ;Column 1 $H=45 For $i = 1 To 13 GUICtrlCreateLabel($FunctionKeys1ColumnName[$i], $FL1, $H, $WidthL, $HeightL) GUICtrlSetFont(-1, $FS, $FW, "") GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) $AppFunctionsArray[$i][1] = GUICtrlCreateInput($AppFunctionsArray[$i][0], $FL2, $H, $WidthI, $HeightI) $H +=24 Next For $i = 14 To 15 GUICtrlCreateLabel($FunctionKeys1ColumnName[$i], $FL1, $H+14, $WidthL, $HeightL) GUICtrlSetFont(-1, $FS, $FW, "") GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) $AppFunctionsArray[$i][1] = GUICtrlCreateInput($AppFunctionsArray[$i][0], $FL2, $H+14, $WidthI, $HeightI) $H +=24 Next ;Column 2 $H=45 $j = 16 For $i = 1 To 13 GUICtrlCreateLabel($FunctionKeys2ColumnName[$i], $FL3, $H, $WidthL, $HeightL) GUICtrlSetFont(-1, $FS, $FW, "") GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) $AppFunctionsArray[$j][1] = GUICtrlCreateInput($AppFunctionsArray[$j][0], $FL4, $H, $WidthI, $HeightI) $H +=24 $j +=1 Next For $i = 14 To 15 GUICtrlCreateLabel($FunctionKeys2ColumnName[$i], $FL3, $H+14, $WidthL, $HeightL) GUICtrlSetFont(-1, $FS, $FW, "") GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) $AppFunctionsArray[$j][1] = GUICtrlCreateInput($AppFunctionsArray[$j][0], $FL4, $H+14, $WidthI, $HeightI) $H +=24 $j +=1 Next It could be condensed a lot. Here's one way which might work- $FunctionKeys1ColumnName = "cat, dog, rat, mouse, hat, ........" $FunctionKeys1ColumnName = StringSplit($FunctionKeys1ColumnName, ",") $FunctionKeys2ColumnName = "car, boat, truck, bike, van,........" $FunctionKeys2ColumnName = StringSplit($FunctionKeys2ColumnName, ",") createLabels ($FunctionKeys1ColumnName, 45, 0);Column 1 createLabels ($FunctionKeys2ColumnName, 45, 15);Column 2 Func createLabels ($arr, $H, $j) $k = 0 For $i = 1 To UBound($arr) If $i = 14 Then $k = 14 GUICtrlCreateLabel($arr[$i], $FL1, $H + $k, $WidthL, $HeightL) GUICtrlSetFont(-1, $FS, $FW, "") GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) $AppFunctionsArray[$i + $j][1] = GUICtrlCreateInput($AppFunctionsArray[$i][0], $FL2, $H, $WidthI, $HeightI) $H += 24 Next EndFunc ;==>createLabels EDIT: correct error in parameter name Edited March 24, 2008 by martin Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
Champak Posted March 25, 2008 Author Share Posted March 25, 2008 (edited) Thanks. Now I have to go through EVERYTHING and figure out how many extra unnecessary lines of code I have beyond the ones I already suspect. I did some work on my own before coming back and got it down to this...although not as short as yours: $FunctionKeys1ColumnName = "cat, dog, rat, mouse, hat, ........" $FunctionKeys1ColumnName = StringSplit($FunctionKeys1ColumnName, ",") $H = 45 For $i = 1 To UBound($FunctionKeys1ColumnName) - 1 $k = 0 If $i = 14 Or $i = 15 Or $i = 29 Or $i = 30 Then $k = 14 If $i = 16 And $x = "" Then $H = 45 $x = 1 EndIf If $i <= 15 Then GUICtrlCreateLabel($FunctionKeys1ColumnName[$i], $FL1, $H + $k, $WidthL, $HeightL) GUICtrlSetFont(-1, $FS, $FW, "") GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) $AppFunctionsArray[$i][1] = GUICtrlCreateInput($AppFunctionsArray[$i][0], $FL2, $H + $k, $WidthI, $HeightI) ElseIf $i >= 16 Then GUICtrlCreateLabel($FunctionKeys1ColumnName[$i], $FL3, $H + $k, $WidthL, $HeightL) GUICtrlSetFont(-1, $FS, $FW, "") GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) $AppFunctionsArray[$i][1] = GUICtrlCreateInput($AppFunctionsArray[$i][0], $FL4, $H + $k, $WidthI, $HeightI) EndIf $H +=24 NextoÝ÷ Ù8^Z()àjܨº»q©º"¶aÆ®¶sbb33c´gVæ7Föä¶W36öÇVÖäæÖRÒgV÷C¶6BÂFörÂ&BÂÖ÷W6RÂBÂââââââââgV÷C°¢b33c´gVæ7Föä¶W36öÇVÖäæÖRÒ7G&æu7ÆBb33c´gVæ7Föä¶W36öÇVÖäæÖRÂgV÷C²ÂgV÷C²¢¢b33c´ÒCP¢f÷"b33c¶ÒFòT&÷VæBb33c´gVæ7Föä¶W36öÇVÖäæÖRÒ¢b33c¶²Ò¢bb33c¶fwC³ÒBæBb33c¶fÇC³ÒR÷"b33c¶fwC³Ò#æBb33c¶fÇC³Ò3FVâb33c¶²Ò@¢bb33c¶fÇC³ÒRFVà¢b33c´ÅÒb33c´dâb33c´Òb33c´dà ¢VÇ6Tbb33c¶fwC³ÒbFVà¢bb33c·ÒgV÷C²gV÷C²FVà¢b33c´ÒCP¢b33c·Ò¢VæDb¢b33c´ÅÒb33c´dÃ0¢b33c´Òb33c´dÃ@¢VæD`¢uT7G&Ä7&VFTÆ&VÂb33c´gVæ7Föä¶W36öÇVÖäæÖU²b33c¶ÒÂb33c´ÅÂb33c´²b33c¶²Âb33cµvGFÂÂb33c´VvD¢uT7G&Å6WDföçBÓÂb33c´e2Âb33c´erÂgV÷C²gV÷C²¢uT7G&Å6WD&´6öÆ÷"ÓÂb33c´uTô$´4ôÄõ%õE$å5$TåB¢b33c´gVæ7Föç4'&²b33c¶Õ³ÒÒuT7G&Ä7&VFTçWBb33c´gVæ7Föç4'&²b33c¶Õ³ÒÂb33c´Âb33c´²b33c¶²Âb33cµvGFÂb33c´VvD¢b33c´³Ò#@¢æW@ I'll have another one in a couple days if you would be so kind. Thanks. Edited March 25, 2008 by Champak Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted March 25, 2008 Moderators Share Posted March 25, 2008 Thought the idea of showing you, was for you to get an idea on how it's done and for you to implement it yourself... Why would you come back with more? Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Champak Posted March 25, 2008 Author Share Posted March 25, 2008 When I said I'll be back with another one in a couple days, I meant with a totally different code snippet for a different function (not another version of this) that I'm having problems condensing...I just want to try a little longer on my own before bringing it here and asking. 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