MadBoy Posted January 23, 2006 Share Posted January 23, 2006 Hey, I have problem with FOR. I would like to achieve something like this: #cs $line_01_entry_1 = GUICtrlCreateInput ("", -90, 10, 0, $nr_line) $line_02_entry_1 = GUICtrlCreateInput ("", -90, 10, 0, $nr_line) $line_03_entry_1 = GUICtrlCreateInput ("", -90, 10, 0, $nr_line) #ce So later on i could use $line_01_entry_1 with GUIRead. I tried diffrent combinations but all i could do was: For $i = 00 to 09 Step +1 $string = GUICtrlCreateInput ("", -90, 10, 0, $nr_line) Next But with this code i don't know how to get 'info' later on with GUIRead. Pls help My little company: Evotec (PL version: Evotec) Link to comment Share on other sites More sharing options...
GaryFrost Posted January 23, 2006 Share Posted January 23, 2006 something like the following Local $string[10] For $i = 0 to 9 $string[$i] = GUICtrlCreateInput ("", -90, 10, 0, $nr_line) Next then you do a guictrlread($string[0]) etc... to get the data SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
ACalcutt Posted January 23, 2006 Share Posted January 23, 2006 (edited) what about using an array? For $i = 00 to 09 Step +1 $string[$i] = GUICtrlCreateInput ("", -90, 10, 0, $nr_line) Next edit- got beat... Edited January 23, 2006 by ACalcutt Andrew Calcutt Http://www.Vistumbler.net Http://www.TechIdiots.net Its not an error, its a undocumented feature Link to comment Share on other sites More sharing options...
MadBoy Posted January 23, 2006 Author Share Posted January 23, 2006 something like the following Local $string[10] For $i = 0 to 9 $string[$i] = GUICtrlCreateInput ("", -90, 10, 0, $nr_line) Next then you do a guictrlread($string[0]) etc... to get the data Ah tnx Gafrost Tnx to you too ACalcut.. althought i think you posted diffrent msg earlier and i tried to add it to my code and it was giving me zilions of errors My little company: Evotec (PL version: Evotec) Link to comment Share on other sites More sharing options...
MadBoy Posted January 23, 2006 Author Share Posted January 23, 2006 (edited) Local $ip_input[11] $ip_input[0] = GUICtrlCreateInput ("", 50, 80, 90, $nr_line) Opt( "GUICoordMode", 2) For $i = 01 to 10 Step +1 $ip_input[$i] = GUICtrlCreateInput ("", -90, 10, 0, $nr_line) Next Is this proper thinking Edited January 23, 2006 by MadBoy My little company: Evotec (PL version: Evotec) Link to comment Share on other sites More sharing options...
ACalcutt Posted January 23, 2006 Share Posted January 23, 2006 (edited) Ah tnx Gafrost Tnx to you too ACalcut.. althought i think you posted diffrent msg earlier and i tried to add it to my code and it was giving me zilions of errors you are correct..it was origionally For $i = 00 to 09 Step +1 $line += 1 $string[$line] = GUICtrlCreateInput ("", -90, 10, 0, $nr_line) Next but that should have given errors...unless you didn't Dim $line=0 before that. i changed it because the other method is better CODE Local $ip_input[11]$ip_input[0] = GUICtrlCreateInput ("", 50, 80, 90, $nr_line) Opt( "GUICoordMode", 2) For $i = 01 to 10 Step +1 $ip_input[$i] = GUICtrlCreateInput ("", -90, 10, 0, $nr_line) Next Is this proper thinking i am new to arrays, but i was under the impression that $ip_input[0] would give the total number of items in that array(i would also know the correct answer to this) edit - i tested with this, and it does apear i was wrong about $ip_input[0] being the total number, it just must be some functions that do that Local $array[6] For $i = 1 to 5 $array[$i] = ($i * 2) Next For $j = 0 to 5 msgbox(0, "", $array[$j]) Next Edited January 23, 2006 by ACalcutt Andrew Calcutt Http://www.Vistumbler.net Http://www.TechIdiots.net Its not an error, its a undocumented feature Link to comment Share on other sites More sharing options...
MadBoy Posted January 23, 2006 Author Share Posted January 23, 2006 you are correct..it was origionally For $i = 00 to 09 Step +1 $line += 1 $string[$line] = GUICtrlCreateInput ("", -90, 10, 0, $nr_line) Next but that should have given errors...unless you didn't Dim $line=0 before that. i changed it because the other method is better i am new to arrays, but i was under the impression that $ip_input[0] would give the total number of items in that array(i would also know the correct answer to this) Well the code i posted is working for me without any problems. Just i am not sure if i am doing it right. Maybe there's more proper way to do it. My little company: Evotec (PL version: Evotec) Link to comment Share on other sites More sharing options...
ACalcutt Posted January 23, 2006 Share Posted January 23, 2006 (edited) i am just curious...how come you are putting the [0] outside the for loop? this should do the same thing Local $ip_input[11] Opt( "GUICoordMode", 2) For $i = 0 to 10 $ip_input[$i] = GUICtrlCreateInput ("", -90, 10, 0, $nr_line) Next or maybe use [0] as the amount of things listed in the array? ex. Local $ip_input[11] Opt( "GUICoordMode", 2) For $i = 1 to 10 $ip_input[$i] = GUICtrlCreateInput ("", -90, 10, 0, $nr_line) $ip_input[0] += 1;adds 1 to $ip_input[0] every loop Next this way you can use $ip_input[0] to know how many of the controls were made ( edit - i guess i wouldn't help much...since you already know that from the nubmer used in the FOR loop) Edited January 23, 2006 by ACalcutt Andrew Calcutt Http://www.Vistumbler.net Http://www.TechIdiots.net Its not an error, its a undocumented feature Link to comment Share on other sites More sharing options...
MadBoy Posted January 23, 2006 Author Share Posted January 23, 2006 Well i am using the first $ip_input[0] outside of loop because it states where [x,y] $ip_input[0] = GUICtrlCreateInput ("", [b]50[/b], [b]80[/b], 90, $nr_line) In loop i just add lines that are dependand on that That's the only way i could think of $ip_input[$i] = GUICtrlCreateInput ("", -90, 10, 0, $nr_line) I have another problem thou with the code below. $File_1 is the file that has '2' or more lines with some names. Problem is the files i want (acl.$username.txt) get created but also there is one unnesecary file being created and it's called acl..txt. Also when you open it up it has 3 times more text then the other files. $standard_profile = FileRead($file) Local $line[11]; Declare array Local $users_file[11]; Declare array For $h = 1 to 10 Step +1 $line[$h] = FileReadLine($file_1, $h) $users_file[$h] = $vpn_profiles_path & "\" & "acl" & "." & $line[$h] & ".txt" $write = FileWrite($users_file[$h], $standard_profile) Next My little company: Evotec (PL version: Evotec) Link to comment Share on other sites More sharing options...
MadBoy Posted January 23, 2006 Author Share Posted January 23, 2006 Fixed the problem with counting lines so the For loop wouldn't go more then needed. I guess that's the best solution for it? $get_lines = _FileCountLines( $users_file ) Local $line[$get_lines+1]; Declare array For $h = 1 to $get_lines Step +1 $line[$h] = FileReadLine($file_1, $h) $users_file = $vpn_profiles_path & "\" & "acl" & "." & $line[$h] & ".txt" $write = FileWrite($users_file, $standard_profile) Next My little company: Evotec (PL version: Evotec) Link to comment Share on other sites More sharing options...
PsaltyDS Posted January 23, 2006 Share Posted January 23, 2006 edit - i tested with this, and it does apear i was wrong about $ip_input[0] being the total number, it just must be some functions that do that Using [0] for a count is a very usefull convention. For the purposes of this thread, you can set one line, set an unknown number of other lines realative to the first, then get the count as follows: CODE #include <array.au3> ; At different times we create a different number of lines $Cnt = Random(1, 15, 1) ; Create GUI $MyGui = GUICreate("Test Input Lines", 200, 50 * $Cnt, 50, 50) ; Create array Local $ip_input[1] $ip_input[0] = "" ; Create first line and add it to array _ArrayAdd($ip_input, GUICtrlCreateInput("", 50, 80, 90)) ; Change GUI coordinate mode opt("GUICoordMode", 2) For $i = 2 To $Cnt _ArrayAdd($ip_input, GUICtrlCreateInput("", -90, 10, 0)) Next ; Save count $ip_input[0] = UBound($ip_input) - 1 _ArrayDisplay($ip_input, "List of " & $ip_input[0] & " input CtrlIDs:") I'm too new with GUICoordMode = 2 to know how that gets what you want, but this code gives you an array of ControlIDs for the GuiCtrlInputs, the [0] cell has the count, and you don't have to know ahead of time how many there will be. 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 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