System Class
This class represents underlying system.
Item Index
Methods
Methods
copyFile
source
destination
[overwrite=false]
Copy source file to destination. If destination file exists and owerwrite is true function rewrites the file.
Parameters:
Returns:
Example:
System.copyFile("dat://source.txt", "dat://destination.txt");
createDir
dir
[createSubDirs=false]
Creates directory
Parameters:
Returns:
Example:
var location = System.path(#USER_DOCUMENTS);
if (!System.isDir(location+"/newFolder"))
System.createDir(location+"/newFolder"); //create new folder in directory, where user's documents are saved usually
else;
// this folder alredy exists
deleteDir
dir
Delete directory / folder. Folder have to be empty.
Parameters:
-
dir
StringLocation of directory / folder to delete. If directory does not exist function returns false.
Returns:
Example:
var location = System.path(#USER_DOCUMENTS);
if (System.isDir(location+"/newFolder"))
System.deleteDir(location+"/newFolder"); //delete folder in directory, where user's documents are saved usually
else;
// this folder does not exists
deleteFile
file
Delete file.
Parameters:
-
file
StringLocation of file to delete. If file does not exist function returns false
Returns:
Example:
var location = System.path(#USER_DOCUMENTS);
if (System.isFile(location+"/userFile.txt"))
System.deleteFile(location+"/userFile.txt"); //delete file from directory, where user's documents are saved usually
else
// this file does not exists
exec
cmd
[args]
[dir]
This functions manages some system operations like mail or sms sending, calling, pictures taking etc.
Parameters:
-
cmd
ObjectUse module name (command line) or Available commands:
- "call-to"
- "mail-to" - send mail
- "sms-to"
- "take-image" - takes a photo using the camera
- "show-image" - show image in built-in image viewer
- "record-video" - record video; parameter file: is overwriten if exists, callback: function which accept maximum of one parameter (location of taken video)
- "play-video" - play video in default video player
- "open-url" - open url in web browser
-
[args]
String optionalCommand line arguments.
-
[dir]
String optionalorking directory.
Returns:
Example:
// "call-to"
System.exec ({
command: "call-to",
phone: "00421954444333";
});
//"mail-to"
System.exec ({
command: "mail-to",
to: "",
cc: "carbon copy",
bcc: "blind carbon copy",
subject: "mail subject",
body: "text of mail",
});
//"sms-to"
System.exec ({
command: "sms-to",
to: "00421954444333",
text: "message text",
});
//"take-image"
var callBack = function(file)
{
console<<file<<"\n"; // returns image location
}
System.exec({
command: "take-image",
file: "dat://image.jpg",
callback: callBack,
});
//"show-image"
System.exec({
command: "show-image",
file: "dat://image.jpg",
});
getFileSize
file
destination
[overwrite]
Returns size of file in bytes.
Parameters:
Returns:
Example:
var location = System.path(#USER_DOCUMENTS);
if (System.isFile(location+"/userFile.txt"))
console<<"File size: " << System.getFileSize(location+"/userFile.txt") << "B\n";
else
// this file does not exists
hideKeyboard
()
Hide system (build-in native) keyboard.
Example:
// system keyboad is not supported in emulator
if(System.IS_EMULATOR === false)
System.hideKeyboard();
home
() String
Function returns home of the current application.
Returns:
isDir
dir
Checks, if directory / folder (sets by parameter) exists.
Parameters:
-
dir
StringDirectory location to check.
Returns:
Example:
System.isDir("dat://folder/subfolder"); // returns true if subfolder exists
var location = System.path(#USER_DOCUMENTS);
if (!System.isDir(location+"/newFolder"))
System.createDir(location+"/newFolder"); //create new folder in directory, where user's documents are saved usually
else;
// this folder alredy exists
isFile
file
Checks, if file (sets by parameter) exists.
Parameters:
-
file
StringSPath to file to check existance
Returns:
Example:
System.isFile("dat://folder/a.txt"); // returns true if file exists
var location = System.path(#USER_DOCUMENTS);
if (System.isFile(location+"/userFile.txt"))
System.deleteFile(location+"/userFile.txt"); //delete file from directory, where user's documents are saved usually
else;
// this file does not exists
messageBox
fmessage
Displays a modal dialog box that contains text and OK button.
Parameters:
-
fmessage
StringText to be displayed in the dialog box
Returns:
Example:
var location = System.path(#USER_DOCUMENTS);
if (System.isFile(location+"/userFile.txt"))
console<<"File size: " << System.getFileSize(location+"/userFile.txt") << "B\n";
else
System.messageBox("this file does not exists");
path
folder
Creates path to the required folder. F.e.: folder with user documents, program files etc. This folders can be placed diferents on diferent platforms.
Parameters:
-
folder
SymbolSpecification of folder
- #SYSTEM
- #SYSTEM_BIN
- #PROGRAM_FILES
- #USER_APPDATA
- #USER_HOME
- #COMMON_APPDATA
- #USER_DOCUMENTS
- #COMMON_DOCUMENTS
Returns:
Example:
// get location of “my documents” folder
var location = System.path(#USER_DOCUMENTS);
if (System.isFile(location+"/userFile.txt"))
System.deleteFile(location+"/userFile.txt"); //delete file from directory, where user's documents are saved usually
else;
// this file does not exists
requestKeyboard
callback
keyboardType
Displays system (build-in native) keyboard.
Parameters:
-
callback
FunctionCallback function.
-
keyboardType
Symbol- #default
- #web
- #pin
- #phone
Returns:
Example:
function processKey(sender, key)
{
console << "key on keyboard: " << key << "\n";
}
if (!System.requestKeyboard(processKey, #default)) {
// use software keyboard
// swKeyboard = new Keyboard();
swKeyboard.visible = false;
}
resetApplicationData
() Boolean
Resets application's data. (Android only).
Returns:
scanFiles
path
[ef]
This function tries to find all files in required format at specified location.
Parameters:
-
path
StringFolder, inside which we want to search and also format of required files f.e.: "dat://folder/*.txt".
-
[ef]
Function optionalFunction, which is called for each found file. This function should accept two parameters (name of file and file flag) and returns true for continue searching or false for stop searching.
Returns:
Example:
function manage(name, flag)
{
console<<"file name: "<<name<<" flag: "<<flag<<"\n"; // displays information about file
return true; // search for another file (return false for stop searching)
}
System.scanFiles("dat://folder/*.txt", manage); //search for txt files in dat://folder/ returns number of files
Properties
language
String
Returns the abbreviated name of the language, ISO Standard 639 names. List of ISO 639-1 code is available here: http://en.wikipedia.org/wiki/ListofISO639-1codes
OS_NAME
String final
Gets the device's operating system. Following symbols can be returned:
- #Windows
- #Mac
- #linux
- #iOS
- #Android
- #bada* #Symbian