Oxygen 2 Misc Documentation: Difference between revisions
Lou Montana (talk | contribs) (File Commands merge) |
Lou Montana (talk | contribs) m (Text replacement - "{{HashLink" to "{{Link") |
||
(2 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
{{TOC|side}} | |||
This page is a list of found [[Oxygen 2]] avilable commands and behaviours. | |||
== if then else == | == O2 Script == | ||
=== if then else === | |||
if (something == 1) then {fred=1;}else{fred=2;}; | if (something == 1) then {fred=1;}else{fred=2;}; | ||
== functions == | === functions === | ||
_SomeFunc= | _SomeFunc= | ||
Line 20: | Line 23: | ||
if (_in== 1) then {1}else{2}; // achieves same | if (_in== 1) then {1}else{2}; // achieves same | ||
}; | }; | ||
== comment == | |||
=== comment === | |||
comment "comment" | comment "comment" | ||
Line 29: | Line 33: | ||
// comments | // comments | ||
== messageBox [text,nButtons] == | === messageBox [text,nButtons] === | ||
Returns ID of pressed button | Returns ID of pressed button | ||
Line 39: | Line 43: | ||
nButtons 0: == OK only | nButtons 0: == OK only | ||
=== isnil === | |||
== isnil == | |||
example: | example: | ||
Line 51: | Line 54: | ||
=== nil === | |||
== nil == | |||
example: | example: | ||
Line 63: | Line 65: | ||
= File Commands = | == File Commands == | ||
=== GetCD === | |||
See {{Link|#SetCD}} below. | |||
=== SetCD === | |||
== SetCD == | |||
_folder=GetCD; // returns fully qualified (P:\etc) | _folder=GetCD; // returns fully qualified (P:\etc) | ||
_SetCD(folder); | _SetCD(folder); | ||
=== openStandardIO === | |||
== openStandardIO == | |||
Opens stream for standard input and output. If no standard I/O is assigned, creates console, and redirect I/O into console. Note: Always assign result to variable, and access stream with variable. | Opens stream for standard input and output. If no standard I/O is assigned, creates console, and redirect I/O into console. Note: Always assign result to variable, and access stream with variable. | ||
Line 86: | Line 85: | ||
console=nil; close it | console=nil; close it | ||
=== openFile ["filename",mode] === | |||
== openFile ["filename",mode] == | |||
*Returns IOStream | *Returns IOStream | ||
Line 105: | Line 103: | ||
_file will be non nil for mode 0 | _file will be non nil for mode 0 | ||
=== shellCmd "command" === | |||
== shellCmd "command" == | |||
Retursn: Result (number) | Retursn: Result (number) | ||
Line 117: | Line 114: | ||
_result = shellCmd ("notepad.exe"); | _result = shellCmd ("notepad.exe"); | ||
=== shellCmdOpenPipe "command" === | |||
== shellCmdOpenPipe "command" == | |||
Returns IOStream | Returns IOStream | ||
Line 134: | Line 130: | ||
_files=nil; | _files=nil; | ||
=== SplitPath "Path" === | |||
== SplitPath "Path" == | |||
Returns the Path string into a 4 element array | Returns the Path string into a 4 element array |
Latest revision as of 17:43, 4 January 2023
This page is a list of found Oxygen 2 avilable commands and behaviours.
O2 Script
if then else
if (something == 1) then {fred=1;}else{fred=2;};
functions
_SomeFunc= { private ["_in","_out"]; _in=_this@0; if (_in== 1) then {_out=1;}else{_out=2;}; out // lack of semi colon returns content of out equally if (_in== 1) then {1}else{2}; // achieves same };
comment
comment "comment" /* comments
- /
// comments
messageBox [text,nButtons]
Returns ID of pressed button
Shows message box with text and buttons.
nButtons is undocumented but probably follows the msoft conventions of ok, cancel, blah, + warning icons
nButtons 0: == OK only
isnil
example:
if (isnil "_exists") ExitWith(_file_exists=false;};
if (!isnil "_exists") ExitWith(_file_exists=true;};
note that exitwith is pretty close to useless it ONLY breaks out of the current braces, not, out of a subroutine per se
nil
example:
_dirs= shellCmdOpenPipe(".... { process... } _dirs=nil;
File Commands
GetCD
See SetCD below.
SetCD
_folder=GetCD; // returns fully qualified (P:\etc) _SetCD(folder);
openStandardIO
Opens stream for standard input and output. If no standard I/O is assigned, creates console, and redirect I/O into console. Note: Always assign result to variable, and access stream with variable.
Example:
console=openStandardIO; console<<"Hallo world"
console=nil; close it
openFile ["filename",mode]
- Returns IOStream
Opens or creates a file specified by filename. Mode contain one of following values:
- 0 - test existence of file (no open)
- 1 - open existing file for reading
- 2 - create new file for writting
- 3 - open existing file for reading and writting
- 4 - open (create if not exists) file for reading and writting
Example:
_file=openFile ["some\file\anywhere.ext",0]; if (!isnil("_file")) then {do_something;_file=nil;};
Note: _file will be non nil for mode 0
shellCmd "command"
Retursn: Result (number)
Function waits until command is finished
result is -1 if file not found, or cannot be started, otherwise returns application's exit code
Example:
_result = shellCmd ("notepad.exe");
shellCmdOpenPipe "command"
Returns IOStream
Creates bi-directional pipe to the new process. Script can use this pipe to send commands to child process and read its results
Example:
_files=shellCmdOpenPipe ("dir /b/a:-d-h/L *.p3d"); list only p3d files in lower case, no hidden stuff while "!eof _files" do { _filename= getline _files; if (_filename!="") then {[_filename] call something;}; }; _files=nil;
SplitPath "Path"
Returns the Path string into a 4 element array
[drive,folders,filename,extension]
Example:
splitPath "C:\test\anywhere\anyFile.txt" , result is ["c:","\test\anywhere","anyFile",".txt"]
this command does not work as nature intended
the drive is force-set to current drive
the folder path is determined by current directory
a lack of preceding slash adds it. any drive specification in the string (such as proxy:) is treated as folder path (part of)