I must be missing something dumb...
IfWindowOpen>macroscheduler.com*,MySubroutine
SRT>MySubroutine
messagemodal>Hello World
End>MySubroutine
Why do I get the error:
"Error - Subroutine/Label Not Found!"
More importantly, how do I fix it?
Thanks in advance!
IfWindowOpen and subroutines
Moderators: JRL, Dorian (MJT support)
- Bob Hansen
- Automation Wizard
- Posts: 2475
- Joined: Tue Sep 24, 2002 3:47 am
- Location: Salem, New Hampshire, US
- Contact:
Good news:
I can recreate the error, get same results. (version 7.2.036, WinSE).
Bad news:
See no obvious errors yet.
1. Added a Label>MySubroutine just before SRT to see results. This made the error message go away.
2. Changed IfWindowOpen> to go to label MySub vs. SRT.
Error still gone away, but SRT still not running.
2. Also added a MessageModal>Window not open after IfWindowOpen>
Closed Window in rest of tests, never called up.
3. Also added a Wait>5 after each MessageModal>
Log results are curious. Neither MessageModal ever gets executed. Wait> commands are not executed
My modified script follows:
Log results are here:
I can recreate the error, get same results. (version 7.2.036, WinSE).
Bad news:
See no obvious errors yet.
1. Added a Label>MySubroutine just before SRT to see results. This made the error message go away.
2. Changed IfWindowOpen> to go to label MySub vs. SRT.
Error still gone away, but SRT still not running.
2. Also added a MessageModal>Window not open after IfWindowOpen>
Closed Window in rest of tests, never called up.
3. Also added a Wait>5 after each MessageModal>
Log results are curious. Neither MessageModal ever gets executed. Wait> commands are not executed
My modified script follows:
=========================IfWindowOpen>Macro Scheduler 7.2*,MySub
MessageModal>Window not open
Wait>5
Goto>End
Label>MySub
SRT>MySubroutine
messagemodal>Hello World
Wait>5
End>MySubroutine
Label>End
Log results are here:
More analysis to follow.....07/22/2003 18:58:07:600 - Started Macro : subname
07/22/2003 18:58:07:600 - Label>MySub
07/22/2003 18:58:07:600 - End>MySubroutine
07/22/2003 18:58:07:650 -
07/22/2003 18:58:07:650 - Label>End
07/22/2003 18:58:07:650 - Finished Macro : subname
Last edited by Bob Hansen on Fri Jul 25, 2003 3:30 pm, edited 1 time in total.
- Bob Hansen
- Automation Wizard
- Posts: 2475
- Joined: Tue Sep 24, 2002 3:47 am
- Location: Salem, New Hampshire, US
- Contact:
Using version 7.2.037, with mixed results on IfWindowOpen> calling SRT.
This works, calling a Sub Routine from an IfWindowOpen>
Here is results of Success Log, using new logging options:
======= Log Before and After Running Steps ==============
08/04/2003 21:42:16:560 - Started Macro : subname
08/04/2003 21:42:16:560 - START: IfWindowOpen>Document - WordPad*,MySub
08/04/2003 21:42:16:620 - END: SRT>MySub
08/04/2003 21:42:16:620 - START: MessageModal>Window is Open
08/04/2003 21:42:19:140 - END: MessageModal>Window is Open
08/04/2003 21:42:19:310 - START: Wait>5
08/04/2003 21:42:24:310 - END: Wait>5
08/04/2003 21:42:24:310 - START: Goto>End
08/04/2003 21:42:24:360 - END: Label>End
08/04/2003 21:42:24:420 - Finished Macro : subname
=============================
But this does not work if the window is open. It does work if the window is not open. This is calling a label followed by SRT. Sub Routine is skipped completely. Changes are Bold Red
Here is results of Failure Logs, using new logging options:
======= Log Before Running Steps ==============
08/04/2003 21:37:02:830 - Started Macro : subname
08/04/2003 21:37:02:880 - IfWindowOpen>Document - WordPad*,MySubRoutine
08/04/2003 21:37:02:880 - SRT>MySub
08/04/2003 21:37:02:940 -
08/04/2003 21:37:02:940 - Label>End
08/04/2003 21:37:02:940 - Finished Macro : subname
======= Log After Running Steps ==============
08/04/2003 21:38:10:770 - Started Macro : subname
08/04/2003 21:38:10:770 - Label>MySubRoutine
08/04/2003 21:38:10:830 - End>MySub
08/04/2003 21:38:10:830 -
08/04/2003 21:38:10:830 - Label>End
08/04/2003 21:38:10:880 - Finished Macro : subname
======= Log Before and After Running Steps ==============
08/04/2003 21:38:52:130 - Started Macro : subname
08/04/2003 21:38:52:180 - START: IfWindowOpen>Document - WordPad*,MySubRoutine
08/04/2003 21:38:52:180 - END: Label>MySubRoutine
08/04/2003 21:38:52:180 - START: SRT>MySub
08/04/2003 21:38:52:240 - END: End>MySub
08/04/2003 21:38:52:240 - START:
08/04/2003 21:38:52:240 - END:
08/04/2003 21:38:52:290 - START: Label>End
08/04/2003 21:38:52:290 - END: Label>End
08/04/2003 21:38:52:290 - Finished Macro : subname
=======================================
Can anyone see any script error that I missed?
Perhaps a SRT will not run if not called by an earlier command? That would make sense. I'll bet that's it! It also means I don't have to put a Goto> statement before any SRT loops to jump over that code...
I think I just solved my own problem.....Cancel my comments about mixed results. Well done!.
(I like the new logging options! )


=====================IfWindowOpen>Document - WordPad*,MySub
MessageModal>Window is not open
Wait>5
Goto>End
SRT>MySub
MessageModal>Window is Open
Wait>5
Goto>End
End>MySub
Label>End
Here is results of Success Log, using new logging options:
======= Log Before and After Running Steps ==============
08/04/2003 21:42:16:560 - Started Macro : subname
08/04/2003 21:42:16:560 - START: IfWindowOpen>Document - WordPad*,MySub
08/04/2003 21:42:16:620 - END: SRT>MySub
08/04/2003 21:42:16:620 - START: MessageModal>Window is Open
08/04/2003 21:42:19:140 - END: MessageModal>Window is Open
08/04/2003 21:42:19:310 - START: Wait>5
08/04/2003 21:42:24:310 - END: Wait>5
08/04/2003 21:42:24:310 - START: Goto>End
08/04/2003 21:42:24:360 - END: Label>End
08/04/2003 21:42:24:420 - Finished Macro : subname
=============================

===========================IfWindowOpen>Document - WordPad*,MySubRoutine
MessageModal>Window is not open
Wait>5
Goto>End
Label>MySubRoutine
SRT>MySub
MessageModal>Window is Open
Wait>5
Goto>End
End>MySub
Label>End
Here is results of Failure Logs, using new logging options:
======= Log Before Running Steps ==============
08/04/2003 21:37:02:830 - Started Macro : subname
08/04/2003 21:37:02:880 - IfWindowOpen>Document - WordPad*,MySubRoutine
08/04/2003 21:37:02:880 - SRT>MySub
08/04/2003 21:37:02:940 -
08/04/2003 21:37:02:940 - Label>End
08/04/2003 21:37:02:940 - Finished Macro : subname
======= Log After Running Steps ==============
08/04/2003 21:38:10:770 - Started Macro : subname
08/04/2003 21:38:10:770 - Label>MySubRoutine
08/04/2003 21:38:10:830 - End>MySub
08/04/2003 21:38:10:830 -
08/04/2003 21:38:10:830 - Label>End
08/04/2003 21:38:10:880 - Finished Macro : subname
======= Log Before and After Running Steps ==============
08/04/2003 21:38:52:130 - Started Macro : subname
08/04/2003 21:38:52:180 - START: IfWindowOpen>Document - WordPad*,MySubRoutine
08/04/2003 21:38:52:180 - END: Label>MySubRoutine
08/04/2003 21:38:52:180 - START: SRT>MySub
08/04/2003 21:38:52:240 - END: End>MySub
08/04/2003 21:38:52:240 - START:
08/04/2003 21:38:52:240 - END:
08/04/2003 21:38:52:290 - START: Label>End
08/04/2003 21:38:52:290 - END: Label>End
08/04/2003 21:38:52:290 - Finished Macro : subname
=======================================
Can anyone see any script error that I missed?



(I like the new logging options! )

Hi,
Your code will not work because your subroutine is never called!!
Subroutines are only executed when they are called (either by a Gosub or from one of the If commands). Subroutine blocks are completely ignored in all other circumstances.
You could make your code work by either adding a Gosub after the Label>MySubroutine, or by changing the IfWindowOpen line to call the subroutine rather than the label.
This is correct behaviour and is how subroutines should work.
Your code will not work because your subroutine is never called!!
Subroutines are only executed when they are called (either by a Gosub or from one of the If commands). Subroutine blocks are completely ignored in all other circumstances.
You could make your code work by either adding a Gosub after the Label>MySubroutine, or by changing the IfWindowOpen line to call the subroutine rather than the label.
This is correct behaviour and is how subroutines should work.
MJT Net Support
[email protected]
[email protected]
- Bob Hansen
- Automation Wizard
- Posts: 2475
- Joined: Tue Sep 24, 2002 3:47 am
- Location: Salem, New Hampshire, US
- Contact: