Function Reference
From Sputnik Wiki
				
				
				(Difference between revisions)
				
																
				
				
								
				 (→Other GUI Functions)  | 
		 (→Window Management Functions)  | 
		||
| Line 302: | Line 302: | ||
* [[Core Function WinExists|WinExists ( <title>, <text> )]] -- Checks to see if a specified window exists  | * [[Core Function WinExists|WinExists ( <title>, <text> )]] -- Checks to see if a specified window exists  | ||
* [[Core Function WinGetHandle|WinGetHandle ( <title>, <text> )]] -- Retrieves the internal handle of a window  | * [[Core Function WinGetHandle|WinGetHandle ( <title>, <text> )]] -- Retrieves the internal handle of a window  | ||
| + | |||
| + | ===== Controls =====  | ||
| + | * [[Core Function ControlSend|ControlSend ( <title>, <text>, <controlID>, <string> <flag> )]] -- Sends a string of characters to a control  | ||
==== Misc Functions ====  | ==== Misc Functions ====  | ||
Revision as of 01:50, 27 November 2011
Function Reference
How to create a Function
To create your own funtions see the Function page.
Core Functions
Language Features
- <Expression> =~ m/pattern/flags -- Match a string to a regular expression pattern and check if it matches and optionally return captured groups
 - <Expression> =~ s/pattern/replacement/flags -- Replace parts of a string using a regular expression pattern and optionally executing functions on the matched groups
 
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
 
Multithreading Functions
- ThreadCreate( <name>, <function> ) -- Create a new thread and start it off executing a function or some code
 - ThreadSleep( <name> ) -- Freeze a thread and make it sleep
 - ThreadResume( <name> ) -- Unfreeze a thread and allow it to continue execution
 - ThreadState( <name> ) -- Returns state of a thread
 - ThreadKill( <name> ) -- Terminate a thread and remove it from the script
 - ThreadExists( <name> ) -- Check if a thread exists by this name
 - ThreadName( ) -- Returns the name of the current thread that is executing this code
 - Threads( ) -- Return an array of all threads
 
Variable Type Conversions
- Char( <expression> ) -- Returns the single letter representation of an expression
 - Byte( <expression> ) -- Returns the unsigned 8-bit integer (whole number) representation of an expression
 - SByte( <expression> ) -- Returns the signed 8-bit integer (whole number) representation of an expression
 - Short( <expression> ) -- Returns the signed 16-bit integer (whole number) representation of an expression
 - Int16( <expression> ) -- Returns the signed 16-bit integer (whole number) representation of an expression
 - Int32( <expression> ) -- Returns the signed 32-bit integer (whole number) representation of an expression
 - Int( <expression> ) -- Returns the signed 32-bit integer (whole number) representation of an expression
 - Int64( <expression> ) -- Returns the signed 64-bit integer (whole number) representation of an expression
 - Long( <expression> ) -- Returns the signed 64-bit integer (whole number) representation of an expression
 - UShort( <expression> ) -- Returns the unsigned 16-bit integer (whole number) representation of an expression
 - UInt16( <expression> ) -- Returns the unsigned 16-bit integer (whole number) representation of an expression
 - UInt32( <expression> ) -- Returns the unsigned 32-bit integer (whole number) representation of an expression
 - UInt( <expression> ) -- Returns the unsigned 32-bit integer (whole number) representation of an expression
 - UInt64( <expression> ) -- Returns the unsigned 64-bit integer (whole number) representation of an expression
 - ULong( <expression> ) -- Returns the unsigned 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
Misc
- Unset( $variable ) -- Delete a variable
 
Hash/Array
- Reset( $variable ) -- Reset the current array pointer to the first element
 - Next( $variable ) -- Set the array pointer to the next element
 - Prev( $variable ) -- Set the array pointer to the previous element
 
Type Checking
- isVarChar( $variable ) -- Checks if a variable is a char type
 - isVarByte( $variable ) -- Checks if a variable is an unsigned 8-bit integer type
 - isVarSByte( $variable ) -- Checks if a variable is a signed 8-bit integer type
 - isVarShort( $variable ) -- Checks if a variable is a signed 16-bit integer type
 - isVarInt16( $variable ) -- Checks if a variable is a signed 16-bit integer type
 - isVarInt( $variable ) -- Checks if a variable is a signed 32-bit integer type
 - isVarInt32( $variable ) -- Checks if a variable is a signed 32-bit integer type
 - isVarInt64( $variable ) -- Checks if a variable is a signed 64-bit integer type
 - isVarLong( $variable ) -- Checks if a variable is a signed 64-bit integer type
 - isVarUShort( $variable ) -- Checks if a variable is an unsigned 16-bit integer type
 - isVarUInt16( $variable ) -- Checks if a variable is an unsigned 16-bit integer type
 - isVarUInt( $variable ) -- Checks if a variable is an unsigned 32-bit integer type
 - isVarUInt32( $variable ) -- Checks if a variable is an unsigned 32-bit integer type
 - isVarUInt64( $variable ) -- Checks if a variable is an unsigned 64-bit integer type
 - isVarULong( $variable ) -- Checks if a variable is an unsigned 64-bit integer type
 - isVarFloat( $variable ) -- Checks if a variable is a single precision floating point type
 - isVarDouble( $variable ) -- Checks if a variable is a double precision floating point type
 - isVarString( $variable ) -- Checks if a variable is a string type
 - isVarNumber( $variable ) -- Checks if a variable is any integer or float/double type
 - isVarBinary( $variable ) -- Checks if a variable is a binary type
 - isVarRef( $variable ) -- Check if a variable is an reference to another variable
 - isVarArray( $variable ) -- Check if a variable is an array
 - isVarObj( $variable, <type> ) -- Check if a variable is an object type (This includes classes, file handles etc)
 - isVarClass( $variable, <type> ) -- Check if a variable's object type is a class
 - isVarGUI( $variable ) -- Check if a variable's object type is a GUI
 - isVarGUIObject( $variable ) -- Check if a variable's object type is a GUI Object (Buttons etc)
 
Binary Data Management Functions
- Pack( <expression>, <expressions> ) -- Pack data into a binary array
 - Unpack( <expression>, <binary-array> ) -- Unpack data from a binary array
 - BinaryCreate( <size>, <fill> ) -- Create a new binary variable and its array size and fill data type
 - BinaryClone( <binary-array> ) -- Clone a binary variable 100% and return a new binary variable with exactly same data as the old one
 - BinaryWipe( <binary-array> ) -- Wipes a binary variables data 100% and sets the variable to a blank int containing just 0
 - 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
 - BinaryUnshift( <binary-array>, <byte> ) -- Add a byte to the beginning of a binary variable
 - BinaryPush( <binary-array>, <byte> ) -- 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>, <flag> ) -- Save a binary variable data to file
 - BinaryLoad( <file>, <flag> ) -- Create a new binary variable by loading binary data from a file
 
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> ) -- Calculates the arctangent of a number
 - BitAND( <expression> ) --
 - BitNOT( <expression> ) --
 - BitOR( <expression> ) --
 - BitROTATE( <expression> ) --
 - BitSHIFT( <value>, <shift> ) -- Performs a bit shifting operation
 - BitXOR( <expression> ) --
 - Ceiling( <expression> ) --
 - Cos( <expression> ) --
 - Cosh( <expression> ) --
 - Exp( <expression> ) --
 - Floor( <expression> ) --
 - Log( <expression> ) --
 - Math( <expression> ) --
 - Max( <expression>, <expression2> ) -- Find the greater number and return it
 - Min( <expression> ) --
 - Mod( <expression> ) --
 - Pow( <expression> ) --
 - Random( <expression> ) -- Get a random number from the defined area.
 - 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( <sting>, <string>, <casesense>) -- Check is string contains sub string
 - Compare( <string>, <string> ) -- Compare two strings to each other
 - 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
 - DecPad( <expression>, <count> ) -- Pads numeric string to a given number of chars (Filling in the gap with zeros)
 - 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> ) -- Checks if string contains only Alphabetic characters
 - isAlphaNumeric( <expression> ) -- Checks if string contains only AlphaNumeric(A-Z, 0-9), Characters
 - isASCII( <expression> ) --
 - isEmpty( <expression> ) -- Checks if a string is completely empty.
 - isFloat( <expression> ) --
 - isLower( <expression> ) -- Checks if string contains only lowercase letters
 - isNumeric( <expression> ) -- Checks if string only contains numbers
 - isSpace( <expression> ) --
 - isSymbol( <expression> ) --
 - isUpper( <expression> ) --
 - isXDigit( <expression> ) --
 - LC( <expression> ) --
 - LCFirst( <expression> ) --
 - LCWords( <expression> ) --
 - Left( <expression> ) --
 - Match( <expression> ) --
 - MD5( <expression> ) -- Creates MD5 Hash of specified string
 - PadLeft( <expression> ) --
 - PadRight( <expression> ) --
 - RandStr( <expression> ) --
 - Repeat( <expression>, <count>, <flag> ) -- Create a new string or new array containing repeats of a string provided
 - Replace( <expression> ) --
 - Reverse( <expression> ) --
 - Right( <expression>, <count> ) -- Returns a number of characters from the right-hand side of a string.
 - SHA1( <expression> ) -- Returns SHA1 hash of string
 - 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> ) -- Checks if string starts with specified string
 - StrLen( <expression> ) -- Returns length of specified string
 - SubStr( <expression> ) -- Return part of a string
 - Trim( <expression> ) -- Removes whitespace from the beginning and end of a string
 - TrimLeft( <expression> ) --Strip whitespace from the start of a string
 - TrimRight( <expression> ) -- Strip whitespace from the end of a string
 - UC( <expression> ) -- Returns string in all Upper Case
 - UCFirst( <expression> ) -- Upper Cases first letter of string
 - UCWords( <expression> ) -- Upper Cases first letter of each word in string
 
Array Functions
- Join( <array>, <separator> ) -- Join an array into a string with an optional separator
 - UBound( <array/binary-array> ) -- Returns the size of array (How many elements it currently has stored)
 - Push( <array>, <expressions> ) -- Add items to the end of an array
 - Insert( <array>, <id>, <expressions> ) -- Add items to an array at a given location
 - Unshift( <array>, <expressions> ) -- Add items to the beginning of an array
 - Pop( <array> ) -- Delete the first item in an array
 - Shift( <array> ) -- Delete the last item in an array
 - Remove( <array>, <start-id>, <end-id> ) -- Delete items from an array starting at a given location and stopping at a given location
 - Delete( <array>, <expresions> ) -- Delete items from an array that match regex patterns, number patterns, or contain specific text etc
 
Hash (Dictionary) Functions
Process Functions
- DLLCall( <dll>, <function>, <returntype>, <paramtypes>, <params> ) -- Dynamically call a function in a DLL
 - Run( <file>, <workdir>, <flag> ) -- Runs an external program
 - RunWait( <file>, <workdir>, <flag> ) -- Runs an external program and waits until the program finishes
 - ProcessClose( <pid/name> ) -- Terminates a named process
 - ProcessExists( <pid/name> ) -- Checks to see if a specified process exists
 - ProcessList( <name> ) -- Returns an array listing the currently running processes (names and PIDs)
 - ProcessSetPriority( <name>, <priority> ) -- Changes the priority of a process
 - ProcessWait( <name>, <timeout> ) -- Pauses the current thread until a given process exists or optional the timeout expires
 - ProcessWaitClose( <name>, <timeout> ) -- Pauses the current thread until a given process no longer exists or optional the timeout expires
 - Shutdown( <shutdown code> ) -- Shuts down the system
 
Environment Management
- EnvExpand( <expression> ) -- Convert a string containing %name% env tags and return complete string with names resolved
 - EnvGet( <tag> ) -- Get the value of an environment variable
 - EnvSet( <tag>, <expression> ) -- Set the value of an environment variable
 - EnvUpdate( <tag>, <expression> ) -- Refreshes the OS environment
 
File Functions
File Create/Read/Write Functions
- FileOpen( <FileName>, <flag> ) -- Opens a file for reading or writing
 - FileClose( <file> ) -- Closes a previously opened file
 - FileWrite( <file>, <expression> ) -- Write text to previously opened file at the current File Steam pointer location
 - FileWriteBinary( <file>, <binary-array> ) -- Write the data from a binary variable to previously opened 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
 - FileAppendBinary( <file>, <binary-array> ) -- Append the data from a binary variable to the end of a previously opened 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
 - FileReadBinary( <file>, <expression> ) -- Read a number of bytes from a previously opened 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
 
GUI Functions
Dialog Creation Functions
Dialog Properties Get/Set Functions
Control Creation Functions
- GUICreateButton( <gui/container>, <name>, <text>, <left>, <top>, <width>, <height> ) -- Create a button
 - GUICreateTextBox( <gui/container>, <name>, <text>, <left>, <top>, <width>, <height> ) -- Create a Textbox
 - GUICreateTextBoxEx( <gui/container>, <name>, <text>, <left>, <top>, <width>, <height> ) -- Create a multiline Textbox
 - GUICreateTimer( <gui/container>, <name>, <interval> ) -- Create a timer
 - GUICreateDataGrid( <gui/container>, <name>, <left>, <top>, <width>, <height> ) -- Create a Data Grid control.
 
Event Linking Functions
Dialog/Control Properties Get/Set Functions
Control Properties Get/Set Functions
Other GUI Functions
- MsgBox( <message>, <title>, <flag>, <timeout> ) -- Show a message dialog
 - InputBox( <title>, <message>, <default text> ) -- Shows a box to input text.
 
Keyboard Control Functions
- HotKeySet( <keydef>, <expression> ) -- Create a custom hotkey to run custom code or execute a function.
 - SendKeys( <keydef>, <flag> ) -- Sends simulated keystrokes to the active window
 
Mouse Control Functions
- MouseClick ( <button>, <x>, <y>, <clicks>, <speed> ) -- Perform a mouse click operation
 - MouseClickDrag ( <button>, <x1>, <y1>, <x2>, <y21>, <speed> ) -- Perform a mouse click and drag operation
 - MouseDown ( <button> ) -- Perform a mouse down event at the current mouse position
 - MouseUp ( <button> ) -- Perform a mouse up event at the current mouse position
 - MouseMove ( <x>, <y>, <speed> ) -- Moves the mouse pointer
 - MouseGetPos ( ) -- Retrieves the current position of the mouse cursor
 - MouseGetCursor ( ) -- Returns a cursor ID Number of the current Mouse Cursor
 - MouseWheel ( <direction>, <clicks> ) -- Moves the mouse wheel up or down.
 
Window Management Functions
- WinActivate ( <title>, <text> ) -- Activates (gives focus to) a window
 - WinActive ( <title>, <text> ) -- Checks to see if a specified window exists and is currently active
 - WinExists ( <title>, <text> ) -- Checks to see if a specified window exists
 - WinGetHandle ( <title>, <text> ) -- Retrieves the internal handle of a window
 
Controls
- ControlSend ( <title>, <text>, <controlID>, <string> <flag> ) -- Sends a string of characters to a control
 
Misc Functions
- Return <expressions> -- Returns a result from a Function.
 - Throw( <expression> ) -- Throw an exception.
 - Eval( <expression>, <flag> ) -- Evaluate a string as Sputnik code.
 - GC( <flag> ) -- Use the garbage collector.
 - Require( <file>, <flag> ) -- Add all functions etc from a file for use.
 - Include( <file>, <flag> ) -- Add all functions etc from a file for use and execute all expressions.
 - PixelGetColor ( <x>, <y> ) -- Returns a pixel color according to x, y pixel coordinates.
 - Opt( <option>, <value> ) -- Changes the operation of various Sputnik functions/parameters
 
User Defined Functions
These functions are created using Sputnik and are not part of the Sputnik core language.