IfFileExists

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
MacschedStudent
Junior Coder
Posts: 36
Joined: Fri Oct 12, 2007 5:55 pm
Location: federal way wa
Contact:

IfFileExists

Post by MacschedStudent » Fri Jan 04, 2008 5:20 am

Guys look at this code:



IfFileExists>codex.log,xout

Goto>kpgo




Label>xout
Exit


Label>kpgo
WLN>Marker,result,test





I have also tried it this way with the same results:

IfFileExists>codex.log,xout,kpgo
..
..
..
..
Label>xout
Exit


Label>kpgo
WLN>Marker,result,test





Correct me if I'm wrong, but the marker file (under the kpgo label)should not be written if the exit command is prior to it.

I guess the question I'm asking is, does the logic go passed the Exit command even though the label is below it.

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Fri Jan 04, 2008 8:42 am

Exit is a new command in version 10. So it won't do anything if you are running an earlier version. Also, it should look like this:

Exit>result_code

E.g.:

Exit>0

When the script reaches the Exit>0 line it will terminate.

Here's how I would code your script:

Code: Select all

IfFileExists>codex.log
  Exit>0
Else
  WriteLn>Marker,result,test
Endif
In fact this is all you need:

Code: Select all

IfFileExists>codex.log
Else
  WriteLn>Marker,result,test
Endif
All those gotos and labels are unnecessary and just make it harder to read.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

BlackWisdom
Pro Scripter
Posts: 58
Joined: Thu Oct 16, 2003 12:53 am

Post by BlackWisdom » Fri Jan 04, 2008 5:11 pm

Thanks Marcus...

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