It is currently Sun Nov 19, 2017 7:08 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject: Mac OS Equivalence for RunProgram("Notepad.exe .....
PostPosted: Mon Mar 20, 2017 6:39 pm 
Offline
User
User

Joined: Sat Aug 11, 2007 6:16 pm
Posts: 33
Location: Frisco, US
Brand new to Mac OS, and trying to port an existing PB program to it. Having syntactical trouble getting TextEdit.app to just open my pre-generated text file and sit there so the user can look at it and maybe close it it he wants to and continue on with the PB app.

In my PC version the code
Code:
RunProgram("notepad.exe", path$ + "\" + filename$,"C:\WINDOWS\system32")
worked fine.

I've spent an embarrassing amount of time searching and trying get Mac OS equivalent behavior without success. Is someone could post a workable line, I'd really appreciate it. Thank you.


Top
 Profile  
Reply with quote  
 Post subject: Re: Mac OS Equivalence for RunProgram("Notepad.exe .....
PostPosted: Mon Mar 20, 2017 7:22 pm 
Offline
User
User

Joined: Sat Aug 11, 2007 6:16 pm
Posts: 33
Location: Frisco, US
While we are at it, I need to do the same thing with a .pdf file. Both .txt and .pdfs preview easily in Finder. Hopefully this is also a runprogram solution?


Top
 Profile  
Reply with quote  
 Post subject: Re: Mac OS Equivalence for RunProgram("Notepad.exe .....
PostPosted: Mon Mar 20, 2017 8:10 pm 
Offline
User
User

Joined: Sat Aug 11, 2007 6:16 pm
Posts: 33
Location: Frisco, US
I guess the "Simple PDF Viewer" topic begs to differ.


Top
 Profile  
Reply with quote  
 Post subject: Re: Mac OS Equivalence for RunProgram("Notepad.exe .....
PostPosted: Mon Mar 20, 2017 8:32 pm 
Offline
Enthusiast
Enthusiast

Joined: Thu Apr 14, 2011 6:07 pm
Posts: 313
Hi,

You can try this (it used to work fine for me, been a while since i have not used Mac), once the file is given the adequate extension:

Code:
                curDir = GetCurrentDirectory()
                SetCurrentDirectory("/")
                RunProgram("open", Chr(34) + fileName + Chr(34),"")
                SetCurrentDirectory(curDir)


Top
 Profile  
Reply with quote  
 Post subject: Re: Mac OS Equivalence for RunProgram("Notepad.exe .....
PostPosted: Mon Mar 20, 2017 9:09 pm 
Offline
User
User

Joined: Sat Aug 11, 2007 6:16 pm
Posts: 33
Location: Frisco, US
Thanks said but changing the directory seems needless and does not work.

I've come close with RunProgram("open",GetCurrentDirectory() + filename$,"") PROVIDED filename$ has no spaces in the name.

Thought I saw some kind of escaping about 200 screens back. Any suggestions would be appreciated.

The same is true if the target is a .pdf. Works great if no spaces in the name. How can I beat the space in the name problem?


Top
 Profile  
Reply with quote  
 Post subject: Re: Mac OS Equivalence for RunProgram("Notepad.exe .....
PostPosted: Mon Mar 20, 2017 9:52 pm 
Offline
Addict
Addict
User avatar

Joined: Thu Apr 21, 2005 2:38 pm
Posts: 1461
Location: Germany
The following command opens a text file in TextEdit (you have to substitute /PathToTextFile/TextFile with an actual path and text file name; the #DQUOTE constants allow you to use spaces in your folder names or file names; #DQUOTE$ displays a double quote character as also Chr(34) does):
Code:
RunProgram("Open", "/Applications/TextEdit.app " + #DQUOTE$ + "/PathToTextFile/TextFile" + #DQUOTE$, "")

To open a PDF file with your default PDF viewer (in my case Abobe Reader):
Code:
RunProgram("Open", #DQUOTE$ + "/PathToPDFFile/PDFFile" + #DQUOTE$, "")


Top
 Profile  
Reply with quote  
 Post subject: Re: Mac OS Equivalence for RunProgram("Notepad.exe .....
PostPosted: Tue Mar 21, 2017 1:17 am 
Offline
User
User

Joined: Sat Aug 11, 2007 6:16 pm
Posts: 33
Location: Frisco, US
That did the trick. In retrospect, Said was right about the Chr(34). You guys are awesome!

So for any noobs that come along, my working variant is:

Code:
RunProgram("open", Chr(34) + GetCurrentDirectory() + "my file.txt" + Chr(34),"")


The noob is curious though - this "open" syntax does not seem to conform to the F1 parameters for the RunProgram() command (filename$, Parameter$, WorkingDirectory$, Flags). So what is going on here?


Top
 Profile  
Reply with quote  
 Post subject: Re: Mac OS Equivalence for RunProgram("Notepad.exe .....
PostPosted: Tue Mar 21, 2017 1:47 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sun Feb 12, 2006 10:06 pm
Posts: 623
I've got zero experience with MacOS, but I'd imagine that "open" is a system command that behaves like an executable file...

_________________
there is no sig, only zuul (and the following disclaimer)

WARNING: may be talking out of his hat


Top
 Profile  
Reply with quote  
 Post subject: Re: Mac OS Equivalence for RunProgram("Notepad.exe .....
PostPosted: Tue Mar 21, 2017 10:17 pm 
Offline
Addict
Addict
User avatar

Joined: Thu Apr 21, 2005 2:38 pm
Posts: 1461
Location: Germany
PB2004 wrote:
The noob is curious though - this "open" syntax does not seem to conform to the F1 parameters for the RunProgram() command (filename$, Parameter$, WorkingDirectory$, Flags). So what is going on here?
citystate wrote:
I've got zero experience with MacOS, but I'd imagine that "open" is a system command that behaves like an executable file...

citystate's imagination is correct: open is a BSD system command located in /usr/bin.
You may take a look into Apple's documentation for this command or simply open a terminal and type
Code:
man open


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 15 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye