Function Reference
From Sputnik Wiki
Contents
|
Function Reference
Core Functions
Language Features
Console Functions
- Print( <expression> ) -- Prints an expressions string value to the console window.
- Println( <expression> ) -- Prints an expressions string value to the console window and inserts a newline charactor at the end.
- Printf( <expression>, <expressions>... ) -- Print a formatted string to the console window
- Input( <expression> ) -- Capture a string typed to console window.
- InputC( <expression> ) -- Capture a char typed to console window.
- Cls( ) -- Clear all text from the console window.
Variable Type Conversions
- Byte( <expression> ) -- Returns the 8-bit integer (whole number) representation of an expression.
- Int16( <expression> ) -- Returns the 16-bit integer (whole number) representation of an expression.
- Int32( <expression> ) (Alias: Int( $variable )) -- Returns the 32-bit integer (whole number) representation of an expression.
- Int64( <expression> ) -- Returns the 64-bit integer (whole number) representation of an expression.
- Float( <expression> ) -- Returns the 32-bit floating point representation of an expression.
- Double( <expression> ) -- Returns the 64-bit floating point representation of an expression.
- String( <expression> ) -- Returns the String representation of an expression.
Common Variable Functions
- isInt( $variable ) -- Checks if a variable is an integer type
- isBinary( $variable ) -- Checks if a variable is a binary ype
- isFloat( $variable ) -- Checks if a variable is a float type
- isNumber( $variable ) -- Checks if a variable is a integer or float type
- isString( $variable ) -- Checks if a variable is a string type
- isArray( $variable ) -- Check if a variable is an array
- isHash( $variable ) -- Check if a variable is an hash
- isObj( $variable ) -- Check if a variable is an object type
- isClass( $variable ) -- Check if a variable's object type is a class
- isStruct( $variable ) -- Check if a variable's object type is a struct
Binary Data Management Functions
- Pack( <expression>, <expressions> ) -- Pack data into a binary array
- Unpack( <expression>, <binary-array> ) -- Unpack data from a binary array
- BinaryClone( <binary-array> ) -- Clone a binary variable 100% and return a new binary variable with exactly same data as the old one
- BinaryStr( <binary-array>, <separator> ) -- Create a Hex string from a binary array
- BinaryHex( <expression> ) -- Create a binary array from a hex string
- BinaryLen( <binary-array> ) -- Returns the number of bytes in a binary variable
- BinaryGet( <binary-array>, <index> ) -- Get the byte at an index of a binary variable
- BinarySet( <binary-array>, <index>, <value> ) -- Set the byte at an index of a binary variable
- BinaryReverse( <binary-array>, <start>, <length> ) -- Reverse the order bytes a binary variable
- BinaryMid( <binary-array>, <start>, <length> ) -- Create a binary variable by extracting a number of bytes from another binary variable
- BinaryAppend( <binary-array>, <binary-array2>, <flag> ) -- Append a binary variables data onto the end or beginning of another binary variables data
- BinaryInsert( <binary-array>, <binary-array2>, <index> ) -- Insert a binary variables data into another binary variable at a specific location
- BinaryDelete( <binary-array>, <index> ) -- Delete an element from an index of a binary variable
- BinaryUnshift( <binary-array> ) -- Add a byte to the beginning of a binary variable
- BinaryPop( <binary-array> ) -- Add a byte to the end of a binary variable
- BinaryShift( <binary-array> ) -- Delete the first byte from a binary variable
- BinaryPop( <binary-array> ) -- Delete the last byte from a binary variable
- BinaryResize( <binary-array>, <size>, <data> ) -- Resize a binary variables data array
- BinaryCompress( <binary-array> ) -- Compress a binary variables data
- BinaryUncompress( <binary-array> ) -- Uncompress a binary variable data
- BinarySave( <binary-array>, <file> ) -- Save a binary variable data to file
- BinaryLoad( <binary-array>, <file> ) -- Load binary data from a file to a binary variable
Math Functions
- Abs( <expression> ) -- Calculates the absolute value of a number
- ACos( <expression> ) -- Calculates the arcCosine of a number
- ASin( <expression> ) -- Calculates the arcsine of a number
- ATan( <expression> ) --
- BitAND( <expression> ) --
- BitNOT( <expression> ) --
- BitOR( <expression> ) --
- BitROTATE( <expression> ) --
- BitSHIFT( <expression> ) --
- BitXOR( <expression> ) --
- Ceiling( <expression> ) --
- Cos( <expression> ) --
- Cosh( <expression> ) --
- Exp( <expression> ) --
- Floor( <expression> ) --
- Log( <expression> ) --
- Math( <expression> ) --
- Max( <expression> ) --
- Min( <expression> ) --
- Mod( <expression> ) --
- Random( <expression> ) --
- Round( <expression> ) --
- Sin( <expression> ) --
- Sinh( <expression> ) --
- Sqrt( <expression> ) --
- Tan( <expression> ) --
- Tanh( <expression> ) --
- Turncate( <expression> ) --
String Functions
- Asc( <expression> ) --
- AscW( <expression> ) --
- Chr( <expression> ) --
- ChrW( <expression> ) --
- Contains( <expression> ) --
- Compare( <expression> ) --
- Dec( <expression> ) -- Returns a integer representation of a hexadecimal string
- FDec( <expression> ) -- Returns a float representation of a hexadecimal string
- DDec( <expression> ) -- Returns a double representation of a hexadecimal string
- EndsWith( <expression> ) --
- Hex( <expression>, <length> ) -- Returns a string representation of an integer type converted to hexadecimal
- FHex( <expression> ) -- Returns a string representation of an float type converted to hexadecimal
- DHex( <expression> ) -- Returns a string representation of an double type converted to hexadecimal
- InStr( <string>, <substirng>, <casesense>, <occurrence>, <start>, <count> ) -- Checks if a string contains a given substring.
- isAlpha( <expression> ) --
- isAlphaNumeric( <expression> ) --
- isASCII( <expression> ) --
- isFPU( <expression> ) --
- isLower( <expression> ) --
- isNumeric( <expression> ) --
- isSpace( <expression> ) --
- isSpace( <expression> ) --
- isUpper( <expression> ) --
- isXDigit( <expression> ) --
- LC( <expression> ) --
- LCFirst( <expression> ) --
- LCWords( <expression> ) --
- Left( <expression> ) --
- Match( <expression> ) --
- MD5( <expression> ) --
- PadLeft( <expression> ) --
- PadRight( <expression> ) --
- RandStr( <expression> ) --
- RegExp( <expression>, <pattern>, <flag>, <start> ) -- Check if a string fits a given regular expression pattern
- Replace( <expression> ) --
- Reverse( <expression> ) --
- Right( <expression> ) --
- SHA1( <expression> ) --
- Split( <expression>, <delim/pattern>, <flag> ) -- Splits up a string into substrings depending on the given delimiters.
- SPrintf( <expression>, <expressions>... ) -- Create a formatted string
- StartsWith( <expression> ) --
- StrLen( <expression> ) --
- SubStr( <expression> ) --
- Trim( <expression> ) --
- TrimLeft( <expression> ) --
- TrimRight( <expression> ) --
- UC( <expression> ) --
- UCFirst( <expression> ) --
- UCWords( <expression> ) --
Array Functions
- Join( <array>, <separator> ) -- Join an array into a string with an optional separator
- Splice( <array>, <expressions> ) -- Create a new array from an old one splicing it in specific ways
- UBound( <array/binary-array> ) -- Returns the size of array (How many elements it currently has stored)
File Functions
Text File Create/Read/Write Functions
- FileOpen( <FileName>, <flag> ) -- Opens a text file for reading or writing
- FileClose( <file> ) -- Closes a previously opened file
- FileWrite( <file>, <expression> ) -- Write text to previously opened text file at the current File Steam pointer location
- FileAppend( <file>, <expression> ) -- Append a line of text to the end of a previously opened text file
- FileSeek( <file>, <offset>, <flag> ) -- Change the POSITION of the File Stream pointer
- FilePos( <file> ) -- Get the current POSITION of the File Stream pointer
- FileRead( <file>, <expression> ) -- Read a number of characters from a previously opened text file starting from current File Steam pointer location
- FileReadLine( <file>, <expression> ) -- Read a line of text from a previously opened text file (Or specify a name of a file)
- FileReadLines( <file> ) -- Read all lines of text from a previously opened text file (Or specify a name of a file)
- FileSave( <file>, <expression> ) -- Save all text to a file
- FileLoad( <file> ) -- Load all text from a file
Misc Functions
- Return( <expression> ) -- Returns a result from a Function.
- Require( <expression> ) -- Includes a file in the current script.
- Throw( <expression> ) -- Throw an exception.
User Defined Functions
This functions are either a Namepace or a Class.
These functions are created using Sputnik and are not part of the Sputnik core language.
Namespaces
Namespace Str -- Require("String.spk")
- str.StrToHex( <expression> ) -- Convert a string to a hex string
- str.HexToStr( <expression> ) -- Convert a hex string to a string