Appie78 Posted March 4, 2009 Share Posted March 4, 2009 Hi Guys, Is it possible to change the value of $i while the loop is running? For $i = 1 to 10 Step 3 Thanks Electron microscopes rule!!! Link to comment Share on other sites More sharing options...
Authenticity Posted March 4, 2009 Share Posted March 4, 2009 Yup, but not the end case. For example if the loop is processing until i is equal to the UBound of an array then resizing this array won't change the amount of loops. For this kind of task there is While..WEnd or Do...Until Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 4, 2009 Moderators Share Posted March 4, 2009 Pokerface, Have you tried? M23 P.S. Yes. Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
James Posted March 4, 2009 Share Posted March 4, 2009 Like this? Dim $a = 5, $x = False For $i = 1 To 10 If $x = False Then $i = $a $x = True EndIf ConsoleWrite($i & @CRLF) Next Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
Appie78 Posted March 4, 2009 Author Share Posted March 4, 2009 CODEFunc Recall() $Recall1 = FileOpen("c:\program files\scan sample\Positions.log", 0); Laad het bestand met de posities. MsgBox(0,"", $Recall1) If $Recall1 = -1 Then Return MsgBox(0, "Error", "No file with positions.") Exit EndIf $Line = FileRead($Recall1); Lees het file uit. $AvArray = StringSplit($Line, ";", 1); Zet de waardes in een Array en scheid ze door de ; weg te halen. _ArrayTrim($AvArray, 2, 0, 2) $Tel = UBound($AvArray); tel het aantal posities. $Coor = $Tel - 2; posities - 2. If $Coor < 3 Then Return MsgBox(0, "Custom Service", "No data or corrupted file.") Exit EndIf HotKeySet("{bs}", "BackRecall") For $q = 1 To $Coor Step 3 $u = $AvArray[$q] $v = $AvArray[$q + 1] $w = $AvArray[$q + 2] WinActivate("Scanning Electron Microscope") Sleep(200) ControlClick("Scanning Electron Microscope", "", 89, "left", 1, 20, 20); Stage control10 Sleep(100) WinActivate("Stage Control") Sleep(200) Send("!p") Send($u) Send("{Tab}") Send($v) Send("{Tab}") Send($w) Sleep(1000) ControlClick("Positioning", "", 1, "left", 1, 20, 20); Verplaats naar positie Sleep(5000) If $q = $Coor - 2 Then MsgBox(0, "Custom Service", "Finished"); Alle posities bekeken Else $Msg = MsgBox(1, "Custom Service", "Continue or Cancel?"); Naar de volgende positie of stoppen? If $Msg = 2 Then ExitLoop Else MsgBox(0, "Custom Service", "Moving to next position", 3); Verplaats naar positie EndIf EndIf Next HotKeySet("{bs}") FileClose($Recall1) EndFunc ;==>Recall Func BackRecall() ControlClick("Stage Control", "", 3, "left", 1, 20, 20) $d = $q - 3 EndIf MsgBox(0, "", $d) $a = $AvArray[$d] $b = $AvArray[$d + 1] $c = $AvArray[$d + 2] WinActivate("Scanning Electron Microscope") Sleep(200) ControlClick("Scanning Electron Microscope", "", 89, "left", 1, 20, 20); Stage control10 Sleep(100) WinActivate("Stage Control") Sleep(200) Send("!p") Send($a) Send("{Tab}") Send($ Send("{Tab}") Send($c) Sleep(1000) ControlClick("Positioning", "", 1, "left", 1, 20, 20); Verplaats naar positie Sleep(5000) $q = $q - 3 EndFunc This is my code, I want to decrease $q by 3. To set the array to the correct values. Electron microscopes rule!!! Link to comment Share on other sites More sharing options...
James Posted March 4, 2009 Share Posted March 4, 2009 For $i = 1 to 10 Step 3 ... Next Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
Appie78 Posted March 4, 2009 Author Share Posted March 4, 2009 Hi James, If you look at the BackRecall function you'll see I want to decrease $q by 3. Hoping that the Recall function changes its value. Cheers. Electron microscopes rule!!! Link to comment Share on other sites More sharing options...
Marlo Posted March 4, 2009 Share Posted March 4, 2009 For $I = 30 To 1 Step -3 Next Click here for the best AutoIt help possible.Currently Working on: Autoit RAT Link to comment Share on other sites More sharing options...
James Posted March 4, 2009 Share Posted March 4, 2009 (edited) Hi James, If you look at the BackRecall function you'll see I want to decrease $q by 3. Hoping that the Recall function changes its value. Cheers. Well think about it... Increase, "3" and to decrease.... We minus :0 "-3". For $q = 1 To $Coor Step -3 Edit: Smiley fix Edited March 4, 2009 by JamesBrooks Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
Appie78 Posted March 4, 2009 Author Share Posted March 4, 2009 Hi James, Did you read my code or did you just look at the question at the top? please read the code maybe you can give me better info. Arnaud Electron microscopes rule!!! Link to comment Share on other sites More sharing options...
James Posted March 4, 2009 Share Posted March 4, 2009 Hi James, Did you read my code or did you just look at the question at the top? please read the code maybe you can give me better info. ArnaudBoth. expandcollapse popupFunc Recall() $Recall1 = FileOpen("c:\program files\scan sample\Positions.log", 0); Laad het bestand met de posities. MsgBox(0,"", $Recall1) If $Recall1 = -1 Then Return MsgBox(0, "Error", "No file with positions.") Exit EndIf $Line = FileRead($Recall1); Lees het file uit. $AvArray = StringSplit($Line, ";", 1); Zet de waardes in een Array en scheid ze door de; weg te halen. _ArrayTrim($AvArray, 2, 0, 2) $Tel = UBound($AvArray); tel het aantal posities. $Coor = $Tel - 2; posities - 2. If $Coor < 3 Then Return MsgBox(0, "Custom Service", "No data or corrupted file.") Exit EndIf HotKeySet("{bs}", "BackRecall") For $q = 1 To $Coor Step -3 $u = $AvArray[$q] $v = $AvArray[$q + 1] $w = $AvArray[$q + 2] WinActivate("Scanning Electron Microscope") Sleep(200) ControlClick("Scanning Electron Microscope", "", 89, "left", 1, 20, 20); Stage control10 Sleep(100) WinActivate("Stage Control") Sleep(200) Send("!p") Send($u) Send("{Tab}") Send($v) Send("{Tab}") Send($w) Sleep(1000) ControlClick("Positioning", "", 1, "left", 1, 20, 20); Verplaats naar positie Sleep(5000) If $q = $Coor - 2 Then MsgBox(0, "Custom Service", "Finished"); Alle posities bekeken Else $Msg = MsgBox(1, "Custom Service", "Continue or Cancel?"); Naar de volgende positie of stoppen? If $Msg = 2 Then ExitLoop Else MsgBox(0, "Custom Service", "Moving to next position", 3); Verplaats naar positie EndIf EndIf Next HotKeySet("{bs}") FileClose($Recall1) EndFunc;==>Recall Func BackRecall() ControlClick("Stage Control", "", 3, "left", 1, 20, 20) $d = $q - 3 EndIf MsgBox(0, "", $d) $a = $AvArray[$d] $b = $AvArray[$d + 1] $c = $AvArray[$d + 2] WinActivate("Scanning Electron Microscope") Sleep(200) ControlClick("Scanning Electron Microscope", "", 89, "left", 1, 20, 20); Stage control10 Sleep(100) WinActivate("Stage Control") Sleep(200) Send("!p") Send($a) Send("{Tab}") Send($b) Send("{Tab}") Send($c) Sleep(1000) ControlClick("Positioning", "", 1, "left", 1, 20, 20); Verplaats naar positie Sleep(5000) $q = $q - 3 EndFunc Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
Appie78 Posted March 4, 2009 Author Share Posted March 4, 2009 Hi James, I understand your solution but it's not my problem!!!!! Let me try to explain a bit better. I've got coordinats (x, y, r) saved in a file, I want to recall these coordinats. That's where the Recall() comes in. But I want to make it possible to go back 1 position that's where the BackRecall() comes in. If the position is back by 1 the recall position is doing it's next cycle and continues with the 3rd so the second position is skipped. I don't want to skip this position so I need to change the For..Next loop. I hope this clears up my problem. Thanks Electron microscopes rule!!! Link to comment Share on other sites More sharing options...
James Posted March 4, 2009 Share Posted March 4, 2009 Sorry, I am taking a shot in the darkness here but try this perhaps? Step $myStep Where $myStep is a variable determined by the code. Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 4, 2009 Moderators Share Posted March 4, 2009 Pokerface,Why not use a 2D array to save your coordinates and avoid all this triple-jumping?Global $AvArray[n][3] .. $u = $AvArray[$q][0] $v = $AvArray[$q][1] $w = $AvArray[$q][2]Then you only need to jump one forward/back and the Step value becomes moot.M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Appie78 Posted March 5, 2009 Author Share Posted March 5, 2009 @ James, The $Step seems to work!! @ M23 A 2d array may come in handy. Does anybody have an example how to make an 2d array from a file? Thanks Electron microscopes rule!!! Link to comment Share on other sites More sharing options...
BrettF Posted March 5, 2009 Share Posted March 5, 2009 Well whats the contents of the file? Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
Appie78 Posted March 5, 2009 Author Share Posted March 5, 2009 @ Brettf The content of the file are coordinats so only numbers which are seperated by a ; Thanks Electron microscopes rule!!! Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 5, 2009 Moderators Share Posted March 5, 2009 Pokerface,If your coordinates file looks like this:1-1;1-2;1-3;2-1;2-2;2-3;3-1;3-2;3-3;4-1;4-2;4-3then this code:#include <Array.au3> $sString = FileRead("coords.txt") ConsoleWrite($sString & @CRLF) $aCoords_1D = StringSplit($sString, ";") _ArrayDisplay($aCoords_1D) Global $aCoords_2D[$aCoords_1D[0] / 3][3] $k = 1 For $i = 0 To 3 For $j = 0 To 2 $aCoords_2D[$i][$j] = $aCoords_1D[$k] $k += 1 Next Next _ArrayDisplay($aCoords_2D)will get it into a 2D array.Array.au3 is only included to show you the results via _ArrayDisplay - it is not needed for the actual code. You will have to check that the size of the first dimension of your 2D array is correctly set. AutoIt kindly sets the [0] element of the array produced by StringSplit to the number of elements found - so if you are sure that you have only coord-triplets, you just need to divide this number by 3.You will doubtless have to tweak this a bit to meet your requirements, but I hope the basic principles are clear.M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Appie78 Posted March 5, 2009 Author Share Posted March 5, 2009 Thanks M23, The 2d array works fine after some adjustments like you sad. I thought that the $step in For $i = 0 to $Coor Step $step worked but I was mistaking. I've tried to work with an .Ini file aswell, didn't work. Does anybody got any suggestions? Pokerface Electron microscopes rule!!! Link to comment Share on other sites More sharing options...
BrettF Posted March 6, 2009 Share Posted March 6, 2009 Give us an example of the contents of the file (what you want to store in the array). Heck, I ain't no mind reader. Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! 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