Sign in to follow this  
Followers 0
MyDisplayName

Can I...For each control of this type: perform this action

5 posts in this topic

I have basically a GUI form that I created that has about 50 input boxes, and 20 combos. There is a listbox on the form that determines control values - basically pulling from an excel file serving as a database with a list of People in the listbox.

I want to basically:

for each input on thisform

.save value to database based on controlname

next control

I'm sure I can manage the actual functionality but is there a way to perform this loop and come out with the results I want?

Share this post


Link to post
Share on other sites



I have basically a GUI form that I created that has about 50 input boxes, and 20 combos. There is a listbox on the form that determines control values - basically pulling from an excel file serving as a database with a list of People in the listbox.

I want to basically:

for each input on thisform

.save value to database based on controlname

next control

I'm sure I can manage the actual functionality but is there a way to perform this loop and come out with the results I want?

Put the control IDs in arrays when you create them, making it easy to For/Next loop through them:

For $n = 0 To UBound($avInputs) - 1
    _ExcelWriteCell($oExcel, GUICtrlRead($avInputs[$n]), "B" & 5 + $n) ; write to B5 thru B5+n
Next

:whistle:


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Put the control IDs in arrays when you create them, making it easy to For/Next loop through them

Sounds good, makes great sense. However I've had a disgust for arrays since I started coding (I think I'm scared of them).

What would be the best way to put them into arrays? (totally clueless here but if you can just point me to where at in the help I can figure it out)

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Sounds good, makes great sense. However I've had a disgust for arrays since I started coding (I think I'm scared of them).

What would be the best way to put them into arrays? (totally clueless here but if you can just point me to where at in the help I can figure it out)

Read the help file on "Variables", and the keywords "Dim/Global/Local". Try out the demos in the help file for MouseGetPos() and WinList().

Arrays are indispensable for many kinds of scripting, even outside of AutoIt. Might as well learn them now. Many AutoIt functions like MouseGetPos() return an array by default, others like StringSplit() only return arrays. So you can't even use all the standard built-in functions without using arrays.

Combining arrays with For/Next loops is very powerful, and simplifies otherwise complicated tasks -- like checking the state on a bunch of GUI controls.

A one dimension (1D) array is just a numbered list, numbered from zero. Sometimes you declare an array as being a certain length, and people often forget it is numbered from zero. So if you declare an array with 3 elements, they are numbered from 0 to 2:

#include <array.au3>
Dim $avDogs[3] = ["Lassie", "Astro", "Snoopy"]
_ArrayDisplay($avDogs, "1D Array")oÝ÷ Øp¡Ø¦z{"¢v¥Ø6«­¬¢²;¬¶X¤y«ZnW¨®Êky§lç­®¢[¦«­¢+Ø¥¹±Õ±ÐíÉÉä¹ÔÌÐì)¥´ÀÌØíÙ½ÍlÍulÉtômlÅÕ½Ðí1ÍÍ¥ÅÕ½Ðì°ÅÕ½Ðí1ÍÍ¥°
½µ!½µÅÕ½Ðít°lÅÕ½ÐíÍÑɼÅÕ½Ðì°ÅÕ½ÐíQ¡)Ñͽ¹ÌÅÕ½Ðít°lÅÕ½ÐíM¹½½ÁäÅÕ½Ðì°ÅÕ½ÐíA¹ÕÑÌÅÕ½Ðíut)}ÉÉå¥ÍÁ±ä ÀÌØíٽ̰ÅÕ½ÐìÉÉÉäÅÕ½Ðì¤oÝ÷ ØÚ-zØ^ëa¡×è®)â¶&¥8§­Þ®(}Ö­j)ÞiÈlzÚn¶ëljYbÈy©èº×«n¶ëN~קʢ}ý¶IèÂÝ¢}ý·§¶Ú-)äiº.¶0n(-æ«­¬§yçl¶Þ§ʭæ­z+E¢»ajÛaz·¢°
ëk t¢{Þب»­Z²²Ø^~*ìµé^éív§jºÚËH¬±ëm¢Ø^¶Z{¦mêè~ënWéÛ)¶¬rïz{b¢y²±é_jwn±ë§ë,¶«z+r©zYb
ÞjÊ'm¡8b²+u騡öPajØZ±«Ú®&éî·«¡÷!yÉ£¬"Û¬zËaz×xª¹ëÇ.²Çiº/y©Ýrw¬¶®¶²Â+a±ëÞ­©E¢¿Í{e¢m¢­¶°¢¹¢wºÚ"µÍÚ[ÛYH  ÙÝZXÛÛÝ[Ë]LÉÝÂÚ[ÛYH  Ø^K]LÉÝÂÜ
    ][ÝÑÝZSÛ][[ÙI][ÝËJBÛØ[ ÌÍØ]ÚÐÞÌWHHÌBÈÚÈÜÛÝ[Ú[HBIÌÍÐÛÝ[H[]Þ
    ][ÝÐ^HÙÕRHÛÛÛÈ[[É][ÝË    ][ÝÓ[XÙÛÛÛÈ
KL
N   ][ÝÊBRYÜ[BQ^]Q[ÙBBIÌÍÐÛÝ[H[X   ÌÍÐÛÝ[
BBRY    ÌÍÐÛÝ[ ÝÈ[   ÌÍÐÛÝ[ ÈH[^]ÛÜQ[YÑ[ÈÜX]HÝZBÌÍÚÕRHHÕRPÜX]J ][ÝÐ^HÙÕRHÛÛÛÈ[[É][ÝËÍ

BÕRTÙ]Û][
    ÌÍÑÕRWÑUSÐÓÔÑK ][Ý×Ô]Z] ][ÝÊBÕRPÝÜX]SX[
    ][ÝÔÙ[XÝÚXÚØÞÈ[ÛXÚÈÒË][ÝËLLÌÌ
BÕRPÝÙ]Û
LKM

BÈYÚXÚØÞÂÜ   ÌÍØÈHHÈ    ÌÍÐÛÝ[NÈØ[Ý[]HÞHÛÛÜÂRY ÌÍØÈ    ÏHL[BIÌÍÞHLBIÌÍÞHH
È
    ÌÍØÈ
Ì
BQ[ÙBBIÌÍÞHNBIÌÍÞHH
È

    ÌÍØÈHL
H
Ì
BQ[YBNÈXÙHHÛÛÛWÐ^PY
    ÌÍØ]ÚÐÞÕRPÝÜX]PÚXÚØÞ
    ][ÝÐÚXÚØÞË][ÝÈ [È ÌÍØË    ÌÍÞ  ÌÍÞKML
JB^ÌÍØ]ÚÐÞÌHHPÝ[
    ÌÍØ]ÚÐÞ
HHBÈXYÈÜ^HÙÛÛÛQÂÐ^QÜ^J    ÌÍØ]ÚÐÞ   ][ÝÐÛÛÛQÉ][ÝÊBÈY]ÛÂÌÍÓÒ×Ø]ÛHÕRPÝÜX]P]Û    ][ÝÓÒÉ][ÝËLÍLÌ
BÕRPÝÙ]Û][
LK  ][Ý×Ð]Û]    ][ÝÊBÌÍÐÛXØ]ÛHÕRPÝÜX]P]Û    ][ÝÐÛX[  ][ÝËLÍLÌ
BÕRPÝÙ]Û][
LK  ][Ý×Ð]Û]    ][ÝÊBÕRPÝÜX]P]Û   ][ÝÑVU    ][ÝËÌÍLÌ
BÕRPÝÙ]Û][
LK  ][Ý×Ô]Z] ][ÝÊBÕRTÙ]Ý]J
BÚ[HBTÛY

BÑ[[ÈÐ]Û]

BSØØ[ ÌÍÜÓÙÈH   ][ÝÉ][ÝË    ÌÍÛTÝÚ]ÚÕRWÐÝYBPØÙH  ÌÍÓÒ×Ø]ÛBBPÛÛÛÛUÜ]J ][ÝÑXYΠ ÌÍÓÒ×Ð]Û]    ][ÝÈ  [ÈBBBQÜ   ÌÍÛHHÈ  ÌÍØ]ÚÐÞÌBBBBRYÛÛÛÛÛ[X[
    ][ÝÐ^HÙÕRHÛÛÛÈ[[É][ÝË    ][ÝÉ][ÝË    ÌÍØ]ÚÐÞÉÌÍÛK  ][ÝÒÐÚXÚÙY    ][ÝÊH[    ÌÍÜÓÙÈ    [ÏH    ÌÍÛ  [È ][ÝË  ][ÝÂBBS^BBRY  ÌÍÜÓÙÈH   ][ÝÉ][ÝÈ[BBBIÌÍÜÓÙÈH  ][ÝÓÛHÙ[XÝY][ÝÂBBQ[ÙBBBBIÌÍÜÓÙÈH  ][ÝÔÙ[XÝY   ][ÝÈ  [ÈÝ[Õ[TYÚ
    ÌÍÜÓÙËBBBQ[YBBSÙÐÞ
    ][ÝÔÝ[É][ÝË   ÌÍÜÓÙÊBBPØÙH    ÌÍÐÛXØ]ÛBBPÛÛÛÛUÜ]J  ][ÝÑXYΠ ÌÍÐÛXÐ]Û] ][ÝÈ  [ÈBBBQÜ   ÌÍÛHHÈ  ÌÍØ]ÚÐÞÌBBBBPÛÛÛÛÛ[X[
    ][ÝÐ^HÙÕRHÛÛÛÈ[[É][ÝË    ][ÝÉ][ÝË    ÌÍØ]ÚÐÞÉÌÍÛK  ][ÝÕ[ÚXÚÉ][ÝÊBBBS^BPØÙH[ÙBBBSÙÐÞ
M   ][ÝÑÜ][ÝË  ][ÝÕ[[YØÙNÕRWÐÝQH    ][ÝÈ  [ÈÕRWÐÝY
BQ[ÝÚ]Ú[[ÈÏOIÝ×Ð]Û][ÈÔ]Z]

BQ^][[ÈÏOIÝ×Ô]Z]

Hope that helps.

:lmao:

Edit: ARRRRRGH!!!! I hate the way the forum editor scrambles code boxes! That is really, really annoying! :whistle:

Edited by PsaltyDS

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

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
Sign in to follow this  
Followers 0