Tutorial by Examples

Executes a OS-command. OS-COMMAND without any options will start a new shell and not exit it - thus you will on graphical OS:es leave a window "hanging". DEFINE VARIABLE cmd AS CHARACTER NO-UNDO. cmd = "dir". OS-COMMAND VALUE(cmd). There are three options: SILENT, NO...
The OPSYS-function returns what OS the program is running on: MESSAGE OPSYS VIEW-AS ALERT-BOX. Result: It can be used to select what OS-utility to call: IF OPSYS = "LINUX" THEN OS-COMMAND VALUE("ls -l"). ELSE OS-COMMAND VALUE("dir").
Returns an error from a previous OS-* call represented by an integer. The calls that can return an OS-ERROR are: OS-APPEND OS-COPY OS-CREATE-DIR OS-DELETE OS-RENAME SAVE CACHE Note that OS-COMMAND is missing. You need to handle errors in OS-COMMAND yourself. Error numberDescription0No er...
Returns the value of any OS environment variable. MESSAGE OS-GETENV ("OS") VIEW-AS ALERT-BOX. On a Windows machine: MESSAGE OS-GETENV ("SHELL") VIEW-AS ALERT-BOX. Result on a Linux machine with Bash as current shell: ┌────── Message ───────┐ ...
Copy a file COPY source-file target-file Copy c:\temp\source-file.txt to c:\temp\target-file.txt. You need to check OS-ERROR for success or lack thereof. OS-COPY VALUE("c:\temp\source-file.txt") VALUE("c:\temp\target-file.txt"). IF OS-ERROR <> 0 THEN DO: MESS...
Deletes a file, or a file-tree. As with many other OS-* utilities, you have to check status in OS-ERROR. OS-DELETE file-or-dir-to-delete [ RECURSIVE ] Delete the entire /tmp/dir tree: OS-DELETE VALUE("/tmp/dir") RECURSIVE. Delete the file called c:\dir\file.txt OS-DELETE VALUE...
Creates a directory, status is in OS-ERROR OS-CREATE-DIR directory Create a directory called /usr/local/appData OS-CREATE-DIR VALUE("/usr/local/appData").
Append one file to another. Status is checked in OS-ERROR OS-APPEND source target Appends targetfile.txt with sourcefile.txt: OS-APPEND VALUE("sourcefile.txt") VALUE("targetfile.txt").
Rename a file or directory. Status is in OS-ERROR. Can also be used to move files (or move and rename). OS-RENAME oldname newname Rename /tmp/old-name to /tmp/new-name: OS-RENAME VALUE("/tmp/old-name") VALUE("/tmp/new-name"). Move file c:\temp\old.txt to c:\new-dir\old....
Returns a list of all drives on a system. MESSAGE OS-DRIVES VIEW-AS ALERT-BOX. Result with four drives, C through F: On Linux the list will simply be empty as there by definitions are no "drives" connected. Listing directories is done in another way (INPUT FROM OS-DIR)

Page 1 of 1