DADiSP Worksheet Functions > Function Categories > Operating System Interface > SHELLEXECUTE

 

SHELLEXECUTE

Purpose:

Runs an external program or processes a file using the OS shell.

Syntax:

SHELLEXECUTE(

"verb", "filename", "params", "dir", modal, showmode, bgtime)

"verb"

-

Optional. A string, the application "verb". Defaults to "", the default verb associated with "filename". Common application verbs include:

"open"

:

Opens the file specified. The file can be an executable file, a document file, or a folder.

"edit"

:

Launches an editor and opens the document for editing. If "filename" is not a document file, the function will fail.

"print"

:

Prints the document file specified. If "filename" is not a document file, the function will fail.

"properties"

:

Displays the file or folder's properties.

"filename"

-

A string, the file to process or the name of the program or executable to run.

"params"

-

Optional. A string, the parameters for the program to run. Defaults to "", no parameters.

"dir"

-

Optional. A string, the working directory. Defaults to the current directory.

modal

-

Optional. An integer specifying the parent of the process:

0:

No parent, the process is independent of DADiSP.

1:

DADiSP is the parent, the process terminates if DADiSP terminates (default).

showmode

-

Optional. An integer specifying the display mode of the application to run.

0:

hidden

1:

normal (default)

2:

minimized

3:

maximized

bgtime

-

Optional. An integer specifying the background monitor time in milliseconds. If specified, the executing program is queried every bgtime milliseconds to determine if it is still running.  Ctrl-Break can be used to terminate monitoring of the task. Defaults to 0, no background task monitoring.

Example:

shellexecute("open", "readme.txt", "", gethome)

 

opens the text file "readme.txt" in the home directory using the system default editor (typically Notepad).

Example:

shellexecute("print", "readme.txt", "", gethome)

 

prints the text file "readme.txt" in the home directory using the system default editor (typically Notepad).

Example:

shellexecute("open", gethome + "data\kasha.jpg")

 

opens the file "kasha.jpg" using the system default image viewer.

Example:

shellexecute("open", gethome + "data\kasha.jpg", 1, 3)

 

same as above except the image is displayed full screen.

Example:

shellexecute("open", which("dadisp.wav"))

 

opens the file "dadisp.wav" using the system default audio player (typically MediaPlayer).

Remarks:

An error value is returned if the program cannot be executed.

 

If a file is specified, SHELLEXECUTE attempts to load the appropriate application to display the file.

 

If bgtime is specified, the executing task is queried every bgtime milliseconds to determine the task state. In this case, task monitoring can be terminated by pressing Ctrl-Break.

 

See RUN to execute a program and wait until it has completed.

See Also:

DOS, VMS or UNIX macro

RUN

SHELL

VIEWFILE

VIEWHTML