trying to stop script

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
Jmac2501
Pro Scripter
Posts: 76
Joined: Tue Nov 15, 2005 8:11 pm

trying to stop script

Post by Jmac2501 » Tue Nov 15, 2005 10:07 pm

Ok i have a script where i have it GPC> x,y,pc and if = pc then to sent an error message, which it dose just fine but then it continus on with the script from that point on. I know i can put goto>end and it will stop but i can't have it close the dialog box. i need it to stop there and reset itself and not go further.
here is the script: if it goes to the "did not work" screen that means its not stoping the scrip when there is an error.

let>k=0
Dialog>MyDialog
Caption=This is My Dialog
Top=300
Width=305
Left=300
Height=120
Label=Type Something Here:,5,5
Edit=MyEdit,5,22,230,Type Something Here and Press 'Display'
Button=Display,240,22,50,20,3
Button=Exit Macro,5,50,100,20,2
CheckBox=MyCheckBox,Play Chimes?,130,50,90,False
Edit=msEdit1,128,0,49,%k%
EndDialog>MyDialog

Label>MainLoop
Show>MyDialog,result
If>result=2,End
If>result=3,SayHello
if>MyDialog.MyCheckBox=True,PlayWav
Goto>MainLoop

SRT>SayHello
Gpc>189,116,pc
if>%pc%=394231,error
let>k=%k%+1
Let>%MyDialog.msEdit1%=k
ResetDialogAction>MyDialog
//rest of script...
wait>5
message>did not work if this message shows
END>SayHello

srt>error
message>i need it to stop here and go back to the dialog
end>error

SRT>PlayWav
let>k=%k%+1
PlayWav>Chimes.wav
End>PlayWav

Label>End

User avatar
support
Automation Wizard
Posts: 1450
Joined: Sat Oct 19, 2002 4:38 pm
Location: London
Contact:

Post by support » Tue Nov 15, 2005 10:24 pm

Hi,

If I've understood you correctly then you just want to do this:

let>k=0
Dialog>MyDialog
Caption=This is My Dialog
Top=300
Width=305
Left=300
Height=120
Label=Type Something Here:,5,5
Edit=MyEdit,5,22,230,Type Something Here and Press 'Display'
Button=Display,240,22,50,20,3
Button=Exit Macro,5,50,100,20,2
CheckBox=MyCheckBox,Play Chimes?,130,50,90,False
Edit=msEdit1,128,0,49,%k%
EndDialog>MyDialog

Label>MainLoop
Show>MyDialog,result
If>result=2,End
If>result=3,SayHello
if>MyDialog.MyCheckBox=True,PlayWav
Goto>MainLoop

SRT>SayHello
Gpc>189,116,pc
if>%pc%=394231
GoSub>error
else
let>k=%k%+1
Let>%MyDialog.msEdit1%=k
ResetDialogAction>MyDialog
endif
END>SayHello

srt>error
message>i need it to stop here and go back to the dialog
end>error

SRT>PlayWav
let>k=%k%+1
PlayWav>Chimes.wav
End>PlayWav

Label>End

This requires latest version.

If you're using 7.2 (or earlier) which doesn't have if/else/endif you will have to use labels and gotos, something like:

SRT>SayHello
Gpc>189,116,pc
if>%pc%=394231,ErrLabel
let>k=%k%+1
Let>%MyDialog.msEdit1%=k
ResetDialogAction>MyDialog
Goto>EndSayHello
Label>ErrLabel
message>i need it to stop here and go back to the dialog
Label>EndSayHello
END>SayHello

Not as elegant. Use the latest version!
MJT Net Support
[email protected]

Jmac2501
Pro Scripter
Posts: 76
Joined: Tue Nov 15, 2005 8:11 pm

Post by Jmac2501 » Tue Nov 15, 2005 10:47 pm

ok this is how i have it set up but its giving me an error "missing if/endif"

wpc>13421772,128,144,0
GetRectCheckSum>37,363,40,365,grcs1
if>%grcs1%1046898
GoSub>error3
else
gpc>656,583,pc7
if>%pc7%=0
GoSub>error3
else
gpc>270,341,pc3
if>%pc3%=394231
GoSub>end
else
gpc>359,394,pc4
if>%pc4%=255
GoSub>end
else
//rest of script
endif

is that wrong and if so how can i fix it. Thanks by the way you are great.

User avatar
CyberCitizen
Automation Wizard
Posts: 721
Joined: Sun Jun 20, 2004 7:06 am
Location: Adelaide, South Australia

Post by CyberCitizen » Tue Nov 15, 2005 11:24 pm

Ok Long Story Short You Are Missing The End If Command.

Give This A Try, Unable To Test Script, However Should Work.

If You Are Using The If/Else/EndIf Command, I Believe There Needs To Be A Statement For Each If Statement.

The Best Thing You Can Do If You Get Any Missing Label Errors Is To Step Through Your Script With The F8 Command To Find Out Where The Error Is Occuring.

Any Issues Let Us Know.


wpc>13421772,128,144,0
GetRectCheckSum>37,363,40,365,grcs1
if>%grcs1%1046898
GoSub>error3
else
gpc>656,583,pc7
EndIf
if>%pc7%=0
GoSub>error3
else
gpc>270,341,pc3
EndIf
if>%pc3%=394231
GoSub>end
else
gpc>359,394,pc4
EndIf
if>%pc4%=255
GoSub>end
else
EndIf
//rest of script
FIREFIGHTER

Jmac2501
Pro Scripter
Posts: 76
Joined: Tue Nov 15, 2005 8:11 pm

Post by Jmac2501 » Tue Nov 15, 2005 11:37 pm

That work thanks much

Jmac2501
Pro Scripter
Posts: 76
Joined: Tue Nov 15, 2005 8:11 pm

Post by Jmac2501 » Wed Nov 16, 2005 4:10 pm

ok Well it stoped giving me an error but its not stoping the script. once it goes to >error3 it displays the message and when i push ok it continues on from there. i need it to stop.

GetRectCheckSum>37,363,40,365,grcs1
if>%grcs1%1046898
GoSub>error3
else
gpc>656,583,pc7
EndIf
if>%pc7%=0
GoSub>error3
else
gpc>270,341,pc3
EndIf
if>%pc3%=394231
GoSub>end
else
gpc>359,394,pc4
EndIf
if>%pc4%=255
GoSub>end
else
//script here
endif

User avatar
support
Automation Wizard
Posts: 1450
Joined: Sat Oct 19, 2002 4:38 pm
Location: London
Contact:

Post by support » Wed Nov 16, 2005 4:18 pm

I'm having difficulty understanding what you want to do. Am I right in saying you want to show the error and then exit? If so surely you just to do Goto>end after the Gosup and put a label at the end of the script called end.

If I have misunderstood you please post your entire script and explain what you are wanting to do.
MJT Net Support
[email protected]

Jmac2501
Pro Scripter
Posts: 76
Joined: Tue Nov 15, 2005 8:11 pm

Post by Jmac2501 » Wed Nov 16, 2005 4:34 pm

what i want it to do is if i goes to that error screen i want it to stop and to go backl to the dialog box. for exaple in this script:

*mydialog here*

srt>NTF
GetRectCheckSum>37,363,40,365,grcs1
if>%grcs1%1046898
GoSub>error3 656,583,pc7
EndIf
if>%pc7%=0
GoSub>error3
else
gpc>270,341,pc3
EndIf
if>%pc3%=394231
GoSub>end
else
gpc>359,394,pc4
EndIf
if>%pc4%=255
GoSub>end
else
//rest of script
endif
end>NTF

srt>error3
messagemodal>error message
end>error3

But after i push the ok button it continus on with the scrip. i am thinking that i have the if/endif/else in the wrong place. I hope this makes better sence.

User avatar
JRL
Automation Wizard
Posts: 3501
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Wed Nov 16, 2005 5:28 pm

You are calling a subroutine. A subroutine processes then returns you to the point in the script where it was called and the script continues processing from there.

Maybe error3 should be a label instead of a subroutine (srt). Within error3 you could have your message followed by a line that goes to a label where your dialog box will be called.

Jmac2501
Pro Scripter
Posts: 76
Joined: Tue Nov 15, 2005 8:11 pm

Post by Jmac2501 » Wed Nov 16, 2005 6:39 pm

Ok i got it to work but what i had to do is add in a goto>MainLoop and that put it right back to the beginning. Thanks for all your help.

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts