System Functions
In this chapter we are going to learn about the system functions
- System()
- Get()
- IsMSDOS()
- IsWindows()
- IsWindows64()
- IsUnix()
- IsMacOSX()
- IsLinux()
- IsFreeBSD()
- IsAndroid()
- Windowsnl()
- Get Command Line Arguments
- Get Active Source File Name
System() Function
We can execute system commands using the system() function
Syntax:
	System(cCommand)Example:
	System("myapp.exe") 	# Run myapp.exe
	System("ls")		# print list of filesGet() Function
We can get environment variables using the Get() function
Syntax:
	Get(cVariable)Example:
	see get("path")		# print system path information
IsMSDOS()
We can check if the operating system is MSDOS or not using the IsMSDOS() function
Syntax:
	IsMSDOS() ---> Returns 1 if the operating system is MS-DOS, Returns 0 if it's notIsWindows()
We can check if the operating system is Windows or not using the IsWindows() function
Syntax:
	IsWindows() ---> Returns 1 if the operating system is Windows, Returns 0 if it's not
IsWindows64()
We can check if the operating system is Windows 64bit or not using the IsWindows64() function
Syntax:
	IsWindows64() ---> Returns 1 if the operating system is Windows64, Returns 0 if it's not
IsUnix()
We can check if the operating system is Unix or not using the IsUnix() function
Syntax:
	IsUnix() ---> Returns 1 if the operating system is Unix, Returns 0 if it's not
IsMacOSX()
We can check if the operating system is Mac OS X or not using the IsMacOSX() function
Syntax:
	IsMacOSX() ---> Returns 1 if the operating system is Mac OS X, Returns 0 if it's not
IsLinux()
We can check if the operating system is Linux or not using the IsLinux() function
Syntax:
	IsLinux() ---> Returns 1 if the operating system is Linux, Returns 0 if it's not
IsFreeBSD()
We can check if the operating system is FreeBSD or not using the IsFreeBSD() function
Syntax:
	IsFreeBSD() ---> Returns 1 if the operating system is FreeBSD, Returns 0 if it's not
IsAndroid()
We can check if the operating system is Android or not using the IsAndroid() function
Syntax:
	IsAndroid() ---> Returns 1 if the operating system is Android, Returns 0 if it's notExample
	see "IsMSDOS() --> " + ismsdos() + nl
	see "IsWindows() --> " + iswindows() + nl
	see "IsWindows64() --> " + iswindows64() + nl
	see "IsUnix() --> " + isunix() + nl
	see "IsMacOSX() --> " + ismacosx() + nl
	see "IsLinux() --> " + islinux() + nl
	see "IsFreeBSD() --> " + isfreebsd() + nl
	see "IsAndroid() --> " + isandroid() + nlOutput:
	IsMSDOS() --> 0
	IsWindows() --> 1
	IsWindows64() --> 0
	IsUnix() --> 0
	IsMacOSX() --> 0
	IsLinux() --> 0
	IsFreeBSD() --> 0
	IsAndroid() --> 0Windowsnl()
We can get the windows new line string using the Windowsnl() function.
Syntax:
	WindowsNL() ---> Returns a string contains CR+LF = CHAR(13) + CHAR(10)Example:
	cStr = read("input.txt")if iswindows() cStr = substr(cStr,windowsnl(),nl) ok
aList = str2list(cStr) # to do - list items processing using "for in" cStr = list2str(aList)
if iswindows() cStr = substr(cStr,nl,windowsnl()) ok
write("ouput.txt",cStr)
Get Command Line Arguments
We can get the command line arguments passed to the ring script using the sysargv variable.
The sysargv variable is a list contains the command line parameters.
Example
	see copy("=",30) + nl
	see "Command Line Parameters" + nl
	see "Size : " + len(sysargv) + nl
	see sysargv
	see copy("=",30) + nl
	nStart = sysargv[3]
	nEnd = sysargv[4]
	for x = nStart to nEnd
		see x + nl
	nextOutput
	b:\mahmoud\apps\ring>ring tests\syspara.ring 1 10
	==============================
	Command Line Parameters
	Size : 4
	ring
	tests\syspara.ring
	1
	10
	==============================
	1
	2
	3
	4
	5
	6
	7
	8
	9
	10Get Active Source File Name
We can get the active source file name (*.ring) using the filename() function
Syntax:
	filename() ---> String contains the active source file name.Example:
	see "Active Source File Name : " + filename() + nlOutput:
	Active Source File Name : tests\filename.ring
Example:
	if sysargv[2] = filename()
		see "I'm the main program file!" + nl
		# we can run tests here!
	else
		see "I'm a sub file in a program" + nl
	ok