IfWindowOpen and subroutines

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
crozzer

IfWindowOpen and subroutines

Post by crozzer » Mon Jul 21, 2003 4:56 am

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!

Lumumba

Post by Lumumba » Mon Jul 21, 2003 11:13 am

Have you checked that you've not been trapped by the famous "trailing space" on labels\variables error?

Check the length of your lines. Goto to each line and press the End key

e.g. MySubroutine is diferent from MySubroutine

Guest

Post by Guest » Tue Jul 22, 2003 5:38 am

No, I have not made the aforementioned "space case" error. Cut and paste and see if it works for you?

Any ideas? thoughts?

thanks

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Tue Jul 22, 2003 11:08 pm

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:

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:
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
More analysis to follow.....
Last edited by Bob Hansen on Fri Jul 25, 2003 3:30 pm, edited 1 time in total.

Peter

Post by Peter » Fri Jul 25, 2003 3:13 pm

I ran into this last week and assumed it was something I was doing wrong.

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Tue Aug 05, 2003 1:35 am

Using version 7.2.037, with mixed results on IfWindowOpen> calling SRT. :?

:D This works, calling a Sub Routine from an IfWindowOpen>
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
=============================
:( 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
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? :?:

:idea: 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... :D I think I just solved my own problem.....Cancel my comments about mixed results. Well done!.

(I like the new logging options! ) :D

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

Post by support » Tue Aug 05, 2003 8:40 am

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.
MJT Net Support
[email protected]

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Tue Aug 05, 2003 9:18 pm

Thanks for confirming my conclusion.

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