RUN executes a command line without capturing it's output, waits for command completion
SPAWN executes a command line without capturing it's output. Starts the command and continues execution in parallel
PIPETOSTR() executes a command line capturing and returning whatever it wrote to its standard output, waits for completion.
Bacticks can be used inside character strings to capture the output and substitute into the character string
SHELLEXEC is a windows only and non portable WINAPI function call
Also note that you can execute a program via file association e.g. To open up PDF file.
Code:
Lianja.showDocument("myfile.pdf")
When including the full path to a file please include "file:///". For example:
Code:
showdocument("file:///f:\staff\sherlie\book2.xlsx")
One way is to use the RUN command:
Code:
WSHShell = CreateObject("WScript.Shell")
eExe = WSHShell.RegRead("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\AcroRd32.exe\")
if type("eExe") = "C"
? "Key exists: " + eExe
else
? "Key not found"
endif
RELEASE WSHShell
Is it actually a specific file you need to open? Is it a scenario where you could create a temporary file (TMPNAM() will give you a temporary file name in the temporary files directory) so that multiple users aren't trying to access the same file?
If it's the CSV report files we are talking here and the CSV is already open in Excel, the fopen() will return a filehandle of -1, ferror() will return -1, errno() will return 13 and strerror(errno()) will return 'Permission denied'. That doesn't tell you who has the file open, or whether the 'Permission denied' is due to another cause.
Q:
What would be good way to run an executable? Ping. Pipe (Linux)
A:
From the Linux desktop you could use ! and output to a file, then handle the file e.g.
Code:
!ping -c 5 192.168.3.3 > /home/yvonne/ping.txt
type /home/yvonne/ping.txt
When creating a new window that runs an App the --args "arg" that you specify is in the same format as Lianja.showDocument() NOT args to a script.
So for example to load the "customerorders" app and lookup the customerid.
Code:
Lianja.spawnApp("c:\lianja\bin\lianjaruntime --app mysalesapp --args "page:customers?action=search&text=1220")
Excel file formats are different between older and newer releases and I am unsure what version of excel you are using so you need to research the ODBC driver that matches the version you use.
Be aware that excel is not multiuser either so you need to bear this in mind if you are building a multiuser application that interacts with an excel spreadsheet.
Q:
Is it possible to call a Windows command-line application from within a Lianja App?
A:
Code:
Lianja.run("path_to_exe","arg1,arg2...")
or
Code:
Lianja.spawn("path_to_exe","arg1,arg2...")
Q:
The reason I ask is that I can call a prg with it and get no error; but there is also no evidence that the prg is running. Executing
Code:
? lianja.spawnapp("testspawn.prg")
A:
In fact I stand corrected, my code will run .prg, .php, .py. .js and app files.
You may need to set the path of the filename if its not an App.
Code:
result = Lianja.spawnApp(filename | appname, [username, [password, [args] ] ])
if result
// process is running
endif
Lianja.showDocument() has some interesting functionality that is not well known.
You can invoke the desktop browser,
run external applications,
run other apps (in a new runtime container)
and also run Lianja/VFP scripts (in a new runtime container).
Lianja.showDocument() handles desktop associations. e.g..
Code:
Lianja.showDocument("http://www.google.com")
Lianja.showDocument("myspreadsheet.xlsx")
Lianja.showDocument("myspecialapp.exe")
Lianja.showDocument("lianja --app myapp --username myusername --password mypassword")
Lianja.showDocument("lianja myform.prg")
All topics in [Answers] alphabetically: http://www.lianja.com/community/show...ll=1#post12352
Bookmarks