Syntax

stat = SYSTEM('<executable_program>')

Arguments

stat: integer

executable_program: text

Meaning

The text executable program is passed as command line to the operating system, e.g. to start an external program and then go back to the ADAPL program. If the command is successfully carried out, the result in stat will be 0. Any other value signifies an error.

You can use system also to execute internal system commands, to manipulate files and directories like you would under DOS. You can always do this by calling cmd.exe (part of your operating system), and pass the internal command and options as arguments in the following syntax:

stat = SYSTEM('cmd /c <intcmd> <file_or_dir>')

(Parameters between < and > must be replaced by an actual value. Use single quotes.) If a file name contain spaces, the entire file name must be enclosed by double quotes. You can use local, relative or UNC paths. For a complete description of this cmd.exe function, type help in a (DOS) command window, or type help <function name>.
The problem with cmd.exe though, is that stat won't contain the result code of the internal command (which you really want to know) but the result code of cmd.exe instead. So when you were to rename a non-existing file this way, resulting in a system error, then stat would still contain 0 because cdm.exe was executed alright.

Some internal system commands that you can use without calling cmd.exe are:

ATTRIB

CHDIR

XCOPY

ERASE

MKDIR

RENAME

RMDIR

CD (change directory)

 

For these selected commands, the syntax becomes:

stat = SYSTEM('<intcmd> <file_or_dir>')

The advantage being that stat will result in the error code of the internal command, as desired.
Note that you cannot use variables or tags as arguments for the internal command, but you can use a variable as the argument for SYSTEM. So if you want to use variable file names (maybe coming from a field), you'll have to build up the entire SYSTEM argument string in a variable and pass the variable to SYSTEM, like so for example:

argumentstringvar = 'rename ' + pathplusfilename1var + ~
                   ' ' + filename2var
resultvar = system(argumentstringvar)

NB: With the SYSTEM function, a program can be started that disrupts execution of Collections or ADAPL - with unpredictable results.

Example 1

stat = SYSTEM('adlwin')

Result

stat gets the value 0 if adlwin.exe has successfully been started from the current folder, and otherwise an error code from the operating system.

Example 2

stat = SYSTEM('del log.txt')

Result

stat gets the value 0 if the file log.txt has been removed successfully, and otherwise an error code from the operating system.