Compiled or script (variable wanted)

Ideas for new features & functions

Moderators: Dorian (MJT support), JRL

Post Reply
User avatar
Grovkillen
Automation Wizard
Posts: 998
Joined: Fri Aug 10, 2012 2:38 pm
Location: Bräcke, Sweden
Contact:

Compiled or script (variable wanted)

Post by Grovkillen » Sat Feb 01, 2020 7:30 pm

I find myself using this over and over again just to see if the script is running as compiled or in developer mode (as I like to think about it).
I would be really happy if we could just look at a variable to tell if it's running as compiled or script (through the editor).

Code: Select all

Let>REGEX_PATTERN=(?<=").*?(?=")
RegEx>REGEX_PATTERN,COMMAND_LINE,0,SCRIPT_DIR_CMD,,,,
Separate>SCRIPT_DIR_CMD_1,\,SCRIPT_DIR_CMD
Let>RUNNED_EXE=SCRIPT_DIR_CMD_%SCRIPT_DIR_CMD_count%
If>RUNNED_EXE=msched.exe
  //Running in dev mode
Else>
  //Running as compiled
Endif>
Let>ME=%Script%

Running: 15.0.24
version history

User avatar
Grovkillen
Automation Wizard
Posts: 998
Joined: Fri Aug 10, 2012 2:38 pm
Location: Bräcke, Sweden
Contact:

Re: Compiled or script (variable wanted)

Post by Grovkillen » Sat Feb 01, 2020 7:41 pm

And as a follow up on this, I would be really happy to have a %SCRIPT_DIR_PARENT% (similar to ../ in other coding languages). See this code snippet for the "why" :)

Code: Select all

Let>REGEX_PATTERN=(?<=").*?(?=")
RegEx>REGEX_PATTERN,COMMAND_LINE,0,SCRIPT_DIR_CMD,,,,
Separate>SCRIPT_DIR_CMD_1,\,SCRIPT_DIR_CMD
Let>RUNNED_EXE=SCRIPT_DIR_CMD_%SCRIPT_DIR_CMD_count%
If>RUNNED_EXE=msched.exe
  //Running in dev mode
  Separate>%SCRIPT_DIR%,\,SCRIPT_DIR_PATH
  Let>k=0
  Let>k_stop=SCRIPT_DIR_PATH_count-1
  Let>SCRIPT_IMPORTS=
  Repeat>k
    Let>k=k+1
    ConCat>SCRIPT_IMPORTS,SCRIPT_DIR_PATH_%k%
    ConCat>SCRIPT_IMPORTS,\
  Until>k=k_stop
  Include>%SCRIPT_IMPORTS%script_imports\lib_get_root_path.scp
  Include>%SCRIPT_IMPORTS%script_imports\dialog_monitor.scp
  Include>%SCRIPT_IMPORTS%script_imports\standard_loop.scp
Else>
  //Running as compiled
  Include>%SCRIPT_DIR%\script_imports\lib_get_root_path.scp
  Include>%SCRIPT_DIR%\script_imports\dialog_monitor.scp
  Include>%SCRIPT_DIR%\script_imports\standard_loop.scp
Endif>
Let>ME=%Script%

Running: 15.0.24
version history

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

Re: Compiled or script (variable wanted)

Post by JRL » Sun Feb 02, 2020 6:25 am

Looks to me like your scripts would be less complicated if you simply used the "Extract" functions.

Code: Select all

ExtractFileName>command_line,startedBy
MDL>startedBy

ExtractFilePath>script_dir,runningFromParent
mdl>runningFromParent

User avatar
Grovkillen
Automation Wizard
Posts: 998
Joined: Fri Aug 10, 2012 2:38 pm
Location: Bräcke, Sweden
Contact:

Re: Compiled or script (variable wanted)

Post by Grovkillen » Sun Feb 02, 2020 6:37 am

Yes, much better! 👊 Thanks
Let>ME=%Script%

Running: 15.0.24
version history

User avatar
Grovkillen
Automation Wizard
Posts: 998
Joined: Fri Aug 10, 2012 2:38 pm
Location: Bräcke, Sweden
Contact:

Re: Compiled or script (variable wanted)

Post by Grovkillen » Sun Feb 02, 2020 6:48 am

JRL wrote:
Sun Feb 02, 2020 6:25 am

Code: Select all

ExtractFileName>command_line,startedBy
MDL>startedBy
That one didn't work because of the quotes. So a RegEx is first needed.
Let>ME=%Script%

Running: 15.0.24
version history

User avatar
Grovkillen
Automation Wizard
Posts: 998
Joined: Fri Aug 10, 2012 2:38 pm
Location: Bräcke, Sweden
Contact:

Re: Compiled or script (variable wanted)

Post by Grovkillen » Sun Feb 02, 2020 6:53 am

So it boiled down to this:

Code: Select all

Let>REGEX_PATTERN=(?<=").*?(?=")
RegEx>REGEX_PATTERN,COMMAND_LINE,0,SCRIPT_DIR_EXE,,,,
ExtractFileName>SCRIPT_DIR_EXE_1,RUNNED_EXE
If>RUNNED_EXE=msched.exe
  //Running in dev mode
  ExtractFilePath>SCRIPT_DIR,SCRIPT_IMPORTS
  Include>%SCRIPT_IMPORTS%\script_imports\lib_get_root_path.scp
  Include>%SCRIPT_IMPORTS%\script_imports\dialog_monitor.scp
  Include>%SCRIPT_IMPORTS%\script_imports\standard_loop.scp
Else>
  //Running as compiled
  Include>%SCRIPT_DIR%\script_imports\lib_get_root_path.scp
  Include>%SCRIPT_DIR%\script_imports\dialog_monitor.scp
  Include>%SCRIPT_DIR%\script_imports\standard_loop.scp
Endif>
Let>ME=%Script%

Running: 15.0.24
version history

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

Re: Compiled or script (variable wanted)

Post by JRL » Sun Feb 02, 2020 7:39 am

Sorry, I didn't read to the bottom of your script to see that you were using the msched.exe.

You could boil it down by one more line by using StringReplace or by making the regex all one line.

Code: Select all

//StringReplace>COMMAND_LINE," ,,SCRIPT_DIR_EXE
//Or
//RegEx>(?<=").*?(?="),COMMAND_LINE,0,SCRIPT_DIR_EXE,,,,

/////To replace these two lines///////
Let>REGEX_PATTERN=(?<=").*?(?=")
RegEx>REGEX_PATTERN,COMMAND_LINE,0,SCRIPT_DIR_EXE,,,,
//////////////////////////////////
ExtractFileName>SCRIPT_DIR_EXE,RUNNED_EXE
If>RUNNED_EXE=msched.exe
  //Running in dev mode
  ExtractFilePath>SCRIPT_DIR,SCRIPT_IMPORTS
  Include>%SCRIPT_IMPORTS%\script_imports\lib_get_root_path.scp
  Include>%SCRIPT_IMPORTS%\script_imports\dialog_monitor.scp
  Include>%SCRIPT_IMPORTS%\script_imports\standard_loop.scp
Else>
  //Running as compiled
  Include>%SCRIPT_DIR%\script_imports\lib_get_root_path.scp
  Include>%SCRIPT_DIR%\script_imports\dialog_monitor.scp
  Include>%SCRIPT_DIR%\script_imports\standard_loop.scp
Endif>

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