alibaba Posted January 29, 2009 Share Posted January 29, 2009 I set a hotkey in my script for interrupting the execution. The hotkey starts a GUI-containing function where the user can decide wether to stop the script or to continue it. My question is if there is a possibility to show the current script line number where the script was interrupted by pushing the hotkey? I think there should be a possibility because after the hotkey function ends the execution continues at the interruption point which means that this line number (or something related) has to be stored somewhere. Could anybody give my a hint how to solve this? I know '@script line number' and 'trayicondebug' but I didn't succed in using them in this case (same problems as mentioned in other threads). Help would be really appreciated! Link to comment Share on other sites More sharing options...
jaberwacky Posted January 29, 2009 Share Posted January 29, 2009 I set a hotkey in my script for interrupting the execution. The hotkey starts a GUI-containing function where the user can decide wether to stop the script or to continue it. My question is if there is a possibility to show the current script line number where the script was interrupted by pushing the hotkey? I think there should be a possibility because after the hotkey function ends the execution continues at the interruption point which means that this line number (or something related) has to be stored somewhere. Could anybody give my a hint how to solve this?I know '@script line number' and 'trayicondebug' but I didn't succed in using them in this case (same problems as mentioned in other threads).Help would be really appreciated!An *.au3 file is just a text file. Use @scriptlinenumber to go to that line in the .au3 file and then have it display in your gui. Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
alibaba Posted January 29, 2009 Author Share Posted January 29, 2009 An *.au3 file is just a text file. Use @scriptlinenumber to go to that line in the .au3 file and then have it display in your gui.I tried it like that but I only got the script line number of the script line in the hotkey function where the @scriptlinenumber command is. How I have to do it to get the other line? Link to comment Share on other sites More sharing options...
Authenticity Posted January 29, 2009 Share Posted January 29, 2009 The script line is your visual friend but in the background it's not so, the system handle all this activity after you've registered a hot-key and push the return address on the stack and then interrupt the command that was on the EIP register. There is a way to do it in your script in the ants way like on each line store in some global variables $line the script line macro value minus 1 which can get your script execute more unneeded commands (double). The other way which makes more sense to me is to store on function entrance the line in a global variable and that's it, no need more @ScriptLineNumber calls, IMO. Link to comment Share on other sites More sharing options...
PsaltyDS Posted January 29, 2009 Share Posted January 29, 2009 I tried it like that but I only got the script line number of the script line in the hotkey function where the @scriptlinenumber command is. How I have to do it to get the other line? I don't think you have access to it from the script. If you are debugging a problem, you could put the following compiler directive at the top of your script: #AutoIt3Wrapper_run_debug_mode=Y It will be obvious from the output where it was when the hotkey was called. 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...
alibaba Posted January 30, 2009 Author Share Posted January 30, 2009 The script line is your visual friend but in the background it's not so, the system handle all this activity after you've registered a hot-key and push the return address on the stack and then interrupt the command that was on the EIP register. There is a way to do it in your script in the ants way like on each line store in some global variables $line the script line macro value minus 1 which can get your script execute more unneeded commands (double). The other way which makes more sense to me is to store on function entrance the line in a global variable and that's it, no need more @ScriptLineNumber calls, IMO.That sounds good, I think that's what I need. But... ... could you please post this entrance part of such a function? I don't know how to code this, sorry! Link to comment Share on other sites More sharing options...
alibaba Posted January 31, 2009 Author Share Posted January 31, 2009 I don't think you have access to it from the script. If you are debugging a problem, you could put the following compiler directive at the top of your script: #AutoIt3Wrapper_run_debug_mode=Y It will be obvious from the output where it was when the hotkey was called. I don't want to use it for debugging, I just want to use it as an info tool in an established program to record the script line when the hot key was pressed. Link to comment Share on other sites More sharing options...
martin Posted January 31, 2009 Share Posted January 31, 2009 You can easily use Psalty's suggestion for functions like this. (If I underrstood what he said.)HotkeySet("{F10}", "WhatFunc") $Func = "Global space" GUICreate("Press Esc to Increment", 400, 400,0,0,0x04CF0000, 0x00000110) $Btn1 = GUICtrlCreateButton("go to Func1",20,20,100,22) GUISetState () While 1 $msg = GUIGetMsg() if $Msg = -3 then ExitLoop if $Msg = $Btn1 then Func1() sleep(20) WEnd Exit Func WhatFunc() msgbox(262144,"You are in this part of the script",$Func) EndFunc Func Func1() $Func = "Func1" for $n = 1 to 100 sleep(50) Next $func = "Global space" EndFuncIf you want to know the actual line number then it is more difficult. It would be easy to add line numbers by just having a script which reads the script and inserts something between every line like this$fin = Fileopen("script.au3",0) $fout = Fileopen(ScripWithLineNums",2) $count = 0 while 1 $line = FileReadLine($fin) if @error then ExitLoop $count += 1 FileWriteLine($fout,"$linenum = " & $count) FileWriteLine($fout,$line) WEnd FileClose($fin) FileClose($fout)But this will go wrong if you haveIf statements, Switch statements and so on. If that approach is of interest I have a script which is used in my debugger which does that and a lot more, but it could easily be simplified it. (Not volunteering If you run the script is asks for the file to be converted and then produces a modified version which reports at every line the line number, current function, the parameters passed to the function, variables which have changed, etc. 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...
alibaba Posted January 31, 2009 Author Share Posted January 31, 2009 You can easily use Psalty's suggestion for functions like this. (If I underrstood what he said.) HotkeySet("{F10}", "WhatFunc") $Func = "Global space" GUICreate("Press Esc to Increment", 400, 400,0,0,0x04CF0000, 0x00000110) $Btn1 = GUICtrlCreateButton("go to Func1",20,20,100,22) GUISetState () While 1 $msg = GUIGetMsg() if $Msg = -3 then ExitLoop if $Msg = $Btn1 then Func1() sleep(20) WEnd Exit Func WhatFunc() msgbox(262144,"You are in this part of the script",$Func) EndFunc Func Func1() $Func = "Func1" for $n = 1 to 100 sleep(50) Next $func = "Global space" EndFunc If you want to know the actual line number then it is more difficult. It would be easy to add line numbers by just having a script which reads the script and inserts something between every line like this $fin = Fileopen("script.au3",0) $fout = Fileopen(ScripWithLineNums",2) $count = 0 while 1 $line = FileReadLine($fin) if @error then ExitLoop $count += 1 FileWriteLine($fout,"$linenum = " & $count) FileWriteLine($fout,$line) WEnd FileClose($fin) FileClose($fout) But this will go wrong if you haveIf statements, Switch statements and so on. If that approach is of interest I have a script which is used in my debugger which does that and a lot more, but it could easily be simplified it. (Not volunteering If you run the script is asks for the file to be converted and then produces a modified version which reports at every line the line number, current function, the parameters passed to the function, variables which have changed, etc. Hi Martin! Thanks a lot for your reply! The second script pushed me on the right way! I won't add a new number after every script line, but manually at certain "critical" positions. This enables me to get the current position by reading §linenum at the beginning of the hotkey-function where I don't place the numbers. And that's all - for the moment... Thanks again, also all of the others for your replies! 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