Page 1 of 1

Relative Path for Execute

PostPosted: Tue Aug 03, 2021 8:02 pm
by John Holt
I am attempting to get a local html page opened from within an Edit Controls Button and I am getting very confused with path maps.

"os.execute ("start ../galleries/gallery.html" )" using this code in execute opens up the gallery.html as long as it is in C:\Program Files\Blackmagic Design\galleries.

However I am looking to use the Comps: path so I am able to place the galleries folder in #:\Documents\Blackmagic Design\Fusion. I wish to use the Comps: so it will open on another computer. I have read through the pathMap posts but unfortunately can not find my answer. Any help would be appreciated.

"os.execute ("start ../Comps:galleries/gallery.html" )" Doesn't work, I know I am getting the syntax wrong. the correct one would blow me away. TIA

Re: Relative Path for Execute

PostPosted: Tue Aug 03, 2021 8:44 pm
by Bryan Ray
You don't need the leading "../".
Comps: points to the UserData folder, so this should work:

"os.execute ("start Comps:galleries/gallery.html")"

Capture.JPG
Capture.JPG (31.27 KiB) Viewed 2041 times

Re: Relative Path for Execute

PostPosted: Tue Aug 03, 2021 9:50 pm
by John Holt
Hi

Spot on with that answer thanks, although I now have another issue. So it looks like I will have to stick with placing it in the program folder which isn't ideal.

My new issue is it won't launch the default browser. I think I will have to sleep on it.

Your help is greatly appreciated.

Re: Relative Path for Execute

PostPosted: Wed Aug 04, 2021 4:48 am
by Peter Loveday
Have you tried:
Code: Select all
bmd.openurl("file://" .. comp:MapPath("Comps:galleries/gallery.html"))

Re: Relative Path for Execute

PostPosted: Wed Aug 04, 2021 6:06 am
by John Holt
Hello

Peter you are amazing, where do I send the check.

bmd.openurl("file://" .. comp:MapPath("Comps:galleries/gallery.html"))

Worked a charm.

Whilst I think about it how could I open a pdf at the same location. I tried

bmd.openfileexternal('Open', .. comp:MapPath("Comps:pdf.pdf")) obviously I again have the syntax incorrect.

TIA

Re: Relative Path for Execute

PostPosted: Wed Aug 04, 2021 3:43 pm
by Bryan Ray
The .. operator is used for joining strings together. It's present in Peter's example because it's combining the two strings "file://" and the result of MapPath(). You're not trying to join the two arguments of openfileexternal() that way—that would be nonsensical, so you'll get an error from not having a string segment before that operator.

I recommend keeping Programming in Lua handy. I have a hardcopy of the book on my desk at all times, but the first edition is available for free on the web:
https://www.lua.org/pil/contents.html#3

Section 3.4 deals with the string concatenation operator.

edit: Also, hi Peter! Good to see you in here!

Re: Relative Path for Execute

PostPosted: Wed Aug 04, 2021 5:56 pm
by John Holt
Hello

Thank you, I also have a hard copy of Programming in Lua 4th edition & the reference manual but as yet the penny hasn't dropped. I shall re-read Section 3.4 then the rest of the book again.

Appreciate your help, I'll get there.