Compile includes aren't working with dynamic path

Technical support and scripting issues

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:

Compile includes aren't working with dynamic path

Post by Grovkillen » Wed May 12, 2021 9:59 am

See this example and you will only have the second "HELLO" working if you compile it as an exe.

If you open it in the same directory as the "test_1.scp" you will get an error. Opening it in a separate (otherwise empty) directory and you only get the second "HELLO".

test_main.scp (compiled as exe with the option "compile includes" selected):

Code: Select all

Let>TEST_DIR=%SCRIPT_DIR%
Include>%TEST_DIR%\test_1.scp
Include>%SCRIPT_DIR%\test_2.scp
test_1.scp:

Code: Select all

MDL>HELLO 1!
test_2.scp:

Code: Select all

MDL>HELLO 2!
My guess is that the compiler isn't parsing through the code to see what value the variable got once reaching the includes command but instead treat it as a string if it's anything other than explicitly declared %SCRIPT_DIR% or any other system variable.

I hope this can be resolved since I'm relying on having the import path dynamically to fetch the includes from different path's for different projects.
Let>ME=%Script%

Running: 15.0.24
version history

User avatar
Dorian (MJT support)
Automation Wizard
Posts: 1347
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Re: Compile includes aren't working with dynamic path

Post by Dorian (MJT support) » Thu May 13, 2021 8:49 am

Have passed this on.
Yes, we have a Custom Scripting Service. Message me or go here

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

Re: Compile includes aren't working with dynamic path

Post by Grovkillen » Thu May 13, 2021 7:09 pm

I wouldn't mind if I need to declare a variable from within the compiler settings. Kinda like how we add the output exe file and icon. If this is easier to do. But in any case the compile includes need to be documented since I didn't get any warnings or script errors.
Let>ME=%Script%

Running: 15.0.24
version history

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

Re: Compile includes aren't working with dynamic path

Post by Marcus Tettmar » Fri May 14, 2021 12:34 pm

Note:

https://www.mjtnet.com/manuals/v15/HTML/create-exe.html

Compile Includes: "Scripts referenced by Include> statements will be embedded and compiled into the Exe. Will not work where Include> references scripts via variables other than SCRIPT_DIR."
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
Grovkillen
Automation Wizard
Posts: 998
Joined: Fri Aug 10, 2012 2:38 pm
Location: Bräcke, Sweden
Contact:

Re: Compile includes aren't working with dynamic path

Post by Grovkillen » Fri May 14, 2021 12:59 pm

Aha, got it. I will make a build script that will temporarily replace those lines.

Perhaps it should be noted in the help for "include" as well?
Let>ME=%Script%

Running: 15.0.24
version history

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