<<

Constants

Constants are global variables that contain system information -- such as os or screen dimensions -- that is sometimes advantageous to know at run time.


FILE_SEP

The file separator that a system uses. On Windows this will be \ and on Linux and Mac it will be /.

Type: String

Example:

print("This system uses '" + FILE_SEP + "' as a file separator.");

Output:

This system uses '/' as a file separator.

SCREEN_HEIGHT

The height of the screen measured in pixels. Note that with multiple screens this may only apply to the main monitor.

Type: int

Example:

print("This screen is " + SCREEN_HEIGHT + "px tall.");

Output:

This screen is 768px tall.

SCREEN_WIDTH

The width of the screen measured in pixels. Note that with multiple screens this may only apply to the main monitor.

Type: int

Example:

print("This screen is " + SCREEN_WIDTH + "px wide.");

Output:

This screen is 1366px wide.

SYSTEM_OS

The operating system in use.

Type: String

Example:

print("Running OS: " + SYSTEM_OS);

Output:

Running OS: Linux

USER_HOME_DIR

The path to the user's home directory.

Type: String

Example:

print("User's home directory: " + USER_HOME_DIR);

Output:

User's home directory: /home/john

Note that on *nix systems running this as root, even when logged in as a different user, will yield a different result.

If you run your program with sudo the output will look like this:

User's home directory: /root

TEMP_DIR

The path to the temporary directory on the system.

Type: String

Example:

print("Temp directory: " + TEMP_DIR);

Output:

Temp directory: /tmp

USER_NAME

The current user's user name.

Type: String

Example:

print("User name: " + USER_NAME);

Output:

User name: john

Note that on *nix systems running this as root, even when logged in as a different user, will yield a different result.

If you run your program with sudo the output will look like this:

User name: root

WORKING_DIR

The directory the program is being run from.

Type: String

Example:

print("This is being run from " + WORKING_DIR);

Output:

This is being run from /home/john/javauto/