Source Code Reminder

Example scripts and tips (replaces Old Scripts & Tips archive)

Moderators: Dorian (MJT support), JRL, Phil Pendlebury

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

Source Code Reminder

Post by Marcus Tettmar » Wed Dec 17, 2008 3:06 pm

Submitted by Garry Petzold

I dont know if anybody else has a use for this, and I am sure you can clean it up tremendously, but I use this script prior to compiling and leaving at a customer's location. This allows me to run the exe and pass the parameters /RemindMePlease=YesPlease and see the original script.

Code: Select all

Let>APP_TITLE=Remind Me Please

Let>INPUT_BROWSE=1
Input>origscript_,Which script file do you want to modify for remind me,

Let>tmpfile_=%TEMP_DIR%\remindme.txt
Let>remindfile_=%TEMP_DIR%\remindfile_.txt

IfFileExists>%tmpfile_%
  DeleteFile>%tmpfile_%
EndIf>

ReadFile>%origscript_%,entireorigscript_
WriteLn>%tmpfile_%,,If>%RemindMePlease%=YesPlease
WriteLn>%tmpfile_%,,GoSub>RemindMe
WriteLn>%tmpfile_%,,EndIf
WriteLn>%tmpfile_%,,%entireorigscript_%
WriteLn>%tmpfile_%,,SRT>RemindMe

Let>lineno_=1
Label>ReadNextLine_
ReadLn>%origscript_%,%lineno_%,oscurrentline_
If>%oscurrentline_%=##EOF##
  WriteLn>%tmpfile_%,,ExecuteFile>%remindfile_%,
  WriteLn>%tmpfile_%,,MDL>Reminder Complete
  WriteLn>%tmpfile_%,,IfFileExists>%remindfile_%
  WriteLn>%tmpfile_%,,DeleteFile>%remindfile_%
  WriteLn>%tmpfile_%,,EndIf>
  WriteLn>%tmpfile_%,,END>RemindMe
  ExecuteFile>%tmpfile_%,
Else
  WriteLn>%tmpfile_%,,WriteLn>%remindfile_%,,%oscurrentline_%
  Let>lineno_=%lineno_%+1
  Goto>ReadNextLine_
EndIf
What this does is store the script source inside a subroutine which writes it back out to a file when called.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

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 » Wed Dec 17, 2008 4:53 pm

Nice work Garry.

A great example of a dynamic script usage.

What i have been doing until now is to make a ReadOnly copy of the original script file and save it in a hidden folder. But have to remember to do it, need to remember the folder and file names many months later, and could be lost by hard drive tasks, maintenance, drive swaps, etc. This keeps the original as part of the script so it can never be lost.

I gave just added this script to my tool box, thanks for sharing it with us.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

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