Appie78 Posted February 19, 2009 Share Posted February 19, 2009 Hi all, I'm having some problems with starting a function for the second time thru a while loop. The first time the function works fine, if I want to start it for the second time nothing happens! Does anyone have any idea's? Thanks Electron microscopes rule!!! Link to comment Share on other sites More sharing options...
sandin Posted February 19, 2009 Share Posted February 19, 2009 part of the script, or the script itself would be most useful... Some cool glass and image menu | WinLIRC remote controler | Happy Holidays to all... | Bounce the sun, a game in which you must save the sun from falling by bouncing it back into the sky | Hook Leadtek WinFast TV Card Remote Control Msges | GDI+ sliding toolbar | MIDI Keyboard (early alpha stage, with lots of bugs to fix) | Alt+Tab replacement | CPU Benchmark with pretty GUI | Ini Editor - Edit/Create your ini files with great ease | Window Manager (take total control of your windows) Pretty GUI! | Pop-Up window from a button | Box slider for toolbar | Display sound volume on desktop | Switch hotkeys with mouse scroll Link to comment Share on other sites More sharing options...
Appie78 Posted February 19, 2009 Author Share Posted February 19, 2009 This is the code!! CODE While 1 $msg = GUIGetMsg() Select Case $msg = $holder1 Holder1() Case $msg = $recall Recall() Case $msg = $Version MsgBox(0, "Custom Service", "Version 1.4.5") Case $msg = $Help File() Case $msg = $GUI_EVENT_CLOSE or $msg = $exit Exit EndSelect WEnd Func Recall() $Recall = FileOpen("c:\Positions.log", 0); If $recall = -1 Then Return MsgBox(0, "Error", "No file with positions.") Exit EndIf $line = FileRead($recall) $avArray = StringSplit($line, ";",1); _ArrayTrim($avArray, 2, 0, 2) _ArrayDisplay($avArray) $tel = UBound($avArray) $coor = $tel - 2; posities - 2. If $coor < 3 Then Return MsgBox(0,"JEOL Custom Service", "No data in file or corrupted file.") Exit EndIf For $i = 1 To $coor Step 3 $x = $avArray[$i] $y = $avArray[$i+1] $r = $avArray[$i+2] WinActivate("JEOL Scanning Electron Microscope") Sleep(200) ControlClick ("JEOL Scanning Electron Microscope", "", 95 , "left" , 1 , 20 , 20); view25 Sleep(1000) ControlClick("JEOL Scanning Electron Microscope", "", 89, "left", 1, 20, 20) Sleep(500) WinActivate("Stage Control") Sleep(200) send("!p") Send($x) Send("{Tab}") Send($y) Send("{Tab}") Send($r) Sleep(200) ControlClick("Positioning", "", 1, "left", 1, 20, 20) Sleep(1000) ControlClick ("JEOL Scanning Electron Microscope", "", 95 , "left" , 1 , 20 , 20) Sleep(500) If $i = $coor - 2 Then $msg = MsgBox(0,"JEOL Custom Service", "Finished") Else $msg = MsgBox(1, "JEOL Custom Service", "Continue or Cancel?") If $msg = 2 Then ExitLoop Else MsgBox(0,"JEOL Custom Service", "Moving to next position",3) EndIf EndIf Next FileClose($Recall) EndFunc Electron microscopes rule!!! Link to comment Share on other sites More sharing options...
sandin Posted February 19, 2009 Share Posted February 19, 2009 no issue there. issue must be in one of your functions (holder1, recall, or other...) -you forgot wend, but I assume you have it in your full script. Some cool glass and image menu | WinLIRC remote controler | Happy Holidays to all... | Bounce the sun, a game in which you must save the sun from falling by bouncing it back into the sky | Hook Leadtek WinFast TV Card Remote Control Msges | GDI+ sliding toolbar | MIDI Keyboard (early alpha stage, with lots of bugs to fix) | Alt+Tab replacement | CPU Benchmark with pretty GUI | Ini Editor - Edit/Create your ini files with great ease | Window Manager (take total control of your windows) Pretty GUI! | Pop-Up window from a button | Box slider for toolbar | Display sound volume on desktop | Switch hotkeys with mouse scroll Link to comment Share on other sites More sharing options...
Appie78 Posted February 19, 2009 Author Share Posted February 19, 2009 Thanks Sandin, But this function is stand alone and it's always the same even when I start the script and immediatly start this function. So no interference of an other function!! Greetz Electron microscopes rule!!! Link to comment Share on other sites More sharing options...
sandin Posted February 19, 2009 Share Posted February 19, 2009 one of your functions must have infinite loop, like While 1, or Do which is never ended, that's why you can run your functions only for the 1st time Some cool glass and image menu | WinLIRC remote controler | Happy Holidays to all... | Bounce the sun, a game in which you must save the sun from falling by bouncing it back into the sky | Hook Leadtek WinFast TV Card Remote Control Msges | GDI+ sliding toolbar | MIDI Keyboard (early alpha stage, with lots of bugs to fix) | Alt+Tab replacement | CPU Benchmark with pretty GUI | Ini Editor - Edit/Create your ini files with great ease | Window Manager (take total control of your windows) Pretty GUI! | Pop-Up window from a button | Box slider for toolbar | Display sound volume on desktop | Switch hotkeys with mouse scroll Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 19, 2009 Moderators Share Posted February 19, 2009 Pokerface,Although you have not shown your GUI creation code, from the While...WEnd loop, it is obvious that you created a control in your GUI and stored its ControlID in variable $recall. Becasue it was created in the main script and not in a function, it is automatically Global in scope.Then in your Recall() function, you reuse the same variable to hold the file handle when you open c:\Positions.log. So when you go back to the While...WEnd loop, the value in $recall is no longer the ControlID and GUIGetMsg is most unlikely to produce the new value!Solution: Set the $recall variable in the function as a Local variable - or better still, do not reuse variable names!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 February 19, 2009 Author Share Posted February 19, 2009 Pokerface,Although you have not shown your GUI creation code, from the While...WEnd loop, it is obvious that you created a control in your GUI and stored its ControlID in variable $recall. Becasue it was created in the main script and not in a function, it is automatically Global in scope.Then in your Recall() function, you reuse the same variable to hold the file handle when you open c:\Positions.log. So when you go back to the While...WEnd loop, the value in $recall is no longer the ControlID and GUIGetMsg is most unlikely to produce the new value!Solution: Set the $recall variable in the function as a Local variable - or better still, do not reuse variable names!M23You where spot on!!!Thanks I was using $recall in my GUI aswell!!!Thanks again,Pokerface Electron microscopes rule!!! 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