Machsupport Forum

Mach Discussion => Mach4 General Discussion => Topic started by: gorf23 on April 02, 2019, 10:16:06 PM

Title: os.execute pdf
Post by: gorf23 on April 02, 2019, 10:16:06 PM
is there a way to run a pdf file from a button?

Tried os.execute but can't seem to get that to work.

Thanks gary
Title: Re: os.execute pdf
Post by: Chaoticone on April 03, 2019, 08:51:31 AM
Code: [Select]
local major, minor = wx.wxGetOsVersion()
    local dir = mc.mcCntlGetMachDir(inst);
    local cmd = "explorer.exe /open," .. dir .. "\\Docs\\MyDoc.pdf"
    if(minor <= 5) then -- Xp we don't need the /open
        cmd = "explorer.exe ," .. dir .. "\\Docs\\MyDoc.pdf"
    end
    wx.wxExecute(cmd)
Title: Re: os.execute pdf
Post by: gorf23 on April 03, 2019, 11:43:52 AM
Yes I tried that also but couldn't run that from a button... there was some sort of restriction couldn't be run from ? forgot the message..

I did get the os.execute to work turns out windows firewall was blocking it from running,,

thanks gary
Title: Re: os.execute pdf
Post by: bryannab on April 03, 2019, 01:21:42 PM
Hello Gary,

Create a function in the screenload script with the script provided in Chaoticone's comment. Then, use a button to call the function.

It is also worth mentioning that the path included in that script requires your document to be in the Docs subfolder in your Mach4 directory.

-B
Title: Re: os.execute pdf
Post by: gorf23 on April 03, 2019, 01:52:42 PM
ok thanks will try that i was using it in the button script itself will put in the screen load script.
Also i do already have the file in the docs folder..

Thanks Gary