Site Tools


dpp:docs_functions

D++ Functions

The following functions can all be used in any evaluated expression, or called via the call command. They can also be called on their own, starting with verion 4.0 and later. All arguments are evaluated, except when a variable is use as a parameter. You can also define your own function which can work the same way as these built-in functions. For more information on user functions, click here.

Back to D++ Documentation Index

String Manipulation

lcase (string)

Returns the the given string in all lower case.

ucase (string)

Returns the given string in all upper case.

trim (string)

Returns the given string with all preceding and trailing spaces removed.

isnumeric (string)

Tests if the given value is a number or not. Returns True or False.

isop (string)

Tests if the given string is an operator or not. Returns True or False. Operators that will return True are: +, -, *, /, \, &, >, <, =, ^, %.

int (value)

Returns the given value in integer format, i.e. no decimal. If a string is given, 0 is returned.

fileexist (file)

Determines if the given file exists. Returns True or False.

rndnum (max)

Generates a random number between 0 and the given maximum value. The number generated is an integer.

rnd (max)

Generates a random number between 0 and the gieven maximum value. The number generated is a double.

asc (character)

Returns the ASCII numerical value equivilant to the given character.

chr (value)

Returns the ASCII character equivilant to the given number.

hex (number)

Returns the given number in Hexadecimal.

len (string)

Returns the length of the given string.

val (string)

Returns the given value as a number. If the value is a string, 0 is returned.

string (character, length)

Returns a string of the given character printed the given amount of times. For example, calling string(“%”, 5) would return “%”.

right (string, length)

Returns the the right side of string for the given length.

left (string, length)

Returns the the left side of string for the given length.

instr (start, string, search_string)

Searches in the given string for a specified string starting at the specified start point. If the search string is found, it returns the location of the search string. Otherwise, 0 is returned.

mid (string, start [, length ] )

Returns a portion of the given string, starting from the given start point. If no length is specified, the end of the string is used.

File I/O

readfile (file)

Reads the given file and returns it's contents. Please note that while D++ does use the ReadFile API so that reading the file is done quickly, the contents of the file is stored in memory and using this function with larger files is not recommended.

f_open (file, mode)

Opens a file for reading or writing and returns the file specifier, which is needed to use other functions on the given file. Valid file modes include: “w” for writing, “a” for appending, “r” for reading, and “b” for binary. If the file does not exist, a run-time error will occure.

f_out (file id, text)

Prints text to the specified file. If the file mode for this file is “w”, then any current text is overwritten. If the file mode is “a”, the text is appended to the end of the file.

f_close (file id)

Closes the specified file. Note that it is recommended that ALL files are closed before exiting the program.

f_linein (file id)

Similar to Line Input, this function will read the current line of the specified file and return this data. Best used in a loop to read the file.

f_in (file id)

Reads data from the specified file and returns the data.

eof (file id)

Determines if the file pointer of the given file is at the end of the file. Returns True or False.

lof (file id)

Returns the length of the given file in bytes. A valid, open file ID must be specified.

filelen (file)

Returns the length of the given file in bytes. A file name must be specified.

Array Functions

isarray (variable)

Determines if the given variable is an array. If a valid variable isn't given, an error will occure. Returns True or False.

isempty (variable)

Determines if the given variable is empty. If it is a normal variable, the variable must contain nothing to be empty. If it is am array, it must be an undefined array having no elements (numElements = -1) to be empty.

ubound (variable)

Determines the upper bounds of a variable, i.e. the index of the last element. No lbound() function exists because D++ variables are always 0-based arrays.

split (string, delimiter, [max_elements])

Splits the specified string into an array based on the given delimiter. Must be used when assigning to an array. You can optionally include the maximum amount of elements to create - note that this is not a 0-based number. Exact same as VB's Split() function.

join (string, delimiter)

Splits the specified string into an array based on the given delimiter. Must be used when assigning to an array. You can optionally include the maximum amount of elements to create - note that this is not a 0-based number. Exact same as VB's Split() function.

Console Functions

These functions will only work when using normal console mode. Not compatible with DOS mode.

setstart (value)

Sets the cursor position of the console to the specified value.

setconsole (text)

Sets the consoles text to the specified value.

getconsole ()

Returns the console's current text.

console.lock (value)

Locks or unlocks the console, so the user can type in it. Value must be either 1 or 0. If 0, the console will be unlocked. If 1, the console will be locked. If anything else, the function is ignored.

Back to D++ Documentation Index

dpp/docs_functions.txt · Last modified: 2015-07-30 13:46 by daniel