LitDev Extension API

Geography LD3DView LDArray LDBits LDBlueTooth
LDCall LDChart LDClient LDClipboard LDColours
LDCommPort LDController LDControls LDCursors LDDataBase
LDDateTime LDDebug LDDialogs LDDictionary LDEffect
LDEmail LDEncryption LDEvents LDFastArray LDFastShapes
LDFigures LDFile LDFocus LDftp LDGeography
LDGraph LDGraphicsWindow LDHashTable LDHID LDIcon
LDImage LDInline LDIOWarrior LDList LDLogic
LDMath LDMathX LDMatrix LDMusic LDNetwork
LDPhysics LDProcess LDQueue LDRegex LDResources
LDScrollBars LDSearch LDServer LDSettings LDShapes
LDShell LDSort LDSound LDSpeech LDStatistics
LDStopwatch LDText LDTextWindow LDTimer LDTranslate
LDUnits LDUtilities LDVector LDWaveForm LDWebCam
LDWindows LDxml LDZip

Geography
This is an abstraction layer around the API.
If we change the API's source or change API
providers LD Geography should not have to change.



LD3DView
3D Visualisation in the GraphicsWindow.

Coordinates have the following directions and have no correspondence to the GraphicsWindow coordinates.
X - Left(-) to Right(+)
Y - Down(-) to Up(+)
Z - Far(-) to Near(+)

For more details on the underlying methods see
Several of the AddShape methods use HelixToolkit (recompiled and slightly modified for SmallBasic)

Also see LDVector for vector algebra methods.


AddAmbientLight AddArrow AddBackImage
AddCone AddCube AddDirectionalLight
AddGeometry AddIcosahedron AddImage
AddPipe AddPointLight AddPyramid
AddRectangle AddRevolute AddSphere
AddSpotLight AddTube AddView
AnimateRotation AnimateRotation2 AnimateTranslation
AutoControl AutoControl2 BoundingBox
CameraProperties CloneObject Freeze
GetCameraDirection GetCameraPosition GetCameraUpDirection
GetPosition HitTest LastRotationCompleted
LastTranslationCompleted LoadModel ModifyObject
MoveCamera QueuedRotationCompleted QueuedTranslationCompleted
ResetCamera ResetMaterial ReverseNormals
RotateGeometry RotateGeometry2 RotateGeometry3
RotationCompleted ScaleGeometry SetBackMaterial
SetBillBoard SetCentre SpecularExponent
SwapUpDirection TranslateGeometry TranslationCompleted

AddAmbientLight(shapeName,colour)
Add an ambient light source.
shapeName The 3DView object.
colour The light colour.
returns The 3DView Light name.

AddArrow(shapeName,length,diameter,arrowLength,arrowDiameter,divisions,colour,materialType)
Add an arrow geometry object pointing up starting at (0,0,0).
shapeName The 3DView object.
length The length of the arrow.
diameter The diameter of the arrow shaft.
arrowLength The length of the arrow head.
arrowDiameter The diameter of the arrow head.
divisions The number of divisions for the arrow (default 18).
colour A colour or gradient brush for the object.
materialType A material for the object.
The available options are:
"E" Emmissive - constant brightness.
"D" Diffusive - affected by lights.
"S" Specular - specular highlights.

returns The 3DView Geometry name.

AddBackImage(shapeName,geometryName,textures,imageName,materialType)
Add an image to a back surface of geometry object.
A geometry 'skin' may contain several segment images in one image.

shapeName The 3DView object.
geometryName The geometry object.
textures A space or colon deliminated list of the texture coordinates for each node.
Each node has 2 values between 0 and 1 indicating the x,y image mapping to the node.
The may be defaulted to "" if the texture has previously been set.

imageName The image to load to the geometry.
Value returned from ImageList.LoadImage or local or network image file.
A colour or gradient brush can also be used here.

materialType A material for the object.
The available options are:
"E" Emmissive - constant brightness.
"D" Diffusive - affected by lights.
"S" Specular - additional specular highlights.


AddCone(shapeName,baseRadius,topRadius,height,divisions,colour,materialType)
Add a cone geometry object pointing up with base centred at (0,0,0).
Note a cylinder is a cone with baseRadius = topRadius.

shapeName The 3DView object.
baseRadius The radius of the base.
topRadius The radius of the top if truncated (default 0).
height The height of the cone.
divisions The number of divisions for the cone (default 18).
colour A colour or gradient brush for the object.
materialType A material for the object.
The available options are:
"E" Emmissive - constant brightness.
"D" Diffusive - affected by lights.
"S" Specular - specular highlights.

returns The 3DView Geometry name.

AddCube(shapeName,sideLength,colour,materialType)
Add a cube geometry object centered on (0,0,0).
shapeName The 3DView object.
sideLength The side length of the cube.
colour A colour or gradient brush for the object.
materialType A material for the object.
The available options are:
"E" Emmissive - constant brightness.
"D" Diffusive - affected by lights.
"S" Specular - specular highlights.

returns The 3DView Geometry name.

AddDirectionalLight(shapeName,colour,xDir,yDir,zDir)
Add a directional light source.
shapeName The 3DView object.
colour The light colour.
xDir The x direction of the light.
yDir The y direction of the light.
zDir The z direction of the light.
returns The 3DView Light name.

AddGeometry(shapeName,points,indices,normals,colour,materialType)
Add a geometry object.
shapeName The 3DView object.
points A space or colon deliminated list of point coordinates.
indices A space or colon deliminated list of indices for each triangle (counter-clockwise for outward face).
normals An optional space or colon deliminated list of the outward normals for each node or "".
colour A colour or gradient brush for the object.
materialType A material for the object.
The available options are:
"E" Emmissive - constant brightness.
"D" Diffusive - affected by lights.
"S" Specular - specular highlights.

returns The 3DView Geometry name.

AddIcosahedron(shapeName,radius,colour,materialType)
Add an icosahedron geometry object centred at (0,0,0).
shapeName The 3DView object.
radius The radius of the icosahedron.
colour A colour or gradient brush for the object.
materialType A material for the object.
The available options are:
"E" Emmissive - constant brightness.
"D" Diffusive - affected by lights.
"S" Specular - specular highlights.

returns The 3DView Geometry name.

AddImage(shapeName,geometryName,textures,imageName,materialType)
Add an image to a geometry object.
A geometry 'skin' may contain several segment images in one image.

shapeName The 3DView object.
geometryName The geometry object.
textures A space or colon deliminated list of the texture coordinates for each node.
Each node has 2 values between 0 and 1 indicating the x,y image mapping to the node.
The may be defaulted to "" if the texture has previously been set.

imageName The image to load to the geometry.
Value returned from ImageList.LoadImage or local or network image file.
A colour or gradient brush can also be used here.

materialType A material for the object.
The available options are:
"E" Emmissive - constant brightness.
"D" Diffusive - affected by lights.
"S" Specular - additional specular highlights.


AddPipe(shapeName,length,innerDiameter,outerDiameter,divisions,colour,materialType)
Add a pipe geometry object pointing up with base centred at (0,0,0).
shapeName The 3DView object.
length The length of the pipe.
innerDiameter The inner diameter of the pipe.
outerDiameter The outer diameter of the pipe.
divisions The number of divisions for the pipe (default 18).
colour A colour or gradient brush for the object.
materialType A material for the object.
The available options are:
"E" Emmissive - constant brightness.
"D" Diffusive - affected by lights.
"S" Specular - specular highlights.

returns The 3DView Geometry name.

AddPointLight(shapeName,colour,xPos,yPos,zPos,range)
Add a non-directional point light source.
shapeName The 3DView object.
colour The light colour.
xPos The x position of the light.
yPos The y position of the light.
zPos The z position of the light.
range The light range.
returns The 3DView Light name.

AddPyramid(shapeName,sideLength,height,colour,materialType)
Add a pyramid geometry object pointing up with base centred at (0,0,0).
shapeName The 3DView object.
sideLength The radius of the base.
height The height of the cone.
colour A colour or gradient brush for the object.
materialType A material for the object.
The available options are:
"E" Emmissive - constant brightness.
"D" Diffusive - affected by lights.
"S" Specular - specular highlights.

returns The 3DView Geometry name.

AddRectangle(shapeName,width,height,colour,materialType)
Add a rectangle geometry object centred at (0,0,0).
shapeName The 3DView object.
width The width of the rectangle.
height The height of the rectangle.
colour A colour or gradient brush for the object.
materialType A material for the object.
The available options are:
"E" Emmissive - constant brightness.
"D" Diffusive - affected by lights.
"S" Specular - specular highlights.

returns The 3DView Geometry name.

AddRevolute(shapeName,path,divisions,colour,materialType)
Add a revolute geometry object. This is a surface starting at (0,0,0) and pointing up.
Its shape is defined by a set points (Y,Z) where Y is the vertical distance along the surface from 0 and Z is the radius of revolution.

shapeName The 3DView object.
path A space or colon deliminated list of 2D point coordinates describing the revolute shape.
divisions The radial divisions, default 10 (affects number of triangles and smoothness).
colour A colour or gradient brush for the object.
materialType A material for the object.
The available options are:
"E" Emmissive - constant brightness.
"D" Diffusive - affected by lights.
"S" Specular - specular highlights.

returns The 3DView Geometry name.

AddSphere(shapeName,radius,divisions,colour,materialType)
Add a sphere geometry object centred on (0,0,0).
shapeName The 3DView object.
radius The sphere radius.
divisions The sphere divisions, default 10 (affects number of triangles and smoothness).
colour A colour or gradient brush for the object.
materialType A material for the object.
The available options are:
"E" Emmissive - constant brightness.
"D" Diffusive - affected by lights.
"S" Specular - specular highlights.

returns The 3DView Geometry name.

AddSpotLight(shapeName,colour,xPos,yPos,zPos,xDir,yDir,zDir,angle,range)
Add a directional spot light source.
shapeName The 3DView object.
colour The light colour.
xPos The x position of the light.
yPos The y position of the light.
zPos The z position of the light.
xDir The x direction of the light.
yDir The y direction of the light.
zDir The z direction of the light.
angle The cone angle the light in degrees.
range The light range.
returns The 3DView Light name.

AddTube(shapeName,path,diameter,divisions,colour,materialType)
Add a tube geometry object.
shapeName The 3DView object.
path A space or colon deliminated list of 3D point coordinates.
diameter The tube diameter.
divisions The tube radial divisions, default 10 (affects number of triangles and smoothness).
colour A colour or gradient brush for the object.
materialType A material for the object.
The available options are:
"E" Emmissive - constant brightness.
"D" Diffusive - affected by lights.
"S" Specular - specular highlights.

returns The 3DView Geometry name.

AddView(width,height,performance)
Add a 3DView (GraphicsWindow shape).
width The width of the 3DView.
height The height of the 3DView.
performance A flag to favour speed over quality "True" or "False".
"True" removes visual clipping (clip 3DView to input width and height), hit-testing (unused) and anti-aliasing (not needed).

returns The 3DView viewport3D name.

AnimateRotation(shapeName,geometryName,xDir,yDir,zDir,startAngle,endAngle,duration,repeats)
Animate a geometry rotation about an axis vector.
This uses the second rotation, the first is still available for another axis rotation.

shapeName The 3DView object.
geometryName The geometry object to animate.
xDir X direction of vector to rotate about.
yDir Y direction of vector to rotate about.
zDir Z direction of vector to rotate about.
startAngle The starting angle in degrees (e.g. 0).
endAngle The final angle in degrees (e.g. 360).
duration The animation duration (time in sec).
repeats The number of times to repeat the animation (-1 is for ever).

AnimateRotation2(shapeName,geometryName,xDir,yDir,zDir,startAngle,endAngle,duration,repeats)
Animate a geometry rotation about an axis vector.
This uses the third rotation, the first is still available for another axis rotation.

shapeName The 3DView object.
geometryName The geometry object to animate.
xDir X direction of vector to rotate about.
yDir Y direction of vector to rotate about.
zDir Z direction of vector to rotate about.
startAngle The starting angle in degrees (e.g. 0).
endAngle The final angle in degrees (e.g. 360).
duration The animation duration (time in sec).
repeats The number of times to repeat the animation (-1 is for ever).

AnimateTranslation(shapeName,geometryName,x,y,z,duration)
Animate a geometry translation.
shapeName The 3DView object.
geometryName The geometry object to animate.
x X position to animate to.
y Y position to animate to.
z Z position to animate to.
duration The animation duration (sec).

AutoControl(pitchRoll,shift,keyDistance,speed)
Set auto control of the camera.
This mode is a general purpose camera control, mainly for moving within a scene (a flyby mode).
Move forwards and backwards with mouse wheel (faster with Shift down, slower with Control down).
Yaw and Pitch camera moving with left mouse button.
Yaw with A,D or Left,Right keys, move forwards and backwards with W,S or Up,Down keys.
Roll camera moving with right mouse button.
Double left click an object to center it (Centre of rotation).
Double right click to reset the up direction to Y.
Yaw and Pitch scene moving with Shift and left mouse button after selecting an object to rotate scene about.
X, Y, Z keys change the view direction and up direction to face in these directions towards (0,0,0), with Shift then the negative direction.

pitchRoll Allow pitch and roll movement, "True" or "False".
shift Allow the Shift/Control key modifiers for mouse control, "True" or "False".
keyDistance The distance to view the scene from using keys, (0 prevents the X,Y,Z key shortcuts, -1 also prevents the A,D,W,S and arrow keys).
speed Forwards and backwards speed multiplier (default 1).

AutoControl2(keyDistance,speed)
Set auto control of the camera.
This mode is mainly to rotate and view a 3D scene rather than move through the scene (an inspection mode).
Zoom in or out with mouse wheel (faster with Shift down, slower with Control down).
Pan left/right with A,D or Left,Right keys, pan up/down with W,S or Up,Down keys.
Double left click an object to center it (Centre of rotation).
Double right click to reset the up direction to Y.
Yaw and Pitch scene moving with left mouse button after selecting an object to rotate scene about.
Roll scene moving with right mouse button.
X, Y, Z keys change the view direction and up direction to face in these directions towards selected center, with Shift then the negative direction.

keyDistance The distance to view the scene from using keys, (0 prevents the X,Y,Z key shortcuts).
speed Forwards and backwards speed multiplier (default 1).

BoundingBox(shapeName,geometryName)
Get the bounding box extent of a geometry.
This is the current position (after any transformations).

shapeName The 3DView object.
geometryName The geometry object.
returns An array of dimensions or "FAILED".
array[1] = sizeX (width)
array[2] = sizeY (height)
array[3] = sizeZ (depth)
array[4] = X (Xmin)
array[5] = Y (Ymin)
array[6] = Z (Zmin)


CameraProperties(shapeName,nearDistance,farDistance,angle)
Set the angle of view, near and far clipping distances.
These are all of the fundamental perspective camera properties.

shapeName The 3DView object.
nearDistance The near clipping distance (can improve near object e.g. wall hit detection).
A negative value is 0.001 (default is 0.125).

farDistance The far clipping distance (can improve performance).
A negative value is infinity (default).

angle The view angle cone of the camera in degrees (affects perspective vanishing point).
If this is negative, then an Orthographic (no perspective) camera is used with view width set to -angle).


CloneObject(shapeName,geometryName)
Create a complete copy of a geometry object and all of its properties.
shapeName The 3DView object.
geometryName The object to copy's name.
returns The new copied 3DView object name.

Freeze(shapeName,geometryName)
Freeze a geometry object to improve performance a bit - it cannot then be modified in any way.
shapeName The 3DView object.
geometryName The object to freeze.

GetCameraDirection(shapeName)
Get the camera direction.
shapeName The 3DView object.
returns An array of the camera direction vector.

GetCameraPosition(shapeName)
Get the camera position.
shapeName The 3DView object.
returns An array of the camera position coordinates.

GetCameraUpDirection(shapeName)
Get the camera up direction.
shapeName The 3DView object.
returns An array of the camera up direction vector.

GetPosition(shapeName,geometryName)
Get the transformed (current) center position of an existing geometry.
shapeName The 3DView object.
geometryName The geometry object.
returns An array of the transformed position or "FAILED".
array[1] = X (Xcen)
array[2] = Y (Ycen)
array[3] = Z (Zcen)


HitTest(shapeName,x,y)
Perform a hit test in the 3DView.
A negative value for the coordinates defaults to the screen centre (camera view).

shapeName The 3DView object.
x The x coordinate in the GraphicsWindow coordinates within the 3DView.
y The y coordinate in the GraphicsWindow coordinates within the 3DView.
returns An array with the hit object name and its distance or "" for no hit.

LastRotationCompleted
The last completed rotation animation geometry object.

LastTranslationCompleted
The last completed translation animation geometry object.

LoadModel(shapeName,fileName)
Load geometry models from a file.
Supported formats include 3ds, lwo, obj, objz, stl and off.

shapeName The 3DView object.
fileName The file to load.
Often image files etc are also required with the same name in the same folder.

returns An array with the added geometry names.

ModifyObject(shapeName,geometryName,action)
Perform an action on a light or geometry object.
shapeName The 3DView object.
geometryName The geometry or light name.
action The action to perform.
The allowed actions are:
"X" remove
"H" hide
"S" show


MoveCamera(shapeName,yaw,pitch,roll,move)
Move the camera view direction and position.
shapeName The 3DView object.
yaw The Left/Right rotation in degrees (Yaw).
pitch The Up/Down rotation in degrees (Pitch).
roll Spin view about view direction in degrees (Roll).
move The Forward/Backward movement in device coordinates (along the view direction).

QueuedRotationCompleted
The number of currently queued completed rotation animations.

QueuedTranslationCompleted
The number of currently queued completed translation animations.

ResetCamera(shapeName,xPos,yPos,zPos,xDir,yDir,zDir,xUp,yUp,zUp)
Reset the camera position, view direction and up vector (optional).
shapeName The 3DView object.
xPos The x position of the camera.
yPos The y position of the camera.
zPos The z position of the camera.
xDir The x direction of the camera.
yDir The y direction of the camera.
zDir The z direction of the camera.
xUp The optional x up direction of the camera or "".
yUp The optional y up direction of the camera or "".
zUp The optional z up direction of the camera or "".

ResetMaterial(shapeName,geometryName,colour,materialType)
Reset the material for an existing geometry.
shapeName The 3DView object.
geometryName The geometry object.
colour A colour or gradient brush for the object.
materialType A material for the object.
The available options are:
"E" Emmissive - constant brightness.
"D" Diffusive - affected by lights.
"S" Specular - specular highlights.


ReverseNormals(shapeName,geometryName)
Reverse the outward normals for a geometry.
For example, make the inside surface of a sphere the visible surface instead of the outside surface (skydome).

shapeName The 3DView object.
geometryName The geometry object to reverse outward normals.

RotateGeometry(shapeName,geometryName,x,y,z,angle)
Rotate a geometry object about its centre.
shapeName The 3DView object.
geometryName The geometry object.
x X direction of vector to rotate about.
y Y direction of vector to rotate about.
z Z direction of vector to rotate about.
angle An angle in degrees to rotate.

RotateGeometry2(shapeName,geometryName,x,y,z,angle)
Rotate a geometry object about its centre (a second rotation).
shapeName The 3DView object.
geometryName The geometry object.
x X direction of vector to rotate about.
y Y direction of vector to rotate about.
z Z direction of vector to rotate about.
angle An angle in degrees to rotate.

RotateGeometry3(shapeName,geometryName,x,y,z,angle)
Rotate a geometry object about its centre (a third rotation).
shapeName The 3DView object.
geometryName The geometry object.
x X direction of vector to rotate about.
y Y direction of vector to rotate about.
z Z direction of vector to rotate about.
angle An angle in degrees to rotate.

RotationCompleted
Event when a rotation animation is completed.

ScaleGeometry(shapeName,geometryName,scaleX,scaleY,scaleZ)
Scale (zoom) a geometry object about its centre.
shapeName The 3DView object.
geometryName The geometry object.
scaleX X scale factor.
scaleY Y scale factor.
scaleZ Z scale factor.

SetBackMaterial(shapeName,geometryName,colour,materialType)
Set the back face material for an existing geometry.
shapeName The 3DView object.
geometryName The geometry object.
colour A colour or gradient brush for the object.
materialType A material for the object.
The available options are:
"E" Emmissive - constant brightness.
"D" Diffusive - affected by lights.
"S" Specular - specular highlights.


SetBillBoard(shapeName,geometryName)
Set an object to rotate to always face the camera.
This uses the 2nd and 3rd rotations.

shapeName The 3DView object.
geometryName The geometry object.

SetCentre(shapeName,geometryName,x,y,z,options)
Set the centre for rotation and scale transformations of a geometry.
By default this is the centre of a bounding box for the geometry, often 0,0,0.
The centre is defined in the coordinates used to create the geometry.
It does not have to be within the geometry.
If a coordinate value is set to "", then the default value is used.

shapeName The 3DView object.
geometryName The geometry object.
x The x coordinate of the centre.
y The y coordinate of the centre.
z The z coordinate of the centre.
options Options to control centre setting. Multiples can be set, e.g. "R1R2R3" to set all rotations.
"R1" First rotation transformation
"R2" Second rotation transformation
"R3" Third rotation transformation
"S" Scale transformation


SpecularExponent
Get or set the specular exponent used for specular materials (default 5).

SwapUpDirection(shapeName,geometryName)
Rotate (swap) the Y and Z direction of a geometry.
This can be useful for geometries created with a Z up convention, coverting it to a Y up direction used by this extension.

shapeName The 3DView object.
geometryName The geometry object.

TranslateGeometry(shapeName,geometryName,dx,dy,dz)
Translate (move) a geometry object.
shapeName The 3DView object.
geometryName The geometry object.
dx X direction translation.
dy Y direction translation.
dz Z direction translation.

TranslationCompleted
Event when a translation animation is completed.

LDArray
A 1-Dimensional array method that is much faster than the standard SmallBasic arrays.

Useful for arrays with greater than 100 to 1000 elements.
An error will result in a return value "FAILED";


Copy CopyNew CopyToSBArray
Count Create CreateFromIndices
CreateFromValues Delete GetIndex
GetValue Load Save
Search SetValue Sort
SortIndex

Copy(array1,array2)
Copy one array to another array.
The dimensions of the 2 arrays must be the same.

array1 The array to copy from.
array2 The array to copy to.
returns "FAILED" or "" for success.

CopyNew(array)
Copy one array to a new array.
array The array to copy.
returns A copy of the array or "FAILED".

CopyToSBArray(array)
Copy LDArray type to SmallBasic array type.

The reverse operation (SmallBasic to LDArray) isn't possible becuase the SmallBasic indexes are not necessarily contiguous integers.
Note also that a SmallBasic array cannot hold an empty string value, so these will not be copied.

array The array name.
returns The SmallBasic array or "FAILED".

Count(array)
Get the number of non-empty "" elements in the array.
array The array name.
returns The number of non-empty values in the array.

Create(maxSize)
Create a new array (can be used for numbers or character strings).
maxSize The maximum number of elements in the array.
returns The array name or "FAILED".

CreateFromIndices(sbArray)
Create a new array from the indices of a Small Basic array.
sbArray The SB array.
returns The new array or "FAILED".

CreateFromValues(sbArray)
Create a new array from the values of a Small Basic array.
sbArray The SB array.
returns The new array or "FAILED".

Delete(array)
Delete an existing array (not generally required, but can save memory if lots of arrays are created).
array The array name.
returns "FAILED" or "" for success.

GetIndex(sbArray,value)
Get the index of the first occurance of a value in an SB array.
sbArray The SB array.
value The value to find.
returns The index of value in the array, "" if not present or "FAILED".

GetValue(array,index)
Get value in array.
array The array name.
index The index at which to get the value (indexed starting from 1).
returns The value or "FAILED".

Load(array,fileName)
Load an array from a file.
array The array to load the data into.
The array must already exist.

fileName The file path to load the array from.
returns The number of elements loaded.

Save(array,fileName)
Save an array to a file.
array The array to save.
fileName The file path to save the file to.
returns The number of elements saved.

Search(array,searchstring,match)
Obtain an array of the indices that have values that contain searchstring.
The search is case in-sensitive.
The input array is unchanged and the match array must be previously created with the same size as the array to check.

array The array to check for matches.
searchstring The string to search for.
match An array to hold the index of matched values.
returns The number of matches found.

SetValue(array,index,value)
Set value in array.
array The array name.
index The index at which to add the value (indexed starting from 1).
value The value.
returns "FAILED" or "" for success.

Sort(array)
Perform a sort on an LDArray.

By default the sort is by string value, therefore 10 comes before 2.
To sort by number value, all values must be a number (or empty).

Empty values are placed at the end of the sort.
The input array is replaced by the sorted array.

array The array to sort.
returns "FAILED" or "" for success.

SortIndex(array,index)
Obtain an array of the indices in sort order of an array.

By default the sort is by string value, therefore 10 comes before 2.
To sort by number value, all values must be a number (or empty).

Empty values are placed at the end of the sort.
The input array is unchanged and the index array must be previously created with the same size as the array to sort.

array The array to obtain an index order sort.
index An array to hold the index order of the sorted array.
returns "FAILED" or "" for success.

LDBits
Bitwise logic to store binary flags in a single number as bits.
A 32 bit number is used internally.
This is like a 32 dimension array of 1s and 0s stored in single number.
The bits (1 to 32) are indexed from 1.


AndBits GetBit GetBits
Not OrBits SetBit
UnsetBit XOrBits

AndBits(var1,var2)
Logically And 2 numbers.
var1 The first number.
var2 The second number.
returns The And number (where both input bits are set).

GetBit(var,bit)
Get the bit value in a number.
var The number to test.
bit A bit to test (1 to 32).
returns 0 (unset) or 1 (set).

GetBits(var)
Get an array of bit values.
var The number to get the bits.
returns A 32 dimension array of bits (0 or 1).

Not(var)
Logically Not a number.
var The number to Not.
returns The Not number (all bits reversed).

OrBits(var1,var2)
Logically Or 2 numbers.
var1 The first number.
var2 The second number.
returns The Or number (where either input bits are set).

SetBit(var,bit)
Set a bit in a number.
var The number to set the bit.
bit A bit to set (1 to 32).
returns The modified number with bit set.

UnsetBit(var,bit)
Unset a bit in a number.
var The number to unset the bit.
bit A bit to unset (1 to 32).
returns The modified number with bit unset.

XOrBits(var1,var2)
Logically XOr 2 numbers.
var1 The first number.
var2 The second number.
returns The XOr number (where exclusively either input bits are set).

LDBlueTooth
BlueTooth control.
The Advanced features refer to non file transfer (effectively writing a device driver).
To communicate with a USB bluetooth stick you also need have an external bluetooth device, setting it to be dicoverable etc before running your SmallBasic program.


Connect DataAvailable Device
Encode GetDevices GetEncodings
GetServices Initialise InRange
LastDevice LastError OutOfRange
ReceiveData ReceiveFile SendData
SendFile Service

Connect()
Advanced feature.
Connect an external device and service to the bluetooth USB stick.
You must first Initialise, then set the device, service and encoding.

returns "True" or "False" on success or failure.

DataAvailable
The number of bytes of data received and waiting to be read.
This could be used in a Timer to check for data received.


Device
The current bluetooth device.

Encode
Advanced feature.
The current bluetooth data encoding.


GetDevices()
Get a list of discovered bluetooth devices.
returns An array of devices or "" on failure.

GetEncodings()
Advanced feature.
Get a list of available encodings.

returns An array of encodings or "" on failure.

GetServices()
Advanced feature.
Get a list of available service protocols.

returns An array of services or "" on failure.

Initialise()
Initialise a bluetooth USB stick and detect discoverable external devices.
As devices come into or out of range the devices list is updated.

returns "True" or "False" for success or failure configuring a bluetooth interface.

InRange
Event when a bluetooth device comes in range.
Seems to keep firing unexpectedly.


LastDevice
The last device in or out of range.

LastError
Get the last error message.
Error messages may be set for various failures.


OutOfRange
Event when a bluetooth device goes out of range.
Doesn't seem to work as expected.


ReceiveData()
Advanced feature.
Receive (fetch) data from a bluetooth device.
The device must be Initialised and Connected.
The encoding should also be set.

returns String of received characters or "" on failure.

ReceiveFile(fileName)
Receive (fetch) a file from an attached external bluetooth device.
You must first Initialise, then set the device.

fileName The location to save the received file.
returns A result status message "True" or "False".

SendData(data)
Advanced feature.
Send data to a bluetooth device.
The device must be Initialised and Connected.
The encoding should also be set.

data A string of characters to send.
returns A result status message "True" or "False".

SendFile(fileName)
Send a file to an attached external bluetooth device.
You must first Initialise, then set the device.

fileName The file to send.
returns A result status message "True" or "False".

Service
Advanced feature.
The current bluetooth service.


LDCall
Call Functions with arguments, asyncronously from any extension or from a pre-compiled SmallBasic exe.

CallAsync CallComplete CallInclude
Compile Function Function2
Function3 Function4 Function5
Include LastCall LastResult

CallAsync(dll,extension,obj,method,arguments)
Call any extension method asynchronously.
See example LDCallAsync.
If dll, extension, obj and arguments are all "", then method may be a subroutine in your SmallBasic program.

dll The extension dll (e.g. "LitDev.dll" or "SmallBasicLibrary.dll").
extension The extension namespace (usually the same as the dll name, e.g. "LitDev" or "MicroSoft.SmallBasic.Library" for SmallBasicLibrary.dll).
obj The extension object name.
method The extension method name.
arguments An array of arguments or "" for none. A single argument doesn't have to be in an array.
returns "PENDING" or an error message on failure.

CallComplete
Event when an asynchronous subroutine method call completes.

CallInclude(include,method)
Call a method in an included pre-compiled file.
include The include file name returned by Include method.
method The subroutine name to call in the included exe.
returns "SUCCESS" or "FAILED".

Compile(path)
Compile a secondary Small Basic file.
Assumes that Small Basic is installed in the default location for your OS.

path A Small Basic file to compile (.sb).
returns The path of the compiled file (.exe) or "" on failure.

Function(funcName,arg1)
Call a Small Basic Sub as a function with one input argument.

The input arguments(s) will be copied to an array called "args".
The result should be put in a variable (may be an array) called "return".
The variable "args" should be set to "" at the start of the program.
The input parameter(s) are unchanged, while "args" and "return" are set to "" on return.

funcName The Small Basic Sub name.
arg1 An input value (may be an array).
returns The result of the function held in optional variable "return" or an error message.

Function2(funcName,arg1,arg2)
Call a Small Basic Sub as a function with two input arguments.

See Function for more details.

funcName The Small Basic Sub name.
arg1 1st input value (may be an array).
arg2 2nd input value (may be an array).
returns The result of the function held in variable "return" or an error message.

Function3(funcName,arg1,arg2,arg3)
Call a Small Basic Sub as a function with three input arguments.

See Function for more details.

funcName The Small Basic Sub name.
arg1 1st input value (may be an array).
arg2 2nd input value (may be an array).
arg3 3rd input value (may be an array).
returns The result of the function held in variable "return" or an error message.

Function4(funcName,arg1,arg2,arg3,arg4)
Call a Small Basic Sub as a function with four input arguments.

See Function for more details.

funcName The Small Basic Sub name.
arg1 1st input value (may be an array).
arg2 2nd input value (may be an array).
arg3 3rd input value (may be an array).
arg4 4th input value (may be an array).
returns The result of the function held in variable "return" or an error message.

Function5(funcName,arg1,arg2,arg3,arg4,arg5)
Call a Small Basic Sub as a function with five input arguments.

See Function for more details.

funcName The Small Basic Sub name.
arg1 1st input value (may be an array).
arg2 2nd input value (may be an array).
arg3 3rd input value (may be an array).
arg4 4th input value (may be an array).
arg5 5th input value (may be an array).
returns The result of the function held in variable "return" or an error message.

Include(path)
Reference a previously compiled program to use a subroutine method from.
path The full path to a secondary compiled Small Basic program to use (.exe)
returns A name for the include file or "" on failure.

LastCall
The last asynchronous call name.

LastResult
The last asynchronous call return value.

LDChart
Chart control.

AddChart ColourMap DoughnutFraction
Highlight HighlightDuration LastChart
LastLabel Legend Properties
SetData Update ValueClicked

AddChart(width,height)
Create a chart control.
The current GraphicsWindow.BackgroundColor will be used for the background.
The current GraphicsWindow.PenColor and Font properties will be used for the label text.
For Example:
GraphicsWindow.FontName = "Segoe UI"
GraphicsWindow.FontBold = "False"

width The width of the chart.
height The height of the chart.
returns The chart shape name.

ColourMap(chartName,hue,saturation,lightness,hsl,start,end,centralColour)
Set colour mapping for the chart.
chartName The chart name.
hue A hue (colour 0 to 360), default 0 (red).
saturation A saturation (intensity 0 to 1), default 0.5.
lightness A lightness (brightness 0 to 1), default 0.5.
hsl The parameter to change for different segments, options are:
"Hue" (default) rainbow colours
"Saturation" increasing intensity of colour
"Lightness" increasing brightness

start Starting value for colour variation in the range [0 to 1], default 0.
end Ending value for colour variation in the range [0 to 1], default 1.
centralColour An optional circular gradient color centered on chart, default "".

DoughnutFraction
Radius fraction removed for doughnut chart, default 0.7.

Highlight(chartName,label,fraction)
Highlight a chart value (move segment out).
chartName The chart name.
label The segment label.
fraction A fraction of the radius to move segment out (0 to return it).

HighlightDuration
Time in ms for Highlight animations, default 100.

LastChart
The last clicked chart.

LastLabel
The last clicked chart segment label.

Legend(chartName,scale,legend,background)
Set legend properties.
chartName The chart name.
scale A scale factor for the legend and text labels, default 1
legend A legend style, options are:
"None" no legend
"Legend" separate legend
"Overlay" names overlaying chart
"Percent" percentages overlaying chart
"Legend_Percent" (default) separate legend and percentages overlaying chart
"

background The legend label text background is coloured, "True" or "False" (default).

Properties(chartName,style,scale)
Set chart properties.
chartName The chart name.
style A style for the chart, options are:
"Pie" (default)
"Doughnut"
"Bubble"
"Bar"
"Column"

scale A scale factor for the chart, default 1.

SetData(chartName,data)
Set data for a chart.
chartName The chart name.
data The data to set, which is a 1D array, indices are item names.
Example:
data["Fred"] = 25
data["Mary"] = 15
data["John"] = 40


Update(chartName)
Redraw (update) a chart.
This restores any highlighted segments or applies any modified chart properties.

chartName The chart name.

ValueClicked
Event when a chart segment is clicked.

LDClient
Server and Client communication between computers.
Separate programs are required for the server and client - this is for the client.


CheckServer CloseDelay Connect
Disconnect Disconnected GetClients
LastServerMessage Name SendMessage
ServerMessage UpdateDynamic UpdateStatic

CheckServer(server)
Test if a server is available for connection.
Do not call this method at a high frequency (> 1 per second).

server The server connection ip:port (e.g. "192.168.1.60:100").
This value is returned by LDServer.Start.

returns "AVAILABLE" or "UNAVAILABLE"

CloseDelay
A delay in ms (default 100) when disconnecting to allow a message to be sent before connection closed (Disconnect).
This delay should also be set for the server in LDServer.CloseDelay.


Connect(server,auto)
Connect to a server.
server The server connection ip:port (e.g. "192.168.1.60:100").
This value is returned by LDServer.Start.

auto Enable auto message passing "True" or "False".
If this is used (recommended) then all client data is passed via server to all other clients,
and no processing of send and receive events is required.
The data is updated to arrays of data (indexed by client name) that is returned from the Update methods.
The auto option should be the same for server and all clients.

returns "SUCCESS", "FAILED" or "ALREADY_CONNECTED"

Disconnect()
Disconnect the client from the server.
returns "SUCCESS", "FAILED" or "NOT_CONNECTED"

Disconnected
Event when server disconnects this client.

GetClients()
Get a list of current connected clients.
returns An array of current client names or "" for none.

LastServerMessage
The last server message.

Name
This client's name.
Get or set your name.


SendMessage(message)
Send a message to the server.
message The message may be any variable including an array.
returns "SUCCESS", "FAILED" or "NOT_CONNECTED"

ServerMessage
Event when the server sends a message to this client.

UpdateDynamic(data)
Update client data when using the auto message passing.
This is for small quantities of frequently changing data, like sprite coordinates.
this method uses the last updated client data stored on the client and is therefore fast.

data The data for this client to propagate to other clients.
returns An array indexed by client names with current data for all existing clients.

UpdateStatic(data)
Update client data when using the auto message passing.
This is for larger quantities of infrequently changing data, like client configuration.
This method uses data stored and retrieved from the server so may be slower than UpdateDynamic since it waits for server retreived data,
guaranteeing that all client data is fully synced.

data The data for this client to propagate to other clients.
returns An array indexed by client names with current data for all existing clients.

LDClipboard
Clipboard methods.

Clear ClipboardChanged GetFileList
GetImage GetText ImageTransparency
SetFileList SetImage SetText

Clear()
Clear the clipboard;
returns "SUCCESS" or "FAILED".

ClipboardChanged
Event when the clipboard status changes.

GetFileList()
Get an array of file names from the clipboard.
returns An array of files or "FAILED".

GetImage()
Load an image from the clipboard into ImageList.
returns The ImageList name or "FAILED".

GetText()
Get text from the clipboard.
returns The clipboard text or "FAILED".

ImageTransparency
Use an extended format for SetImage that includes transparency ("True" default or "False").
This extended format may not be recognised by some applications when pasted.


SetFileList(fileList)
Set a list of files to the clipboard.
fileList An array (or single file) of file names (full path).
returns "SUCCESS" or "FAILED".

SetImage(imageName)
Set an ImageList image to the clipboard.
imageName The ImageList image.
returns "SUCCESS" or "FAILED".

SetText(text)
Set text to the clipboard.
text The text to add to the clipboard.
returns "SUCCESS" or "FAILED".

LDColours
Gets the Standard SmallBasic colours and other colour utilities.

GetBlue GetGreen GetHue
GetLightness GetOpacity GetRed
GetSaturation HSLtoRGB SetOpacity

GetBlue(colour)
Get the Blue component of a colour.
colour The colour to get the component from.
returns The blue component (0 to 255).

GetGreen(colour)
Get the Green component of a colour.
colour The colour to get the component from.
returns The green component (0 to 255).

GetHue(colour)
Get the Hue component of a colour.
colour The colour to get the component from.
returns The hue component (0 to 360).

GetLightness(colour)
Get the Lightness component of a colour.
colour The colour to get the component from.
returns The lightness component (0 to 1).

GetOpacity(colour)
Get the Opacity component of a colour.
colour The colour to get the component from.
returns The opacity component (0 to 255).

GetRed(colour)
Get the Red component of a colour.
colour The colour to get the component from.
returns The red component (0 to 255).

GetSaturation(colour)
Get the Saturation component of a colour.
colour The colour to get the component from.
returns The saturation component (0 to 1).

HSLtoRGB(H,S,L)
Convert a Hue, Saturation, Lightness (HSL) color to a Red, Green, Blue (RGB) colour used by SmallBasic.
H Hue (0 to 360).
S Saturation (0 to 1).
L Lightness (0 to 1).
returns An RGB colour

SetOpacity(colour,opacity)
Modify the opacity of a colour.
colour The colour to modify.
opacity The opacity (0 to 255).
returns The modified colour.

LDCommPort
Sends and receives data over the serial port
Original Code by Nino Carrillo


AvailablePorts ClosePort DataReceived
ErrorReceived LastError LastPort
OpenPort RXAll RXByte
RXChar SetDataBits SetEncoding
SetHandshake SetParity SetStopBits
SwapPort TXByte TXString

AvailablePorts()
Returns a list of available serial ports.
returns An array containing the names of available serial ports.

ClosePort()
Closes the open serial port.
returns "SUCCESS", "NOCONNECTION" or "FAILED".

DataReceived
Event when the serial port receives data.

ErrorReceived
Event when the serial port receives an error.

LastError
The last error for which an error event was raised.

LastPort
The last port name for which an event was raised.

OpenPort(portName,baudRate)
Opens a serial port for use. Assumes 8 databits, no parity.
portName String identifying which port to open in the form of "COM8".
baudRate Integer baud rate, for example 9600.
returns Error message, "SUCCESS", "NOSERIALPORTS", "PORTNOTFOUND" or "CONNECTIONFAILED".

RXAll()
Reads all available bytes in the open comm port input buffer.
returns Returns a string of bytes ("NOCONNECTION" or "FAILED" on failure).

RXByte()
Reads one byte from the open serial port and returns that byte as an integer.
returns One integer value between 0 and 255 ("NOCONNECTION" or "FAILED" on failure).

RXChar()
Reads one byte from the open serial port and returns that byte as a unicode character.
returns One unicode character ("NOCONNECTION" or "FAILED" on failure).

SetDataBits(dataBits)
Sets current port data bits.
5 to 8 (default).

dataBits The data bits:
5 to 8 (default).

returns "SUCCESS", "NOCONNECTION" or "FAILED".

SetEncoding(encoding)
Sets current port encoding for send and receive text conversion.
encoding The encoding:
"Ascii" (default), "Unicode", "UTF7", "UTF8", "UTF32" or "BigEndianUnicode".

returns "SUCCESS", "NOCONNECTION" or "FAILED".

SetHandshake(handshake)
Sets or clears hardware flow control for the current port.
handshake "H" to select hardware flow control, "HX" for hardware and software flow control, "X" for software fow control, any other character to clear.
returns "SUCCESS", "NOCONNECTION" or "FAILED".

SetParity(parity)
Sets current port parity.
parity The parity:
"None" (default), "Even", "Mark", "Odd" or "Space".

returns "SUCCESS", "NOCONNECTION" or "FAILED".

SetStopBits(stopBits)
Current port stop bits.
stopBits The stop bits:
"One" (default), "None", "OnePointFive" or "Two".

returns "SUCCESS", "NOCONNECTION" or "FAILED".

SwapPort(portName)
Switch the current active port to a previously opened port.
portName String identifying a port that is already opened.
returns Error message, "SUCCESS" or "PORTNOTFOUND".

TXByte(dataByte)
Sends one byte to the serial port.
dataByte The byte to be written to the port.
returns "SUCCESS", "NOCONNECTION" or "FAILED".

TXString(dataString)
Sends a string to the serial port.
dataString String value to be sent.
returns "SUCCESS", "NOCONNECTION" or "FAILED".

LDController
Get input from one or more USB attached game controllers (e.g. gamepad or joystick). If there is more than 1 attached device, then they are numbered from 1.

SlimDX runtme for .Net 4.0 requires to be installed before this object can be used (http://slimdx.org/download.php).


Buttons Count Position
POV Rotation Sliders

Buttons(controller)
Get the pressed state of controller buttons.
controller A USB attached controller number (e.g. joystick or gamepad) indexed from 1.
returns An array of button states ("True" or "False")

Count
Get the number of attached controllers.

Position(controller)
Get the position of a controller joystick.
controller A USB attached controller number (e.g. joystick or gamepad) indexed from 1.
returns An array of (X,Y,Z) position values (-100 to 100)

POV(controller)
Get the POV (Point Of View) of controller.
controller A USB attached controller number (e.g. joystick or gamepad) indexed from 1.
returns An array of (X,Y,Z) POV values (degrees)

Rotation(controller)
Get the rotation of a controller joystick.
controller A USB attached controller number (e.g. joystick or gamepad) indexed from 1.
returns An array of (X,Y,Z) rotation values (-100 to 100)

Sliders(controller)
Get the slider position of controller sliders.
controller A USB attached controller number (e.g. joystick or gamepad) indexed from 1.
returns An array of slider positions (0 to 100)

LDControls
Controls for the GraphicsWindow.

AddBrowser AddCheckBox AddComboBox
AddContextMenu AddDataView AddDocumentViewer
AddListBox AddListView AddMediaPlayer
AddMenu AddPasswordBox AddProgressBar
AddRadioButton AddRichTextBox AddSlider
AddTreeView AllowDrop BrowserHistory
BrowserNavigate BrowserPageLoaded BrowserSetURL
CheckBoxChanged CheckBoxGetState CheckBoxState
ComboBoxContent ComboBoxGetSelected ComboBoxItemChanged
ComboBoxSelect ContextMenuClicked DataViewAllowSort
DataViewAllowUserEntry DataViewButtonClicked DataViewCellValueChanged
DataViewClear DataViewColAlignment DataViewColumnReadOnly
DataViewColumnSort DataViewColumnVisible DataViewColumnWidths
DataViewDeleteRow DataViewGetFocus DataViewGetRow
DataViewGetSelected DataViewGetValue DataViewReadFromCSV
DataViewRowColours DataViewRowCount DataViewSaveAsCSV
DataViewSelectionChanged DataViewSetColumnButton DataViewSetColumnCheckBox
DataViewSetColumnComboBox DataViewSetFocus DataViewSetRow
DataViewSetValue DocumentViewerLoadXPS FileDropped
LastBrowser LastBrowserPage LastCheckBox
LastCheckBoxState LastComboBox LastComboBoxIndex
LastContextControl LastContextItem LastDataBaseTable
LastDataView LastDataViewButtonClicked LastDataViewCellValueChanged
LastDropFiles LastDropShape LastListBox
LastListBoxIndex LastListView LastListViewColumn
LastListViewRow LastMediaPlayer LastMenuControl
LastMenuItem LastPassword LastPasswordBox
LastRadioButton LastRadioButtonGroup LastRichTextBox
LastSlider LastSliderValue LastTreeView
LastTreeViewIndex ListBoxContent ListBoxGetSelected
ListBoxItemChanged ListBoxSelect ListBoxSelectionMode
ListViewClear ListViewColAlignment ListViewDeleteRow
ListViewEdit ListViewGetRow ListViewRowCount
ListViewSelectionChanged ListViewSetRow MediaPlayerEnded
MediaPlayerLoad MediaPlayerOpened MediaPlayerPause
MediaPlayerPlay MediaPlayerPlayTime MediaPlayerPosition
MediaPlayerSeek MediaPlayerSpeed MediaPlayerStop
MediaPlayerStretch MediaPlayerVolume MenuBackground
MenuChecked MenuClicked PasswordEntered
ProgressBarValue RadioButtonClicked RadioButtonGet
RadioButtonSet RichTextBoxCaseSensitive RichTextBoxClear
RichTextBoxDefault RichTextBoxFontBackground RichTextBoxFontBold
RichTextBoxFontFamily RichTextBoxFontForeground RichTextBoxFontItalic
RichTextBoxFontSize RichTextBoxFontUnderline RichTextBoxGetText
RichTextBoxIndentToTab RichTextBoxLoad RichTextBoxMargins
RichTextBoxReadOnly RichTextBoxSave RichTextBoxSelection
RichTextBoxSetText RichTextBoxTextAlignment RichTextBoxTextTyped
RichTextBoxWord SetButtonStyle SetCursorPosition
SetCursorToEnd SetSpellCheck SliderChanged
SliderGetValue SliderMaximum SliderValue
TextBoxReadOnly TextBoxTab TreeViewContent
TreeViewEdit TreeViewExpand TreeViewGetData
TreeViewGetSelected TreeViewItemChanged TreeViewSelect

AddBrowser(width,height,url)
Add a web browser.
width The browser width.
height The browser height.
url The html pane to load (e.g. http://smallbasic.com or www.google.com)
returns The browser control name.

AddCheckBox(title)
Add a checkbox dialog control.
title The title of the control.
returns The checkbox shape name.

AddComboBox(list,width,height)
Add a combobox dialog control.
list An array containing the combobox data.

The first index is the row or node number and the value of the array is the display text at the current node.

list[1] = "Option 1"
list[2] = "Option 2"
list[3] = "Option 3"
list[4] = "Option 4"

width The width of the control.
height The drop down height of the control.
returns The combobox shape name.

AddContextMenu(shapeName,items,images)
Add a right click context menu for a control or shape that supports context menus.
shapeName The control or shape name.
items An array of context menu item selection texts.
images Optional array of image icons, any or all may be "".
They may be the result of ImageList.LoadImage or local or network image file.


AddDataView(width,height,headings)
Add a dataview control.
All rows and columns are indexed from 1.
This control always appears on top of all other objects in the GraphicsWindow.

width The width of the control.
height The height of the control.
headings An array of headings for the dataview.
returns The dataview shape name.

AddDocumentViewer(width,height)
Add a document viewer dialog control.
You can view XPS documents (MS version of PDF) with this.
Drag and drop is auto set for this control.

width The width of the control.
height The height of the control.
returns The document viewer shape name.

AddListBox(list,width,height)
Add a listbox dialog control.
list An array containing the listbox data.

The first index is the row or node number and the value of the array is the display text at the current node.

list[1] = "Option 1"
list[2] = "Option 2"
list[3] = "Option 3"
list[4] = "Option 4"

Alternatively, this can be a LDArray or LDList.

width The width of the control.
height The height of the control.
returns The listbox shape name.

AddListView(width,height,headings)
Add a ListView control.
width The width of the control.
height The height of the control.
headings An array of headings for the listview.
returns The listview shape name.

AddMediaPlayer(width,height)
Add a media player (to play videos etc).
Drag and drop is auto set for this control.

width The media player width.
height The media player height.
returns The media player control name.

AddMenu(width,height,menuList,iconList,checkList)
Add a menu control.
width The width of the control.
height The height of the control.
menuList An array of menu items. The index is the menu display name and the value is the parent display name.
The top level display name should be "Main". The names should be unique since they will be returned on click event.
A separator is "-", "--", "---" etc since they have to be unique and cannot be selected.

menuList["File"] = "Main"
menuList["Open"] = "File"
menuList["-"] = "File"
menuList["Exit"] = "File"
menuList["Help"] = "Main"
menuList["Show Help"] = "Help"

iconList An optional array of icon images (URL or ImageList) or "" for none.

iconList["File"] = Program.Directory+"/file.png"

checkList An optional array to identify items as checkable or "" for none.
The value is the initial checked state "True" or "False".

checkList["Show Help"] = "True"

returns The menu shape name.

AddPasswordBox(width,height,length)
Add a password box control (texbox with characters not displayed and PasswordEntered event only when return is pressed).
width The width of the control.
height The height of the control.
length The maximum number of characters in the password.
returns The password box shape name.

AddProgressBar(width,height,orientation)
Add a progress bar control.
width The width of the control.
height The height of the control.
orientation Horizontal or vertical ("H" or "V").
returns The progress bar shape name.

AddRadioButton(title,group)
Add a radio button control.
Only one radio button in a group can be set (they are exclusive).

title A text description for the radio button.
group A name to group radio buttons.
returns The radio button shape name.

AddRichTextBox(width,height)
Add a RichTextBox.
Drag and drop is auto set for this control.

width The width of the RichTextBox.
height The height of the RichTextBox.
returns The RichTextBox name.

AddSlider(width,height,orientation)
Add a slider control.
width The width of the control.
height The height of the control.
orientation Horizontal or vertical ("H" or "V").
returns The slider shape name.

AddTreeView(tree,width,height)
Add a treeview dialog control.
tree A 2D array containing the treeview data.

The first index is the row or node number and the second index is the parent node of the current node (0 for top level).
The value of the array is the display text at the current node.

tree[1][0] = "Level 1"
tree[2][1] = "Level 1 1"
tree[3][1] = "Level 1 2"
tree[4][0] = "Level 2"

width The width of the control.
height The height of the control.
returns The treeview shape name.

AllowDrop(shapeName)
Set shape to allow drag and drop.
Currently only the following are implemented without using FileDropped event to process the dropped file(s):
File path to TextBox (or file paths to MultiLineTextBox).
File opened in RichTextBox.
XPS file opened in DocumentViewer.
Image set in Image or Background.
Media for MediaPlayer (only works if valid media is already loaded).

shapeName The shape to allow drop or "Background".

BrowserHistory(shapeName)
Get an array of the browser history (pages loaded).
shapeName The browser name.
returns The array of urls in the history.

BrowserNavigate(shapeName,direction)
Move browser page forward or backwards.
shapeName The browser name.
direction "F" or "B" for forwards or backwards.

BrowserPageLoaded
Event when a browser page is loaded.

BrowserSetURL(shapeName,url)
Set a web browser page.
shapeName The browser name.
url The html pane to load (e.g. http://smallbasic.com or www.google.com)

CheckBoxChanged
Event when a checkbox is clicked.

CheckBoxGetState(shapeName)
Get a checkbox checked state.
shapeName The checkbox to get state.
returns The checkbox checked state.

CheckBoxState(shapeName,state)
Set a checkbox checked state.
shapeName The checkbox shape name.
state The checkbox check state ("True" or "False").

ComboBoxContent(shapeName,list)
Replace a combobox list.
shapeName The combobox shape name.
list An array containing the combobox data.

The first index is the row or node number and the value of the array is the display text at the current node.

list[1] = "Option 1"
list[2] = "Option 2"
list[3] = "Option 3"
list[4] = "Option 4"


ComboBoxGetSelected(shapeName)
Get a combobox selected node.
shapeName The combobox to get node.
returns The combobox selected node.

ComboBoxItemChanged
Event when a combobox selection changes or selected item is clicked.

ComboBoxSelect(shapeName,node)
Select a node in a combobox.
shapeName The combobox shape name.
node The node to select.

ContextMenuClicked
Event when a shape or control right click context menu item is selected.

DataViewAllowSort(shapeName,allow)
Allow a dataview control to be column sorted by user clicking header.
shapeName The dataview control.
allow Allow "True" (default) or disallow "False".
returns "SUCCESS" or "FAILED".

DataViewAllowUserEntry(shapeName,allow)
Allow user to add data in the last row.
shapeName The dataview control.
allow Allow user data entry "True" (default) or "False".
returns "SUCCESS" or "FAILED".

DataViewButtonClicked
Event when a dataview button is clicked.

DataViewCellValueChanged
Event when a dataview cell value changes after it is commited, for example by selecting away from the cell.

DataViewClear(shapeName)
Clear all rows in a dataview.
shapeName The dataview control.
returns "SUCCESS" or "FAILED".

DataViewColAlignment(shapeName,col,alignment)
Set the alignment for a dataview column.
shapeName The dataview control.
col The column number.
alignment "Left", "Center" or "Right"
returns "SUCCESS" or "FAILED".

DataViewColumnReadOnly(shapeName,col,readOnly)
Set a dataview column to be read only.
shapeName The dataview control.
col The column number.
readOnly Set as read only "True" or "False" (default).
returns "SUCCESS" or "FAILED".

DataViewColumnSort(shapeName,col,ascending)
Sort dataview entries by a column.
shapeName The dataview control.
col The column number to sort by.
ascending Sort ascending ("True") or descending ("False").
returns "SUCCESS" or "FAILED".

DataViewColumnVisible(shapeName,col,visible)
Set a dataview column to be visible or not.
This may be used for example to hide an id column of a database.

shapeName The dataview control.
col The column number.
visible Set as visible "True" (default) or "False".
returns "SUCCESS" or "FAILED".

DataViewColumnWidths(shapeName,widths)
Set the widths of columns.
shapeName The dataview control.
widths An array of widths for the columns, "" to reset to auto sizing.
returns "SUCCESS" or "FAILED".

DataViewDeleteRow(shapeName,row)
Delete a row from a dataview control.
shapeName The dataview control.
row The row number.
returns "SUCCESS" or "FAILED".

DataViewGetFocus(shapeName)
Get the current dataview cell with focus.
shapeName The dataview control.
returns A 1D array with the row and column number with focus, or "".

DataViewGetRow(shapeName,row)
Get a row of data from a dataview control.
shapeName The dataview control.
row The row number.
returns An array of values (one for each column) or "" on failure.

DataViewGetSelected(shapeName)
Get a list of all selected cells in a dataview.
shapeName The dataview control.
returns A 2D array of rows and columns selected.
cells[1][1] = row, cells[1][2] = column.


DataViewGetValue(shapeName,row,col)
Get a dataview cell value.
shapeName The dataview control.
row The row number.
col The column number.
returns The cell value or "".

DataViewReadFromCSV(shapeName,fileName,append)
Add data from a csv (comma separated values) text file into a dataview control.
shapeName The dataview control.
fileName The full path for the csv file.
append Append to the dataview "True" or "False".
returns "SUCCESS" or "FAILED".

DataViewRowColours(shapeName,row,background,foreground)
Set a row of data background and foreground (pen) colours.
shapeName The dataview control.
row The row number. If this is set to 0 then all alternating rows are set.
background The background colour.
foreground The foreground colour.
returns "SUCCESS" or "FAILED".

DataViewRowCount(shapeName)
Get the number of rows in a dataview control.
shapeName The dataview control.
returns The number of rows in the dataview.

DataViewSaveAsCSV(shapeName,fileName,append)
Write an entire dataview to a csv (comma separated values) text file.
shapeName The dataview control.
fileName The full path for the csv file.
append Append to the csv file "True" or "False".
returns "SUCCESS" or "FAILED".

DataViewSelectionChanged
Event when a dataview selection changes.
This event is not called for dataview button clicks, use DataViewButtonClicked.
This event is not called for dataview checkbox or combobox clicks, use DataViewCellValueChanged.


DataViewSetColumnButton(shapeName,col)
Change a dataview column control to be Buttons.
This should be set before data is added, after the dataview is created.
If the dataview is bound to a database, then set this after LDDataBase.EditTable is set.
The data for these cells will be the button title.

shapeName The dataview control.
col The column number.
returns "SUCCESS" or "FAILED".

DataViewSetColumnCheckBox(shapeName,col)
Change a dataview column control to be CheckBoxes.
This should be set before data is added, after the dataview is created.
If the dataview is bound to a database, then set this after LDDataBase.EditTable is set.
The data for these cells should be "True" or "False".

shapeName The dataview control.
col The column number.
returns "SUCCESS" or "FAILED".

DataViewSetColumnComboBox(shapeName,col,data)
Change a dataview column control to be ComboBoxes with selectable values.
This should be set before data is added, after the dataview is created.
If the dataview is bound to a database, then set this after LDDataBase.EditTable is set.
The values to get and set for the cells are the labels set with the data parameter.

shapeName The dataview control.
col The column number.
data An array of data selections for the combo boxes.
returns "SUCCESS" or "FAILED".

DataViewSetFocus(shapeName,row,col)
Set the focus to a dataview cell.
shapeName The dataview control.
row The row number.
col The column number.
returns "SUCCESS" or "FAILED".

DataViewSetRow(shapeName,row,values)
Add a row of data to a dataview control.
shapeName The dataview control.
row The row number.
If the row number is larger than the current number of rows a new row is added, otherwise the row data is over-written.

values An array of values (one for each column).
returns "SUCCESS" or "FAILED".

DataViewSetValue(shapeName,row,col,value)
Set a dataview cell value.
shapeName The dataview control.
row The row number.
col The column number.
value The value to set.
returns "SUCCESS" or "FAILED".

DocumentViewerLoadXPS(shapeName,fileName)
Load an XPS file to a document viewer dialog control.
shapeName The document viewer control.
fileName The XPS file to load and view.

FileDropped
Event when a file is dropped on an object set with AllowDrop.

LastBrowser
The last browser where a page was loaded.

LastBrowserPage
The last browser page loaded (the url).

LastCheckBox
The last checkbox that was clicked.

LastCheckBoxState
The last checkbox checked state ("True" or "False").

LastComboBox
The last combobox where a selection changed.

LastComboBoxIndex
The last combobox selection changed index (row number).

LastContextControl
The contol or shape of the last right click context menu item selected.

LastContextItem
The index of the last shape or control right click context menu item selected.

LastDataBaseTable
The last database table for which a dataview selection changed.

LastDataView
The last dataview where a selection changed.

LastDataViewButtonClicked
Get the cell row, column and value of the last dataview button clicked.
This is a 3 element array.


LastDataViewCellValueChanged
Get the cell row, column and value of a dataview cell whose value has changed.
This is a 3 element array.


LastDropFiles
An array with the last file(s) that were dropped.

LastDropShape
The last object a file was dropped on.

LastListBox
The last listbox where a selection changed.

LastListBoxIndex
The last listbox selection changed index (row number).

LastListView
The last listview where a selection changed.

LastListViewColumn
The last listview selected column number.

LastListViewRow
The last listview selected row number.

LastMediaPlayer
The last media player for which an event occurred.

LastMenuControl
The last menu control selected.

LastMenuItem
The last menu item selected.

LastPassword
The last password entered.

LastPasswordBox
The password box for which an event occurred.

LastRadioButton
The last radio button that was selected.

LastRadioButtonGroup
The group name for the last radio button selected.

LastRichTextBox
The rich text box for which an event occurred.

LastSlider
The last slider for which an event occurred.

LastSliderValue
The last slider value.

LastTreeView
The last treeview where a selection changed.

LastTreeViewIndex
The last treeview selection changed index (row number).

ListBoxContent(shapeName,list)
Replace a listbox list.
shapeName The listbox shape name.
list An array containing the listbox data.

The first index is the row or node number and the value of the array is the display text at the current node.

list[1] = "Option 1"
list[2] = "Option 2"
list[3] = "Option 3"
list[4] = "Option 4"

Alternatively, this can be a LDArray or LDList.


ListBoxGetSelected(shapeName)
Get a listbox selected node.
shapeName The listbox to get node.
returns The listbox selected node number.
If the selection mode is not single (see ListBoxSelectionMode) then an array of nodes is returned.
The return is "" for no selected nodes.


ListBoxItemChanged
Event when a listbox selection changes or selected item is clicked.

ListBoxSelect(shapeName,node)
Select a node or nodes in a listbox.
shapeName The listbox shape name.
node The node number to select.
This can be an array of nodes if the selection mode is not single (see ListBoxSelectionMode).


ListBoxSelectionMode(shapeName,mode)
Set the selection mode for listbox control.
shapeName The listbox control name.
mode One of the following:
"Single" - single selection (default).
"Multiple" - multiple selections using control key.
"Extended" - extended selections using control and shift keys.


ListViewClear(shapeName)
Remove all rows from a listview control.
shapeName The listview control.

ListViewColAlignment(shapeName,col,alignment)
Set the alignment for a listview column.
shapeName The listview control.
col The column number (indexed from 1).
alignment "Left", "Center" or "Right"

ListViewDeleteRow(shapeName,row)
Delete a row of data from a listview control.
shapeName The listview control.
row The row number (indexed from 1).
If the row number is larger than the current number of rows then no action is taken.


ListViewEdit(shapeName,editable)
Change a listview to editable status.
shapeName The listview shape name.
editable "True" with editable TextBoxes or "False" uneditable TextBlocks.

ListViewGetRow(shapeName,row)
Get a row of data from a listview control.
shapeName The listview control.
row The row number (indexed from 1).
returns An array of values (one for each column) or "" on failure.

ListViewRowCount(shapeName)
Get the number of rows in a listview control.
shapeName The listview control.
returns The number of rows in the listview.

ListViewSelectionChanged
Event when a listview selection changes.

ListViewSetRow(shapeName,row,values)
Add a row of data to a listview control.
shapeName The listview control.
row The row number (indexed from 1).
If the row number is larger than the current number of rows a new row is added, otherwise the row data is over-written.

values An array of values (one for each column).

MediaPlayerEnded
Event when a media player ends playing current media.

MediaPlayerLoad(shapeName,media)
Set the media for a media player.
shapeName The media player name.
media The media to load, e.g. an image, music or video file, jp, mp3, mpg, avi, wmv etc.

MediaPlayerOpened
Event when a media player opens new media.

MediaPlayerPause(shapeName)
Pause a media player playback (using current loaded media).
shapeName The media player name.

MediaPlayerPlay(shapeName)
Start a media player playback (using current loaded media).
shapeName The media player name.

MediaPlayerPlayTime(shapeName)
Get a media play time (using current loaded media).
shapeName The media player name.
returns The media play time in ms.

MediaPlayerPosition(shapeName)
Get a media current position (using current loaded media).
shapeName The media player name.
returns The media current position in ms.

MediaPlayerSeek(shapeName,seek)
Position a media player position (using current loaded media).
shapeName The media player name.
seek The new play position in ms.

MediaPlayerSpeed(shapeName,speed)
Set the playback speed for a media player.
shapeName The media player name.
speed The speed (0 to 100) default 1 (normal playback).

MediaPlayerStop(shapeName)
Stop a media player playback (using current loaded media).
shapeName The media player name.

MediaPlayerStretch(shapeName,stretch)
Set a visual media stretch - how the visual fills its area.
shapeName The media player name.
stretch The stretch method. Available stretch options are:
"None" (The content preserves its original size).
"Uniform" (The content is resized to fit in the destination dimensions while it preserves its native aspect ratio - Default).
"Fill" (The content is resized to fill the destination dimensions. The aspect ratio is not preserved).
"UniformToFill" (The content is resized to fill the destination dimensions while it preserves its native aspect ratio, clipping as required).


MediaPlayerVolume(shapeName,volume)
Set the volume for a media player.
shapeName The media player name.
volume The volume (0 to 1) default 0.5.

MenuBackground(shapeName,colour)
Set the background colour for sub menus.
The main top menu can be coloured separately with LDShapes.BrushColour.
Note that separators are not coloured and it is often best to just colour the top menu.

shapeName The menu shape name.
colour The background colour.

MenuChecked(shapeName,itemName)
Get the check state of a menu item.
shapeName The menu shape name.
itemName The menu item name.
returns "True" or "False".

MenuClicked
Event when a menu item is selected.

PasswordEntered
Event when a password is entered (Return key pressed).

ProgressBarValue(shapeName,value)
Set progress bar value (progress).
shapeName The progress bar shape name.
value The progress value (0 to 100).

RadioButtonClicked
Event when a radio button selection changes (it is clicked).

RadioButtonGet(shapeName)
Get a radio button state.
shapeName The radio button to get state.
returns The radio button state.

RadioButtonSet(shapeName)
Set a radio button to selected.
shapeName The radio button to set.

RichTextBoxCaseSensitive
Whether word or phrase highlighting is case sensitive "True" or "False" (default).
Set this before RichTextBoxWord is called.


RichTextBoxClear(shapeName)
Clear all text from the RichTextBox.
shapeName The RichTextBox control.
returns None.

RichTextBoxDefault(shapeName)
Set a default font style using the current RichTextBox Properties.
Note RichTextBoxFontDecoration not available for this option.

shapeName The RichTextBox control.
returns None.

RichTextBoxFontBackground
The font background colour.
Set this before RichTextBoxSelection, RichTextBoxWord or RichTextBoxDefault is called.


RichTextBoxFontBold
The font bold style "True" or "False".
Set this before RichTextBoxSelection, RichTextBoxWord or RichTextBoxDefault is called.


RichTextBoxFontFamily
The font family e.g. "Century Gothic".
Set this before RichTextBoxSelection, RichTextBoxWord or RichTextBoxDefault is called.


RichTextBoxFontForeground
The font foreground colour.
Set this before RichTextBoxSelection, RichTextBoxWord or RichTextBoxDefault is called.


RichTextBoxFontItalic
The font italic style "True" or "False".
Set this before RichTextBoxSelection, RichTextBoxWord or RichTextBoxDefault is called.


RichTextBoxFontSize
The font point size.
Set this before RichTextBoxSelection, RichTextBoxWord or RichTextBoxDefault is called.


RichTextBoxFontUnderline
The font underline style "True" or "False".
Set this before RichTextBoxSelection, RichTextBoxWord or RichTextBoxDefault is called.


RichTextBoxGetText(shapeName)
Get text (unformatted) in a RichTextBox.
shapeName The RichTextBox control.
returns The text.

RichTextBoxIndentToTab
Convert first character indents to tabs "True" (default) or "False".
A tab typed as a first character on a line in a RichTextBox creates an indent unless this is set to "True".


RichTextBoxLoad(shapeName,fileName,append)
Load text and formatting from a file in rtf format to a RichTextBox.
shapeName The RichTextBox control.
fileName File to load the text and formatting from.
append Append to existing text "True" or "False".
returns None.

RichTextBoxMargins(left,right,top,bottom)
Set margins (in pixels) for RichTextBox paragraphs.
A new paragraph is created for each text appended (or created) using RichTextBoxSetText.

left Left margin (default 0).
right Right margin (default 0).
top Top margin (default 0).
bottom Bottom margin (default 0).

RichTextBoxReadOnly
The read only state for the RichTextBox "True" or "False.
Set this before AddRichTextBox is called.


RichTextBoxSave(shapeName,fileName)
Save RichTextBox text and formatting to a file in rtf format.
shapeName The RichTextBox control.
fileName File to save the text and formatting to.
returns None.

RichTextBoxSelection(shapeName)
Set a font style of selected RichTextBox text using the current RichTextBox Properties.
shapeName The RichTextBox control.
returns None.

RichTextBoxSetText(shapeName,text,append)
Set text (unformatted) in a RichTextBox.
shapeName The RichTextBox control.
text Text to load.
append Append to existing text "True" or "False".
A new paragraph is created if text is appended. See RichTextBoxMargins to set margins for the paragraph.

returns None.

RichTextBoxTextAlignment
The text alignment "Center" "Left" "Right" or "Justify".
Set this before AddRichTextBox is called.


RichTextBoxTextTyped
Event when text is typed into a rich text box.

RichTextBoxWord(shapeName,text,mode)
Set a font style of a word or phrase using the current RichTextBox Properties.
shapeName The RichTextBox control.
text The text to change (Case sensitive set by RichTextBoxCaseSensitive parameter).
mode Contol over which instances of the word or phrase to set.
0 - All instances
1 - First instance
2 - Last instance

returns None.

SetButtonStyle(shapeName,brushUnpressed,brushMouseOver,brushPressed,penUnpressed,penMouseOver,penPressed,radius,shine)
Modify the style of a button.
shapeName The button to modify.
brushUnpressed The colour of the unpressed button, may be a gradient brush.
brushMouseOver The colour of the button when the mouse is over it, may be a gradient brush.
brushPressed The colour of the pressed button, may be a gradient brush.
penUnpressed The text font colour of the unpressed button.
penMouseOver The text font colour of the button when the mouse is over it.
penPressed The text font colour of the pressed button.
radius The button corner radius (default 9).
shine Apply a 'shine' effect, "True" (default) or "False".
returns "SUCCESS" or "FAILED".

SetCursorPosition(shapeName,position)
Set the cursor caret to specified position within a textbox.
shapeName The textbox shape name.
position The cursor character position (0 is before first character or a large value e.g. 1000 will set the cursor to the end).

SetCursorToEnd(shapeName)
Scroll the cursor caret to the end of a textbox or richtextbox.
This is for multi-line textboxes or richtextboxes.

shapeName The textbox shape name.

SetSpellCheck(shapeName,state)
Set the spell checking for a textbox or richtextbox.
shapeName The textbox or richtextbox shape name.
state "True" or "False"

SliderChanged
Event when a slider is changed.

SliderGetValue(shapeName)
Get slider value (position).
shapeName The slider shape name.
returns The slider value (0 to 100).

SliderMaximum
The maximum slider value, default is 100, the minimum is always 0.
Set this before calling AddSlider.


SliderValue(shapeName,value)
Set slider value (position).
shapeName The slider shape name.
value The slider value (0 to 100).

TextBoxReadOnly(shapeName,readOnly)
Set a textbox readonly state.
shapeName The textbox control.
readOnly "True" or "False" (default).

TextBoxTab(shapeName,acceptsTab)
Set whether a TextBox accepts a tab or uses it to locate the next control.
shapeName The TextBox or RichTextBox name.
acceptsTab "True" or "False" (default).

TreeViewContent(shapeName,tree)
Replace a treeview tree.
shapeName The treeview shape name.
tree A 2D array containing the treeview data.

The first index is the row or node number and the second index is the parent node of the current node (0 for top level).
The value of the array is the display text at the current node.

tree[1][0] = "Level 1"
tree[2][1] = "Level 1 1"
tree[3][1] = "Level 1 2"
tree[4][0] = "Level 2"


TreeViewEdit(shapeName,node,editable)
Change a treeview node editable status.
shapeName The treeview shape name.
node The node to select.
editable "True" an editable TextBox or "False" uneditable.

TreeViewExpand(shapeName,node,expand,recursive)
Expand/collapse nodes in a treeview below input node.
shapeName The treeview shape name.
node Node number to expand/collapse, 0 recusively expands/collapses all nodes.
expand Expand or collapse "True" or "False"
recursive Recursively expand/collapse nodes (all children nodes) "True" or "False"

TreeViewGetData(shapeName)
Get the data from a treeview tree.
shapeName The treeview shape name.
returns A 2D array containing the treeview data.

The first index is the row or node number and the second index is the parent node of the current node (0 for top level).
The value of the array is the display text at the current node.

tree[1][0] = "Level 1"
tree[2][1] = "Level 1 1"
tree[3][1] = "Level 1 2"
tree[4][0] = "Level 2"


TreeViewGetSelected(shapeName)
Get a treeview selected node.
shapeName The treeview to get node.
returns The treeview selected node.

TreeViewItemChanged
Event when a treeview selection changes or selected item is clicked.

TreeViewSelect(shapeName,node)
Select a node in a treeview.
shapeName The treeview shape name.
node The node to select.

LDCursors
Sets the GraphicsWindow Cursor.

Arrow ArrowCD CreateCursor
Cross Hand Help
IBeam Invalid None
Pen Scroll SetShapeCursor
SetUserCursor SizeAll SizeNESW
SizeNS SizeNWSE SizeWE
Starting UpArrow Wait

Arrow()
Arrow Cursor (default).

ArrowCD()
Arrow with CD Cursor.

CreateCursor(imageName,xHotSpot,yHotSpot)
Create a cursor that can be set using SetUserCursor or SetShapeCursor.
An ImageList image can be resized with LDImage.Resize.

imageName The file path or ImageList image.
xHotSpot The x pixel to use as the hot spot, indexed from 0.
yHotSpot The y pixel to use as the hot spot, indexed from 0.
returns A cursor.

Cross()
Cross Cursor.

Hand()
Hand Cursor.

Help()
Help Cursor.

IBeam()
IBeam Cursor.

Invalid()
Invalid Cursor.

None()
No Cursor.

Pen()
Pen Cursor.

Scroll()
Scroll Cursor.

SetShapeCursor(shapeName,cursor)
Set the cursor for a shape or control when the mouse is over the shape.
shapeName The shape or control name.
cursor A cursor created with CreateCursor or
a standard cursor in this object (e.g. "ArrowCD") or
the full path to a *.cur or *.ani file to use as a cursor.


SetUserCursor(cursor)
Sets a custom cursor as a pointer in the Graphics Window.
cursor A cursor created with CreateCursor or
a standard cursor in this object (e.g. "ArrowCD") or
the full path to a *.cur or *.ani file to use as a cursor.


SizeAll()
Size All Cursor (Resizing).

SizeNESW()
NESW DoubleArrow Cursor (Resizing).

SizeNS()
NS DoubleArrow (Resizing).

SizeNWSE()
NWSE DoubleArrow Cursor (Resizing).

SizeWE()
WE DoubleArrow (Resizing).

Starting()
Starting Cursor.

UpArrow()
Up Arrow Cursor (Insertion).

Wait()
Wait Cursor.

LDDataBase
SQL Database with ListView control.
ConnectSQLite for SQLite databases (see http://zetcode.com/db/sqlite for SQLite commands).
ConnectMySQL for MySQL databases (see http://www.mysql.com for MySQL downloads and setup).
ConnectSqlServer for SqlServer databases (see for SqlServer downloads and setup).
ConnectOleDb for Access OleDb databases.
ConnectOdbc for Odbc databases.


AddListView Command Connection
ConnectMySQL ConnectOdbc ConnectOleDb
ConnectSQLite ConnectSqlServer EditTable
GetDB Query SaveTable

AddListView(width,height)
Add a ListView to view database query results.
This is a read only display of query results.

width The width of the ListView.
height The height of the ListView.
returns The ListView control.

Command(database,command)
Perform an SQLite, MySQL, SqlServer. OleDb or Odbc command (not a query) on a database.
If this database is viewed in a dataview then unsaved user changes will be lost when the dataview is updated following this operation.

database The existing database label (see ConnectSQLite, ConnectMySQL, ConnectSqlServer, ConnectOleDb or ConnectOdbc).
command The SQL Command.
returns The number of rows updated.

Connection
Over-ride an SQL database connection string (advanced use only).
Set before connection to database, when this connection string will be used in place of the entered connection parameters.
Default is "" (unused).


ConnectMySQL(server,user,password,database)
Connect to a MySQL database.
This must be called before any SQL methods.
The MySQL service must be running and database with credentials already created, if in doubt use SQLite.

server The MySQL server (e.g. "localhost").
user The MySQL user name.
password The MySQL user password.
database The MySQL database name.
returns A label to identify the database.

ConnectOdbc(driver,server,port,user,password,option,database)
Connect to an Odbc driver connected database.
This must be called before any SQL methods.
The Odbc service must be running and database with credentials already created, if in doubt use SQLite.

driver The Odbc driver (e.g. "{MySQL ODBC 3.51 Driver}").
server The Odbc server (e.g. "localhost").
port The Odbc port number.
user The Odbc user name.
password The Odbc user password.
option The Odbc option number to control the Odbc connection (e.g. 0 or 3).
database The Odbc database name.
returns A label to identify the database.

ConnectOleDb(provider,server,database)
Connect to an Access OleDb database.
This must be called before any SQL methods.
The Access OleDb service must be running and database with credentials already created, if in doubt use SQLite.

provider The OleDb provider (e.g. "SQLOLEDB").
server The OleDb server (e.g. "localhost").
database The OleDb database name.
returns A label to identify the database.

ConnectSQLite(fileName)
Create or open an SQLite database.
This must be called before any SQL methods.
When a table is created it must have first column as "Id INTEGER PRIMARY KEY".

fileName The full path to the SQLite database file (usually with extension db).
returns A label to identify the database.

ConnectSqlServer(server,database)
Connect to a SqlServer database.
This must be called before any SQL methods.
The SqlServer service must be running and database with credentials already created, if in doubt use SQLite.

server The SqlServer server (e.g. "(local)\SQLEXPRESS").
database The SqlServer database name.
returns A label to identify the database.

EditTable(database,table,dataview)
Display a database table for editing in a LDControls.DataView control.
Using this method the database is bound to the dataview conrol, reflecting the database.

database The existing database label (see ConnectSQLite, ConnectMySQL, ConnectSqlServer, ConnectOleDb or ConnectOdbc).
table The table name to view and edit.
dataview A DataView control.
returns "SUCCESS" or "FAILED".

GetDB()
Get a read only list of databases for use outside Small Basic.
returns IReadOnlyList

Query(database,query,listview,getRecords)
Perform an SQLite, MySQL, SqlServer, OleDb or Odbc Query (not a command) on a database.
database The existing database label (see ConnectSQLite, ConnectMySQL, ConnectSqlServer, ConnectOleDb or ConnectOdbc).
query The SQL Query.
Example "SELECT * FROM myTable;".

listview A ListView to populate with the query result or "" for none.
getRecords Optionally return an array of results ("True" or "False").
Remember large multi-dimensional arrays in Small Basic are slow.

returns Optional array of results or "".

SaveTable(database,dataview)
Commit any changes made in a LDControls.DataView to the database.
database The existing database label (see ConnectSQLite, ConnectMySQL, ConnectSqlServer, ConnectOleDb or ConnectOdbc).
dataview A DataView control.
returns "SUCCESS" or "FAILED".

LDDateTime
Time and Date conversion.

The date format is "25/01/2012 22:18:52", the time part is optional.
The date part will be dependent on your locale, e.g. in US it will be "01/25/2012 22:18:52".

An OADate is the number of days (and part days) since 30 December 1899, allowing dates to be added or subtracted.


Add FromOADate GetDay
GetDayName GetHour GetMinute
GetMonth GetMonthName GetSecond
GetYear Now NowOADate
OADate Subtract ToOADate

Add(date,offset)
Calculate a date from input date and an offset in days.
date The input date.
offset An offset in days.
returns A date equivalent to the input date + offset.

The format is "25/01/2012 22:18:52", the time part is optional.
The date part will be dependent on your locale, e.g. in US it will be "01/25/2012 22:18:52".


FromOADate(OAdate)
Convert OADate to date string.
OAdate The OADate to convert.

The number of days since 30 December 1899 (OADate).

returns The date string.

The format is "25/01/2012 22:18:52", the time part is optional.
The date part will be dependent on your locale, e.g. in US it will be "01/25/2012 22:18:52".


GetDay(OAdate)
Get day of the month from OADate.
OAdate The OADate.

The number of days since 30 December 1899 (OADate).

returns The month.

GetDayName(OAdate)
Get day of the week from OADate.
OAdate The OADate.

The number of days since 30 December 1899 (OADate).

returns The day name.

GetHour(OAdate)
Get hour from OADate.
OAdate The OADate.

The number of days since 30 December 1899 (OADate).

returns The hour.

GetMinute(OAdate)
Get minute from OADate.
OAdate The OADate.

The number of days since 30 December 1899 (OADate).

returns The minute.

GetMonth(OAdate)
Get month from OADate.
OAdate The OADate.

The number of days since 30 December 1899 (OADate).

returns The month.

GetMonthName(OAdate)
Get month name from OADate.
OAdate The OADate.

The number of days since 30 December 1899 (OADate).

returns The month name.

GetSecond(OAdate)
Get second from OADate.
OAdate The OADate.

The number of days since 30 December 1899 (OADate).

returns The second.

GetYear(OAdate)
Get year from OADate.
OAdate The OADate.

The number of days since 30 December 1899 (OADate).

returns The year.

Now()
The current date and time.
returns The current date and time.

The format is "25/01/2012 22:18:52", the time part is optional.
The date part will be dependent on your locale, e.g. in US it will be "01/25/2012 22:18:52".


NowOADate()
The current OADate.
returns The number of days (and part days) since 30 December 1899 (OADate).

OADate(year,month,day,hour,minute,second)
Create OADate from date and time values.
year The year.
month The month.
day The day.
hour The hour.
minute The minute.
second The second.
returns The number of days (and part days) since 30 December 1899 (OADate).

Subtract(date1,date2)
Calculate a number of days between two dates.
date1 The input date1.
date2 The input date2.
returns The number of days (and part days) between the dates (date1-date2).

ToOADate(date)
Convert date string to OADate.
date The date string to convert.

The format is "25/01/2012 22:18:52", the time part is optional.
The date part will be dependent on your locale, e.g. in US it will be "01/25/2012 22:18:52".

returns The number of days (and part days) since 30 December 1899 (OADate).

LDDebug
Debugging utilities.

Break Instrument Start

Break(label)
Set a break point, where the program will pause and variable values can be viewed.
label An identification label for the breakpoint.
A unique label should be chosen for each breakpoint defined.
There are some known limitations with breakpoints inside event subroutines.


Instrument(fileName)
Create a SmallBasic file (_debug.sb) with break points auto added for each line.

Just open and run the new instrumented file to debug it.
When a problem is found, correct it in your original and re-instrument to debug the corrected file.

fileName The Smallbasic file (*.sb) to instrument.

Start()
Start a debugging session, usually do this as the first line of your program.

Usually you would either set break points manually in your code before running (LDDebug.Break) or auto add breakpoints (LDDebug.Instrument).


LDDialogs
Dialogs and popups.

AddRightClickMenu Calendar Colour
Confirm EndWait Font
GetFolder LastRightClickMenuItem OpenFile
RightClickMenu SaveFile SetStartupPosition
ToolTip Wait

AddRightClickMenu(items,images)
Add a right click context menu for the GraphicsWindow.
items An array of context menu item selection texts.
images Optional array of image icons, any or all may be "".
They may be the result of ImageList.LoadImage or local or network image file.


Calendar(start)
A popup calendar date chooser - double click a date or press return to select a date.
start The initial date in the control, may be "" for today.
returns The selected date.

Colour()
Choose a colour from a dialog.
returns The chosen colour.

Confirm(text,title)
A message dialog with Yes, No and Cancel options.
text Text question for the dialog.
title Title for the dialog.
returns "Yes", "No" or "Cancel"

EndWait()
Close the waiting popup window.
returns None.

Font(font)
Use the font dialog to select a font.
font An array with the initial font selected.
It has the same format as the return array, and can be an empty array "".

returns An array with the font properties.
result[1] is Font name
result[2] is Font size
result[3] is Font bold ("True" or "False")
result[4] is Font italic ("True" or "False")


GetFolder(InitialFolder)
A Dialog to get a folder (directory).
InitialFolder The initial folder or "" for the last folder selected.
returns The full path to the selected folder or "" if none is selected.

LastRightClickMenuItem
The index of the last right click context menu item selected.

OpenFile(extension,folder)
Open File Dialogue (get an existing file).
extension The file type extension, e.g. "sb".
This may also be an array of extension types such as "1=png;2=jpg;".
If the extension contains a "|" character then it will be used directly such as "Images|*.bmp;*.jpg;*.gif;*.png|All files (*.*)|*.*".

folder The initial folder to open dialog with, can be "".
returns The full path of the file.

RightClickMenu
Event when a right click context menu item is selected.

SaveFile(extension,folder)
Save File Dialogue (get a new file).
extension The file type extension, e.g. "sb".
This may also be an array of extension types such as "1=png;2=jpg;".
If the extension contains a "|" character then it will be used directly such as "Images|*.bmp;*.jpg;*.gif;*.png|All files (*.*)|*.*".

folder The initial folder to open dialog with, can be "".
returns The full path of the file.

SetStartupPosition(x,y,mode)
Set the startup coordinates (top left) for most dialoges. This should be set before the dialog is called.
x The X coordinate.
y The X coordinate.
mode The mode which is one of the following
0 : Off (default)
1 : The coordinates are relative to the graphics window, equivalent to GraphicsWindow.MouseX/Y.
2 : The coordinates are relative to the display window, equivalent to Desktop.MouseX/Y


ToolTip(shapeName,tip)
Set a tooltip popup for common shapes and controls.
shapeName The shape or control.
tip The text content of the tooltip.
returns None.

Wait(text,colour)
Create a waiting popup window with a text message.
text The text to display in the popup window.
colour The colour of the popup window border, may be "" for default.
returns None.

LDDictionary
This class provides access to an online Dictionary service.
Alternative for Version 1.0 Dictionary object that fails.


GetDefinition GetDefinitionInFrench GetDefinitionInSpanish

GetDefinition(word)
Gets the definition of a word, in English.
word The word to define.
returns The definition(s) of the specified word.

GetDefinitionInFrench(word)
Gets the definition of a word, in French.
word The word to define.
returns The definition(s) of the specified word.

GetDefinitionInSpanish(word)
Gets the definition of a word, in Spanish.
word The word to define.
returns The definition(s) of the specified word.

LDEffect
Apply visual effects to any shape or control.

Bloom Blur Clear
ColourTone DropShadow Embossed
Magnify Monochrome Pixelate
Ripple Sharpen Swirl

Bloom(shapeName,properties)
Apply a bloom effect.
shapeName The shape to apply the effect to.
properties An array of optional ("" for none) properties, indexed by the property name:
BaseIntensity (default 1)
BaseSaturation (default 1)
BloomIntensity (default 1.25)
BloomSaturation (default 1)
Threshold (default 0.25)


Blur(shapeName,properties)
Apply a blur effect.
shapeName The shape to apply the effect to.
properties An array of optional ("" for none) properties, indexed by the property name:
KernelType (default "Gaussian" or "Box")
Radius (default 5)


Clear(shapeName)
Clear effects.
shapeName The shape to clear the effects from.

ColourTone(shapeName,properties)
Apply a colour tone effect.
shapeName The shape to apply the effect to.
properties An array of optional ("" for none) properties, indexed by the property name:
Desaturation (default 0.5)
ToneAmount (default 0.5)
LightColor (default "#FFE580")
DarkColor (default "#338000")


DropShadow(shapeName,properties)
Apply a drop shadow effect.
shapeName The shape to apply the effect to.
properties An array of optional ("" for none) properties, indexed by the property name:
BlurRadius (default 5)
Color (default "Black")
Direction (default 315)
Opacity (default 1)
ShadowDepth (default 5)


Embossed(shapeName,properties)
Apply an embossed effect.
shapeName The shape to apply the effect to.
properties An array of optional ("" for none) properties, indexed by the property name:
Amount (default 3)
Color (default "Gray")
Height (default 0.001)


Magnify(shapeName,properties)
Apply a magnify effect.
shapeName The shape to apply the effect to.
properties An array of optional ("" for none) properties, indexed by the property name:
Amount (default 0.5)
Center (default "X=0.5;Y=0.5;")
InnerRadius (default 0.2)
OuterRadius (default 0.4)


Monochrome(shapeName,properties)
Apply a monochrome effect.
shapeName The shape to apply the effect to.
properties An array of optional ("" for none) properties, indexed by the property name:
Color (default "White")


Pixelate(shapeName,properties)
Apply a pixelate effect.
shapeName The shape to apply the effect to.
properties An array of optional ("" for none) properties, indexed by the property name:
Pixelation (default 0.75)


Ripple(shapeName,properties)
Apply a ripple effect.
shapeName The shape to apply the effect to.
properties An array of optional ("" for none) properties, indexed by the property name:
Center (default "X=0.5;Y=0.5;")
Frequency (default 40)
Magnitude (default 0.1)
Phase (default 10)


Sharpen(shapeName,properties)
Apply a sharpen effect.
shapeName The shape to apply the effect to.
properties An array of optional ("" for none) properties, indexed by the property name:
Amount (default 2)
Height (default 0.0005)


Swirl(shapeName,properties)
Apply a swirl effect.
shapeName The shape to apply the effect to.
properties An array of optional ("" for none) properties, indexed by the property name:
AngleFrequency (default 45)
Center (default "X=0.5;Y=0.5;")
TwistAmount (default 10)


LDEmail
Email Methods.

Attachment Body From
Password Port Recipient
Send Server Subject
UseSSL

Attachment
Attachment file.

Body
Email body text.

From
From email address.

Password
Email client password.

Port
SMTP port (default 587).

Recipient
Recipient email address.

Send()
Send an email.
The default Smtp client is "smtp.gmail.com" and the default port is 587. The following and other email clients may also work.
"smtp.live.com" (Hotmail)
"smtp.mail.yahoo.com"

A minimum of the "From, Password and Recipient" properties must be set first.
The "From" and "Password" properties should be your email credentials for the client.
Additionally you should set the "Subject and Body" properties.
The "Attachment" property may be optionally set to a full file path, "" for no attachment.

No more than 1 email per minute can be sent.

returns "" for success or an error message.

Server
SMTP server (default "smtp.gmail.com").

Subject
Subject text.

UseSSL
"True" or "False" (default "True").

LDEncryption
Encryption and hash methods.

AESDecrypt AESEncrypt MD5Hash
MD5HashFile RSADecrypt RSAEncrypt
RSAPrivateKey RSAPublicKey RSAReset
RSASign RSAVerify SHA512Hash
SHA512HashFile

AESDecrypt(cypher,password)
Decrypt an AES encrypted cypher (previously encrypted) using a password key.
cypher The encrypted text (cypher).
password The password key for the encryption.
returns The original unencrypted text or "" if password and cypher don't match.

AESEncrypt(source,password)
Encrypt some text using AES encryption and a password key.
The encrypted text can be saved to a file.
Note that if you forget the password there is NO WAY to decrypt!

source The text to encrypt.
password The password key for the encryption.
returns The encrypted text (cypher).

MD5Hash(text)
Create an MD5 hash of a text input (http://wikipedia.org/wiki/MD5).
This 32 character hash is recommended where a general or shorter hash is required (password or data integrity).

text A text or password to create a hash.
returns The 32 character hex MD5 Hash.

MD5HashFile(fileName)
Create an MD5 hash of a file.
This 32 character hash is for file data integrity checks (e.g. a file contents is unchanged).

fileName The full path to a file to get the hash.
returns The 32 character hex MD5 Hash.

RSADecrypt(encrypted)
Decrpyt an RSA message.
Requires a Private key to be set (Only originator can decrypt with private key).
If no key is set then one created for this session is used.

encrypted The encypted message.
returns The unencrypted message.

RSAEncrypt(unencrypted)
Encrypt an RSA message.
Requires a Public key to be set (Anyone can encrypt with public key).
If no key is set then one created for this session is used.

unencrypted The message to encrypt.
returns The encrypted message.

RSAPrivateKey
Get or set a private RSA key.

RSAPublicKey
Get or set a public RSA key.

RSAReset()
Randomly reset the private and public keys

RSASign(data)
Sign an RSA message.
Requires a Private key to be set (Only originator can sign with private key).
If no key is set then one created for this session is used.

data The message to sign.
returns The signing for the message.

RSAVerify(data,sign)
Verify a signed RSA message.
Requires a Public key to be set (Anyone can verify with public key).
If no key is set then one created for this session is used.

data The message that was signed.
sign The signing for the message.
returns "True" or "False".

SHA512Hash(password)
Create a SHA2-512 hash of a text input.
This 128 character hash is recommended for the most secure password encryption.

password A text to create a hash (often a password).
returns The 128 character hex SHA512 Hash.

SHA512HashFile(fileName)
Create an SHA512 hash of a file.
This 128 character hash is for file data integrity checks (e.g. a file contents is unchanged).

fileName The full path to a file to get the hash.
returns The 128 character hex SHA512 Hash.

LDEvents
Additional Events.

Error FileChange FileFilter
FilePath LastError LastFileChanged
LastFileChangeType LastMouseWheelDelta MouseDoubleClick
MouseWheel Resized

Error
Event when a LitDev extension error occurs.
This is in addition to TextWindow warnings, which can be turned off using LDUtilties.ShowErrors, LDUtilties.ShowFileErrors and LDUtilties.ShowNoShapeErrors.


FileChange
Event when a file is created, changed or deleted.

The FilePath and FileFilter should be set before registering this event.


FileFilter
A file filter for FileSystem file change event (default is "*.*").

FilePath
The root path to watch for FileSystem file change event (default is "C:").

LastError
The last error message.

LastFileChanged
The full path to the last file changed.

LastFileChangeType
The last file change type ("Created", "Changed" or "Deleted").

LastMouseWheelDelta
The last mouse wheel Delta (rotation direction).

MouseDoubleClick
Event when the mouse is double clicked.

MouseWheel
Event when the mouse wheel is rotated.

Resized
Event when the GraphicsWindow is resized.

LDFastArray
This object provides another faster way of storing values in an Array.
It can handle 1, 2, 3 and higher dimensional arrays and has methods to read and write arrays to files, including in CSV format.
It is also possible for different rows in an array to have different dimensions or numbers of elements (jagged array), just like Small Basic arrays.
Internally it uses lists that allow the sizes to grow so that the array dimension or size doesn't need to be set at the start.
The indexing is by integer starting from 1.
For 1D arrays it is recommended to use LDList since it has additional sort methods.
Elements in arrays with dimension greater than 3 are indexed by a comma separated list of indices or index variable names.


Add Collapse Copy
CreateFromIndices CreateFromValues Dimension
Get Get1D Get2D
Get3D Read ReadCSV
Remove Set Set1D
Set2D Set3D Size
Size1 Size2 Size3
ToArray Write WriteCSV

Add()
Create a new array.
This is a general array that can be used as a 1D, 2D, 3D or higher dimension array, depending on the data set.

returns The array name.

Collapse(arrayName)
Remove all empty "" entries in an array.
Note that indices or even dimensions may change if internal entries are removed.

arrayName The array name.

Copy(arrayName)
Copy an array.
arrayName The array name.
returns A copy of the array.

CreateFromIndices(sbArray)
Convert a SmallBasic array (up to 3 dimensions) to a FastArray array.
This method creates an array only containing the Small Basic array indices.

sbArray The Small Basic array.
returns A new FastArray or "".

CreateFromValues(sbArray)
Convert a SmallBasic array to a FastArray array.
All indices in the Small Basic array are replaced with consecutive integer indices.

sbArray The Small Basic array.
returns A new FastArray or "".

Dimension(arrayName)
Get the dimension of an array.
arrayName The array name.
returns The array dimension.

Get(arrayName,indices)
Get a value.
Get1D, Get2D or Get3D methods are marginally faster for lower dimension arrays.

arrayName The array name.
indices A comma (or space) separated list of index values (slower) or index variable names (faster).
e.g. "3,2,6" or "i,j,k"
If this is set to "", then previously set index variables are used.

returns The array value or "" on failure.

Get1D(arrayName,index1)
Get a 1D value.
arrayName The array name.
index1 The first dimension integer index.
returns The array value or "" on failure.

Get2D(arrayName,index1,index2)
Get a 2D value.
arrayName The array name.
index1 The first dimension integer index.
index2 The second dimension integer index.
returns The array value or "" on failure.

Get3D(arrayName,index1,index2,index3)
Get a 3D value.
arrayName The array name.
index1 The first dimension integer index.
index2 The second dimension integer index.
index3 The third dimension integer index.
returns The array value or "" on failure.

Read(fileName,binary)
Create a new array and initialise it from a file.
If the file is text based and doesn't have the same indexing format as Write, then a 1D array with each line is created.

fileName The full path of the file.
binary Binary ("True") or text ("False") formatted file.
returns The array name.

ReadCSV(fileName)
Read a CSV (comma separated values) file into a 2D FastArray array.
The deliminator may be changed from a comma using Utilities.CSVDeliminator

fileName The full path of the CSV file.
returns A 2D FastArray with CSV file imported or "".

Remove(arrayName)
Delete an array.
arrayName The array name.

Set(arrayName,indices,value)
Set a value.
Set1D, Set2D or Set3D methods are marginally faster for lower dimension arrays.

arrayName The array name.
indices A comma (or space) separated list of index values (slower) or index variable names (faster).
e.g. "3,2,6" or "i,j,k"
If this is set to "", then previously set index variables are used.

value The value to set.

Set1D(arrayName,index1,value)
Set a 1D value.
arrayName The array name.
index1 The first dimension integer index.
value The value to set.

Set2D(arrayName,index1,index2,value)
Set a 2D value.
arrayName The array name.
index1 The first dimension integer index.
index2 The second dimension integer index.
value The value to set.

Set3D(arrayName,index1,index2,index3,value)
Set a 3D value.
arrayName The array name.
index1 The first dimension integer index.
index2 The second dimension integer index.
index3 The third dimension integer index.
value The value to set.

Size(arrayName,indices)
Get the current size of a dimension.
Size1, Size2 or Size3 methods are marginally faster for lower dimension arrays.

arrayName The array name.
indices A comma (or space) separated list of indices.
e.g. "" for first dimension or "3" for second dimension of 3rd element in first dimension.

returns The dimension size.

Size1(arrayName)
Get the current size of the first dimension.
arrayName The array name.
returns The dimension size.

Size2(arrayName,index1)
Get the current size of the second dimension.
arrayName The array name.
index1 The first index to get the size of, may be 1 if all rows have the same size.
returns The dimension size.

Size3(arrayName,index1,index2)
Get the current size of the third dimension.
arrayName The array name.
index1 The first index to get the size of, may be 1 if all rows have the same size.
index2 The second index to get the size of, may be 1 if all rows have the same size.
returns The dimension size.

ToArray(arrayName)
Convert a FastArray array to a Small Basic array.
arrayName The array name.
returns A Small Basic array or "".

Write(arrayName,fileName,binary)
Save an array to a file.
If the array is 1D and written as a text, then each entry is just written to a line with no indexing.

arrayName The array name.
fileName The full path of the file.
binary Binary ("True") or text ("False") formatted file.

WriteCSV(arrayName,fileName)
Write a 2D FastArray array to a CSV (comma separated values) file.
The deliminator may be changed from a comma using Utilities.CSVDeliminator

arrayName The 2D array name.
fileName The full path of the CSV file.

LDFastShapes
Shape methods which are faster than standard Small Basic Shape operations.
This is primarily for shape movement when there are a large number of shapes updated in a game loop.
Only the main Shapes commands are supported since these are the ones that are commonly repeated many times.
The shape must first be created, then registered (ShapeIndex) and the returned integer index used with the other methods.
The visual update of the changes made does not happen until (Update) is called when all changes are processed together.
Performance improvements come from both integer indexing and batch update.


GetLeft GetOpacity GetTop
HideShape Move Rotate
SetOpacity ShapeIndex ShowShape
Update Zoom

GetLeft(index)
Gets the left co-ordinate of the specified shape.
index The index (returned by ShapeIndex) of the shape.
returns The left co-ordinate of the shape.

GetOpacity(index)
Gets the opacity of a shape.
index The index (returned by ShapeIndex) of the shape.
returns The opacity of the object as a value between 0 and 100. 0 is completely transparent and 100 is completely opaque.

GetTop(index)
Gets the top co-ordinate of the specified shape.
index The index (returned by ShapeIndex) of the shape.
returns The top co-ordinate of the shape.

HideShape(index)
Hides an already added shape.
index The index (returned by ShapeIndex) of the shape.

Move(index,x,y)
Moves the shape with the specified name to a new position.
index The index (returned by ShapeIndex) of the shape to move.
x The x co-ordinate of the new position.
y The y co-ordinate of the new position.

Rotate(index,angle)
Rotates the shape with the specified name to the specified angle.
index The index (returned by ShapeIndex) of the shape.
angle The angle to rotate the shape.

SetOpacity(index,level)
Sets how opaque a shape should render.
index The index (returned by ShapeIndex) of the shape.
level The opacity level ranging from 0 to 100. 0 is completely transparent and 100 is completely opaque.

ShapeIndex(shapeName)
Register a shape for use with this object.
This command is potentially slow, so should be called before time critical visual updates occur.
i.e. Create and register all shapes before motion is simulated.

shapeName The name of the created shape.
returns An index to use in the other methods in this object.
The index is an integer starting at 1, incremented for each shape registered.
-1 for an error.


ShowShape(index)
Shows a previously hidden shape.
index The index (returned by ShapeIndex) of the shape.

Update()
Update all of the properties of shapes set by this object that have been modifed since the last update.
The shapes are not visually updated until this method is called.


Zoom(index,scaleX,scaleY)
Scales the shape using the specified zoom levels.
index The index (returned by ShapeIndex) of the shape.
scaleX The x-axis zoom level.
scaleY The y-axis zoom level.

LDFigures
Some additional shapes like callouts, arcs and arrows.

AddArc AddBlockArrow AddCallout
AddLineArrow AddRegularPolygon

AddArc(width,height,startAngle,endAngle,thickness)
Add an arc shape.
width The width of the shape.
height The height of the shape.
startAngle The starting angle in degrees.
endAngle The ending angle in degrees.
thickness The thickness of the arc in pixels.
returns The shape name.

AddBlockArrow(width,height,thickness,arrowAngle,direction)
Add an block arrow shape.
width The width of the shape.
height The height of the shape.
thickness The relative thickness of the arrow shaft, e.g. 0.25.
arrowAngle The arrow head angle in degrees.
direction The direction of the arrow: "Up", "Down", "Left" or "Right".
returns The shape name.

AddCallout(width,height,text,style,anchor)
Add a callout shape.
width The width of the shape.
height The height of the shape.
text The callout text.
style The callout style: "Cloud", "Oval", "Rectangle" or "RoundedRectangle".
anchor Position of callout anchor relative to the callout size (e.g. "X=0;Y=1.25;")
returns The shape name.

AddLineArrow(width,height,size,bend,startArrow,endArrow,startCorner)
Add a line arrow shape.
width The width of the shape.
height The height of the shape.
size The size of the arrow head in pixels.
bend The arrow bend amount (e.g. 0 is straight, 0.5 is smoothly bending).
startArrow The start arrow type: "None", "Arrow", "Open", "Oval" or "Stealth".
endArrow The end arrow type: "None", "Arrow", "Open", "Oval" or "Stealth".
startCorner The start corner position: "BottomLeft", "BottomRight", "TopLeft" or "TopRight". The arrow will terminate in the opposite corner.
returns The shape name.

AddRegularPolygon(width,height,corners,radius)
Add a regular polygon shape.
width The width of the shape.
height The height of the shape.
corners The number of corners.
radius A relative radius for star shapes (e.g. 1 for pentagon, 0.5 for 5 pointed star).
returns The shape name.

LDFile
File utilities.

AccessTime ANSItoUTF8 AppDataFolder
CopyDirectory CreationTime CSVplaceholder
DocumentsFolder Exists GetAllDirectories
GetExtension GetFile GetFolder
Length LoadAllVariables ModifiedTime
MusicFolder PicturesFolder PrintFile
PublicFolder ReadANSI ReadANSIToArray
ReadByteArray ReadCSV ReadCSVTransposed
ReadToArray RenameDirectory RenameFile
SaveAllVariables Size TempFolder
UserName WriteByteArray WriteCSV

AccessTime(fileName)
Gets the last time a file was accessed.
fileName The full path of the file.
returns The last access time of the file or directory ("" on failure).

ANSItoUTF8(fileName,BOM)
Convert an ANSI encoded text file to UTF8.
It should also work for any other encoding.
UTF8 is the default text file encoding used by Small Basic.

fileName The file path to convert.
BOM Include Byte Order Mark (BOM) in UTF8 file ("True" or "False", no BOM is usual).
returns The converted file path (-UTF8.txt) or "" for failure (the encoding may not have been detected correctly).

AppDataFolder
Gets the ApplicationData folder path.

CopyDirectory(directoryFrom,directoryTo)
Recursively copy a directory and all contents including sub-directories.
directoryFrom The full path to the directory to copy from.
directoryTo The full path to the directory to copy to.
returns "SUCCESS" or "FAILED".

CreationTime(fileName)
Gets the creation time of a file.
fileName The full path of the file.
returns The creation time of the file or directory ("" on failure).

CSVplaceholder
Character to use in place of empty values in the imported array when reading CSV files.
A SmallBasic array cannot hold an empty value i.e. "".

Default is the empty string "" (no array entries created for empty values in the CSV file).


DocumentsFolder
Gets the Documents folder path.

Exists(fileName)
Check if a file path is an existing file or directory.
fileName The full path of the file or directory.
returns "True" or "False".

GetAllDirectories(path)
Recursively get all sub-directories in directory.
path The full path to the root dircetory.
returns An array of all sub-directories or "FAILED".

GetExtension(fileName)
Get the file extension for a file.
fileName The file name with extension (may include folder path or not).
returns The extension of the file (without the '.') or "" if no extension.

GetFile(fileName)
Get the file for a full file path.
fileName The full path of a file.
returns The file name part of the file path (without the folder or the extension).

GetFolder(fileName)
Get the folder for a full file path.
fileName The full path of a file.
returns The folder part of the file path.

Length(fileName)
Gets the number of lines in a text file.
fileName The full path of the file.
returns The number of lines in the file (-1 on failure).

LoadAllVariables(fileName)
Restore the values of all variables that were previously stored using SaveAllVariables.
fileName The full path to a file with stored variable values.

ModifiedTime(fileName)
Gets the last time a file was modified.
fileName The full path of the file.
returns The last modified time of the file or directory ("" on failure).

MusicFolder
Gets the Music folder path.

PicturesFolder
Gets the Pictures folder path.

PrintFile(fileName)
Print a file.
fileName The full path of the file to print.

PublicFolder
Gets the Public folder path.

ReadANSI(fileName)
Read an ANSI encoded text file.
It should also work for any other encoding including UTF8.
UTF8 is the default text file encoding used by Small Basic.

fileName The file path to read.
returns The contents of the file or "" for failure (the encoding may not have been detected correctly).

ReadANSIToArray(fileName)
Reads a text file with ANSI encoding into an array with one element for each line in the file.
It should also work for any other encoding including UTF8.
Blank lines are included as an element in the array with one blank space.

fileName The full path of the file.
returns An array with one element for each line in the file or "" for failure (the encoding may not have been detected correctly).

ReadByteArray(filePath,hexMode)
Read a file into an array of bytes [0,255].
filePath The full path of the file.
hexMode If this varaible is set to "True", then a single comma deliminated variable of hex values is returned in place of an anrray..
returns An array of byte values indexed from 1, or single string variable of hex values, or "FAILED".

ReadCSV(fileName)
Read a CSV (comma separated values) file into an array.
The deliminator may be changed from a comma using Utilities.CSVDeliminator

fileName The full path of the CSV file.
returns A 2D array with CSV file imported.

ReadCSVTransposed(fileName)
Read a CSV (comma separated values) file into an array. and transpose (swap rows and columns).
The deliminator may be changed from a comma using Utilities.CSVDeliminator

fileName The full path of the CSV file.
returns 2D array with transposed CSV file imported.

ReadToArray(fileName)
Reads a text file into an array with one element for each line in the file.

Blank lines are included as an element in the array with one blank space.

fileName The full path of the file.
returns An array with one element for each line in the file.

RenameDirectory(directoryFrom,directoryTo)
Rename or move a directory.
directoryFrom The full path to the directory to rename.
directoryTo The full path to the new name for the directory.
returns "SUCCESS" or "FAILED".

RenameFile(fileFrom,fileTo)
Rename or move a file.
fileFrom The full path to the file to rename.
fileTo The full path to the new name for the file.
returns "SUCCESS" or "FAILED".

SaveAllVariables(fileName)
Save all of the current variables to a file.
This is the complete current state of your program.
May be useful to store a game state, or for debugging.

fileName The full path to store the variables and their values.
This file will be over-written.


Size(fileName)
Get the size of a file in bytes.
fileName The full path to the file to get the size of.
returns The number of bytes in the file or -1 on error.

TempFolder
Gets the Temp folder path.

UserName
Gets the current user name.

WriteByteArray(filePath,byteArray,startPos)
Writes an Array of bytes to an (existing) file.
filePath The full path of the file. A non existing file will be created.
byteArray The 1D Array (from 1, continously) with byte values [0,255].
A single comma or sapce separated variable may also be used using hex notation, eg 3D,1F,00.

startPos The byte position (incl., from 1) in an existing file to start writing (ignored for non existing file, will be written from beginning).
<=1, from file start
>file length, append after file end

returns The number of written bytes on success, else "FAILED".
example '(over)writes from file start
WriteByteArray(path, arr, 1)
'SB© after 4th byte
WriteByteArray(path, "1=83;2=66;3=169;",5)


WriteCSV(fileName,array)
Write a 2D array to a CSV (comma separated values) file.
The deliminator may be changed from a comma using Utilities.CSVDeliminator

fileName The full path of the CSV file.
array The array to export.
returns None.

LDFocus
TextBoxFocus utility to control focus (textbox currently active for input).

GetFocus IsFocus SetFocus

GetFocus()
Gets the shape that has current focus.
returns The shape name (usually a textbox) or "False".

IsFocus(shapeName)
Checks if the named shape has the focus.
shapeName The shape name (usually a textbox).
returns "True" or "False".

SetFocus(shapeName)
Sets the named shape to have focus.
shapeName The shape name (usually a textbox).
returns "True" or "False" depending on success or failure.

LDftp
ftp Methods.

Delete DoAssync Download
FTPComplete LastFTPFile LastFTPStatus
ListFiles Upload UseBinary

Delete(remoteFile,ftpServerIP,ftpUserID,ftpPassword)
Delete a file by ftp.
remoteFile The full path (on server) to the remote file to delete.
ftpServerIP The ftp server address (or IP).
ftpUserID The user ID.
ftpPassword The user password.
returns "SUCCESS", "FAILED" or "PENDING" for async.

DoAssync
Set or get whether ftp transfers are performed asynchronously ("True" or "False" default).
An asynchronous ftp transfer will return immediately and complete in the background.
The event FTPComplete will be called when the tranfer is finished.


Download(localFile,remoteFile,ftpServerIP,ftpUserID,ftpPassword)
Download a file by ftp.
localFile The full path to the local file to download.
remoteFile The full path (on server) to the remote file to download.
ftpServerIP The ftp server address (or IP).
ftpUserID The user ID.
ftpPassword The user password.
returns "SUCCESS", "FAILED" or "PENDING" for async.

FTPComplete
Event when an asynchronous ftp transfer completes.

LastFTPFile
The last asynchronous FTP file transfered.

LastFTPStatus
The last asynchronous FTP file status ("SUCCESS" or "FAILED")

ListFiles(remoteFolder,ftpServerIP,ftpUserID,ftpPassword)
Get a remote folder listing by ftp (non async only).
remoteFolder The full path (on server) to the remote folder to list.
ftpServerIP The ftp server address (or IP).
ftpUserID The user ID.
ftpPassword The user password.
returns An array of file and folder names or "FAILED". The array is indexed by the file name and the value contains additional information.

Upload(localFile,remoteFile,ftpServerIP,ftpUserID,ftpPassword)
Upload a file by ftp.
localFile The full path to the local file to upload.
remoteFile The full path (on server) to the remote file to upload.
ftpServerIP The ftp server address (or IP).
ftpUserID The user ID.
ftpPassword The user password.
returns "SUCCESS", "FAILED" or "PENDING" for async.

UseBinary
Set or get whether ftp transfers use binary (default) or ascii. ("True" or "False").

LDGeography
Gets geographic information about countries and
regional blocks.
API provided by https://restcountries.eu
Data provided by https://github.com/mledoze/countries
Coded by Abhishek Sathiabalan


Fields GetAllCountries GetCountriesByCallingCode
GetCountriesByCapital GetCountriesByCode GetCountriesByCurrency
GetCountriesByName GetCountriesByRegion GetCountriesByRegionalBloc
StrictSearch

Fields
An array of fields that the results will
contain. Fields not specified will not be
returned.


GetAllCountries()
Returns all countries on earth and
other territories in a Primitive array.


GetCountriesByCallingCode()
Returns a Primitive array of countries by telephone calling code.

GetCountriesByCapital()
Returns a Primitive array of countries by country capital.

GetCountriesByCode()
Returns a Primitive array of countries by ISO country code.

GetCountriesByCurrency()
Returns a Primitive array of countries by currency used.

GetCountriesByName(name)
Returns a Primitive array of countries by name.
name Name of the country to search for
returns
GetCountriesByRegion()
Returns a Primitive array of countries by geographical region.

GetCountriesByRegionalBloc()
Returns a Primitive array of countries by regional bloc.

StrictSearch
Whenever possible make the search require an exact match
between the query and the results.


LDGraph
Graphing utility.

AddGraph AddSeriesHistogram AddSeriesLine
AddSeriesPoints AutoScale AxesColour
AxesResolution BorderColour CreateTrend
DeleteSeries ExportCSV GridColour
GridLinesX GridLinesY Help
InteriorColour RestartEvents ScaleAxisX
ScaleAxisY StopEvents TextColour
TrendCoef TrendPointCount

AddGraph(xpos,ypos,width,height,title,labelX,labelY)
Create a graph.
xpos The graph left position.
ypos The graph right position.
width The graph width.
height The graph height.
title The graph title.
labelX The X axis label.
labelY The Y axis label.
returns The graph name.

AddSeriesHistogram(graphName,seriesLabel,data,colour)
Add a new data series to an existing graph as a histogram.
graphName The graph name.
seriesLabel The series label.
If a series with this label already exists then it is replaced with this series.

data An array holding the X and Y coordinate data.

For example, a line with points (0,1) and (2,3) would have
data[0] = 1
data[2] = 3

More generally data[x] = y.

colour The colour of the series data.
returns None.

AddSeriesLine(graphName,seriesLabel,data,colour)
Add a new data series to an existing graph as a line graph.
graphName The graph name.
seriesLabel The series label.
If a series with this label already exists then it is replaced with this series.

data An array holding the X and Y coordinate data.

For example, a line with points (0,1) and (2,3) would have
data[0] = 1
data[2] = 3

More generally data[x] = y.

colour The colour of the series data.
returns None.

AddSeriesPoints(graphName,seriesLabel,data,colour)
Add a new data series to an existing graph as points.
graphName The graph name.
seriesLabel The series label.
If a series with this label already exists then it is replaced with this series.

data An array holding the X and Y coordinate data.

For example, a line with points (0,1) and (2,3) would have
data[0] = 1
data[2] = 3

More generally data[x] = y.

colour The colour of the series data.
returns None.

AutoScale
AutoScale axes "True" (default) or "False".
When set to "False" early version scaling is used.


AxesColour
The boundary axes and tick mark colour.

AxesResolution
The axes (min and max value) significant figures (default 2).

BorderColour
The border colour.

CreateTrend(data,order)
Create a trend from data.
data An array holding the X and Y coordinate data.

For example, a line with points (0,1) and (2,3) would have
data[0] = 1
data[2] = 3

More generally data[x] = y.

order The polynomial order for the trend line.
1 is linear.
2 is quadratic.

returns A data array holding a trend that may be plotted.

DeleteSeries(graphName,seriesLabel)
Delete an existing series on existing graph.
graphName The graph name.
seriesLabel The series label name to delete.
returns None.

ExportCSV(data,fileName)
Export data series directly to CSV file (no graphing).
data An array holding the X and Y coordinate data.
fileName The CSV output file name.
returns None.

GridColour
The internal scale grid lines colour.

GridLinesX
The number of X axes tick marks and grid lines (default 10)

GridLinesY
The number of Y axes tick marks and grid lines (default 10)

Help()
This function is just to display this help.

Graphs of data can be plotted as lines, points or histograms.

Each series of data is a SmallBasic array with the array index reprenting the (unique) X value and the array value representing the Y value.

For example:
data[1] = 5
data[2] = 8
data[3] = 3

First create a graph object with AddGraph, then add series with AddSeriesLine, AddSeriesHistogram or AddSeriesPoints.

Once a graph is created and plotted, the axes can be grabbed and scrolled where the hand cursor appears. The legend can also be moved.

The graph can be rescaled by using the left mouse button to select a region to zoom, or the mouse wheel can be used to zoom the display. A double click will reset the scaling to the original default.

A right click will bring up a menu with other features like export of image or data, displaying the cursor coordinates, hiding the legend etc.

Finally the various parmeters for this method give further control of the plotting colours and behaviour.

returns None.

InteriorColour
The interior colour.

RestartEvents()
Restart all the graph left click mouse events.
returns None.

ScaleAxisX(graphName,min,interval,max)
Set the X axis scaling.
This over-rides any automatic methods.

graphName The graph name.
min The X axis minimum value.
interval The grid spacing interval.
If this value is 0 then the interval is calculated from the data.

max The X axis maximum value.
If this value is equal to min, then the maximum is calculated from the data.
If this value is less than min, then both the minimum and maximum are calculated from the data.


ScaleAxisY(graphName,min,interval,max)
Set the Y axis scaling.
This over-rides any automatic methods.

graphName The graph name.
min The Y axis minimum value.
interval The grid spacing interval.
If this value is 0 then the interval is calculated from the data.

max The Y axis maximum value.
If this value is equal to min, then the maximum is calculated from the data.
If this value is less than min, then both the minimum and maximum are calculated from the data.


StopEvents()
Stop all the graph left click mouse events.
returns None.

TextColour
The text colour.

TrendCoef()
Get the polynomial trend line coefficients for the last calculated trend using CreateTrend.
returns An array 'coef' of the polynomial coefficients for the trend line.
The number of coefficients in the array is one larger than the order used to create the trend (order+1) and is indexed from 0.
y = coef[0] + coef[1]x + coef[2]x^2 ...


TrendPointCount
Set or get the number of points created for a trend line using CreateTrend.
Default 50.


LDGraphicsWindow
GraphicsWindow utilities.

Animate BackgroundBrush BackgroundImage
CancelClose Capture Closing
ExitButtonMode ExitOnClose FloodFill
FloodFillTolerance GetPixel Height
Icon MouseX MouseXOffset
MouseXScale MouseY MouseYOffset
MouseYScale PauseUpdates Print
Reposition RepositionedMouseX RepositionedMouseY
RepositionPoint Resize ResumeUpdates
ScreenCapture SetActive SetFontFromFile
ShowInTaskbar State Style
TopMost TransparentGW Width

Animate(scaleX,scaleY,panX,panY,angle,duration)
Scale and move all Shapes and Controls within the GraphicsWindow, by smooth animation.
This is the same as the Reposition method except that the movement is animated.

scaleX The X direction scaling of the view.
scaleY The Y direction scaling of the view.
panX Pan the view in the X direction in the view scaling, 0 is centered in the GraphicsWindow.
panY Pan the view in the Y direction in the view scaling, 0 is centered in the GraphicsWindow.
angle An angle to rotate the view.
duration The time for the animation, in milliseconds.

BackgroundBrush(brush)
Set the background as a gradient of colours.
brush A previously created gradient or image brush (LDShapes.BrushGradient LDShapes.BrushImage).
returns None.

BackgroundImage(imageName)
Set the background as an image.
The backgound is auto rescaled to fill whatever size the GraphicsWindow is.

imageName The image to load as the background.
Value returned from ImageList.LoadImage or local or network image file.

returns None.

CancelClose
Cancel the next GraphicsWindow Close operation "True" or "False" (default).
Requires ExitOnClose to be set to "False".
This should usually be set inside Closing event, possibly using LDDialogs.Confirm.
It will be reset to "False" after a closure is prevented.


Capture(fileName,border)
Save the GraphicsWindow as an image file (png, jpg, bmp, gif, tiff or ico).

The window must be visible and a short delay may be required after updating the window before calling.

fileName The file to save the image to (*.png, *.jpg, *.bmp, *.gif, *.tiff or *.ico).
If this is set to "", then the image is created internally as an ImageList.

border Include the window border ("True" or "False").
returns The ImageList image if fileName is "", otherwise if output to a file, then "" is returned.

Closing
Event when a GraphicsWindow is closed.
ExitOnClose must be set to "False" to use this event.
If CancelClose is set to true, then the closure will be cancelled.


ExitButtonMode(window,mode)
Set the mode of the close button for a window.
window The window title, e.g. TextWindow.Title or GraphicsWindow.Title.
mode The mode "Enabled", "Disabled")

ExitOnClose
Set whether the SmallBasic program is ended when a GraphicsWindow is closed "True" (default) or "False".
If set to false, the program must still have something running to continue.


FloodFill(x,y,colour)
Fill a region surrounding a specified pixel.
All neighbour pixels of the same colour are changed.
This only applies to the drawing layer of the GraphicsWindow.

x The x co-ordinate of the pixel to start the fill.
y The y co-ordinate of the pixel to start the fill.
colour The colour to fill with.

FloodFillTolerance
A tolerance for FloodFill method (0 to 100).
0 is default and only pixels of exactly the same colour are changed, 100 changes all pixels apart from new fill colour.


GetPixel(x,y)
Gets the color of the pixel at the specified x and y co-ordinates.
This method works for background, drawing and shape layers.

x The x co-ordinate of the pixel.
y The y co-ordinate of the pixel.
returns The color of the pixel.

Height
Set or get the GraphicsWindow height if using LDScrollBars

Icon
Set the GraphicsWindow Icon, "SB" sets to Small Basic icon.

MouseX
Move the mouse to GraphicsWindow X coordinate.
Set as well as get.


MouseXOffset
Scaling of GraphicsWindow to Desktop coordinates.
Mouse.X = MouseXOffset + MouseXScale * GraphicsWindow.MouseX.


MouseXScale
Scaling of GraphicsWindow to Desktop coordinates.
Mouse.X = MouseXOffset + MouseXScale * GraphicsWindow.MouseX.


MouseY
Move the mouse to GraphicsWindow Y coordinate.
Set as well as get.


MouseYOffset
Scaling of GraphicsWindow to Desktop coordinates.
Mouse.Y = MouseYOffset + MouseYScale * GraphicsWindow.MouseY.


MouseYScale
Scaling of GraphicsWindow to Desktop coordinates.
Mouse.Y = MouseYOffset + MouseYScale * GraphicsWindow.MouseY.


PauseUpdates()
Pause GraphicsWindow Updates.
returns None.

Print(border)
Print the GraphicsWindow contents.

The window must be visible and a short delay may be required after updating the window before calling.

border Include the window border ("True" or "False").
returns None.

Reposition(scaleX,scaleY,panX,panY,angle)
Scale and move all Shapes and Controls within the GraphicsWindow.
This method resizes and moves the view rather than the shapes, so their positions and other properties remain unchanged but appear scaled within the repositioned region.
For example Shapes.GetLeft remains unchanged although the view has been repositioned and GraphicsWindow.MouseX reports the coordinates relative to the repositioned view.
Imagine the entire view is repositioned as if it were a shape inside the GrapicsWindow.
The transformation between view coordinates (vX,vY) and GraphicsWindow coordinates (gwX,gwY) is:
gwX = (vX+panX)*scaleX + gw*(1-scaleX)/2
gwY = (vY+panY)*scaleY + gh*(1-scaleY)/2
All drawing remains within the original GraphicsWindow.

scaleX The X direction scaling of the view.
scaleY The Y direction scaling of the view.
panX Pan the view in the X direction in the view scaling, 0 is centered in the GraphicsWindow.
panY Pan the view in the Y direction in the view scaling, 0 is centered in the GraphicsWindow.
angle An angle to rotate the view.

RepositionedMouseX
The mouse X GraphicsWindow coordinate in a repositioned view (see Reposition).

RepositionedMouseY
The mouse GraphicsWindow Y coordinate in a repositioned view (see Reposition).

RepositionPoint(x,y,toGW)
Get coordinates transformed between GraphicsWindow and a repositioned View (See Reposition).
x The x coordinate to transform.
y The x coordinate to transform.
toGW Transfer from View to GraphicsWindow ("True") or from GraphicsWindow to View ("False").
returns A 2D array of transformed coordinates indexed by 1 and 2.

Resize
The GraphicsWindow resize mode (CanMinimize 0, CanResize 1, CanResizeWithGrip 2, NoResize 3).

ResumeUpdates()
Resume GraphicsWindow Updates.
returns None.

ScreenCapture
Use screen capture for GraphicsWindow image creation.
This only applies to Print and Capture methods when the border option is set to "False"
If this option is set to "True" then the current visable GraphicsWindow is used to create a bitmap.
If this option is set to "False" then the visuals in the GraphicsWindow will be re-rendered to a bitmap.
Default "False"


SetActive()
Set the GraphicsWindow as active (has focus).

SetFontFromFile(fontFile)
Set font in GraphicsWindow from a local TTF font file.
fontFile Full path to font file to set.
returns The font name on success, else "FAILED".

ShowInTaskbar
Show or hide GraphicsWindow in taskbar ("True" or "False")

State
The GraphicsWindow state (Normal 0, Minimised 1, Maximised 2).

Style
The GraphicsWindow style (None 0, SingleBorder 1, 3DBorder 2, ToolWindow 3).

TopMost
Set the GraphicsWindow as the top most window.
The window will remain above other windows even when other windows are in focus.
"True" or "False".


TransparentGW()
Create a transparent GraphicsWindow.
This must be the called before any other GraphicsWindow, Controls or Shapes methods that create a window.
To see anything you must add something to the transparent GraphicsWindow.
For example, create a non-rectangular window using a transparent border png with LDShapes.BackgroundImage.
The transparency can be altered with GraphicsWindow.BackgroundColor.
Sometimes less than 100% transparency can be required (e.g. to register mouse movements).


Width
Set or get the GraphicsWindow width if using LDScrollBars

LDHashTable
The hashtable provides a fast and efficient way of storing key-value pairs.
Dictionaries have a O(1) scaling and as data size increases the efficiency.
Code by Abhishek Sathiabalan.


Add Clear ContainsKey
ContainsValue GetValue Remove
ToArray

Add(dictionary,key,value)
Adds a key-value pair to a specified dictionary
dictionary The name of the dictionary
key The key to add
value The value to add
returns The number of items in the dictionary or -1 on failure.

Clear(dictionary)
Removes all key-value pairs from a dictionary
dictionary The name of the dictionary
returns The number of items in the dictionary or -1 on failure.

ContainsKey(dictionary,key)
Tells you if the specified dictionary
contains a given key.

dictionary The name of the dictionary
key They key to lookup
returns "True" or "False"

ContainsValue(dictionary,value)
Tells you if the specified dictionary
contains a given key.

dictionary The name of the dictionary
value They value to lookup
returns "True" or "False"

GetValue(dictionary,key)
Retrieves a value given a specified key from the
specified dictionary

dictionary The name of the dictionary
key The key to lookup
returns The value in the key-value pair or "" on failure.

Remove(dictionary,key)
Removes a key-value pair from a specified dictionary
dictionary The name of the dictionary
key They key to remove
returns The number of items in the dictionary or -1 on failure.

ToArray(dictionary)
Converts a specified dictionary into an smallbasic array
dictionary The name of a dictionary
returns "" on failure or an array

LDHID
USB control for HID (Human Interface Devices).
The VID and PID (4 character hex codes) for the device are required.
Only HIDs will work using these methods.
Hopefully this includes most game controllers, simple robotic devices and sensors.


AddDevice FindDevices GetBits
Input InputLength LastDevice
LastInput Output OutputLength
Removed SetBits

AddDevice(VID,PID,name)
Add a HID connected device from its VID and PID.
The VID and PID are 4 character (hex) values, and can be found from:
Device Manager->Properties->Details->Hardware ids
For example: HID\VID_046D PID_C215 REV_0204 has VID "046D" and PID "C215".
Only add a device once.

VID The device VID.
PID The device PID.
name A name for the device.
returns "True" or "False" for success or failure

FindDevices()
List all found HID (Human Interface Devices).
returns A 2D array of all found devices.
The first dimension is the found device indexed from 1.
The second dimension is "VID", "PID" and "Description" holding the hex values of VID, PID and a device description.


GetBits(data)
Get an 8 element array of 1s and 0s indicating which bit of a byte are set.
data A byte number (0 to 255).
returns An 8 element bit array (small bit first) or "" on failure.

Input
Event when the HID input changes.

InputLength(name)
Get the input record length for a HID device.
name The device name.
returns The number of bytes in the input record.

LastDevice
The last HID device that had input.
returns The last device name.

LastInput
An array of the last HID input data.
This a set of values from 0 to 255 (bytes).

returns An array of input data or "" for none.

Output(name,data)
Send data to the HID device.
This must be an array of bytes (0 to 255).
The array must be indexed from 1 and have size OutputLength.

name The HID device name.
data The data to send.
returns "True" or "False" for data consistency.

OutputLength(name)
Get the output record length for a HID device.
name The HID device name.
returns The number of bytes in the output record.

Removed
Event when the HID device is removed.

SetBits(data)
Set a byte from an 8 element array of 1s and 0s indicating which bit of a byte are set.
data An 8 element array of 1s and 0s (small bit first).
returns A byte number (0 to 255) or -1 on failure.

LDIcon
Create an icon (*.ico) or cursor (*.cur) file from an image.

AddImages Blurring BMatrix
Cartoon Cartoon cmyk2rgb
CMYKLayers color2greyscale ColorAccent
ColorFiltration ContrastStretching ContrastStretching
CreateCursor CreateIcon DFT
DFT GammaCorrection GammaCorrectionGS
GF1 GF2 GF3
GMatrix Histogram HistogramShift
HistoramEqualization HPF1 HPF2
HPF3 HPF4 hsv2rgb
iDFT iDFT2 ImageCloseGS
ImageCloseGS ImageDilatationFilterGS ImageDilatationFilterGS
ImageErosionFilterGS ImageErosionFilterGS ImageFilterColor
ImageFilterColor ImageFilterColor ImageFilterGS
ImageFilterGS ImageFilterGS ImageKuwaharaFilterColor
ImageKuwaharaFilterGS ImageMedianFilterColor ImageMedianFilterGS
ImageOpenGS ImageOpenGS ImagePrewittFilterColor
ImagePrewittFilterGS ImageSDROMFilterColor ImageSDROMFilterColor
ImageSDROMFilterGS ImageSDROMFilterGS ImageSobelFilterColor
ImageSobelFilterGS InverseImage iSDFT
iSDFT2 LaplaceF1 LaplaceF2
LaplaceF3 LaplaceF4 LogaritmicScaling
LPF1 LPF2 LPF3
LPF4 Magnitude Matrix2Image
Matrix2Image Matrix2ImageLog Matrix2ImageMax
MaxBrightness MinBrightness NegativeImageColor
NegativeImageGS OilPaint Phase
Resize Resize2 rgb2cmyk
rgb2hsv RGBHistogram RGBLayers
RGBMatrix RMatrix Rotate
Rotate SDFT SDFT
Sepia SetSizes Shift
Shift Sketch SketchCharcoal
SquareImage SubtractImages TiltShift
ToBlackwhite ToBlackwhiteInverse ToGreyscale
ToGreyscaleAVG ToGreyscaleLightness

AddImages(Left,Right)
Converts ARGB images to greyscale using luminance method and adds
Left Image
Right Image
returns Product of addition

Blurring(OriginalImage,X,Y,r)
Image bluring
OriginalImage Original ARGB image
X Horizontal coordinate
Y Vertical coordinate
r Sharp region radius
returns Blurred image

BMatrix(OriginalImage)
Separates blue color layer
OriginalImage Original ARGB image
returns Blue color layer

Cartoon(OriginalImage,R,Level,InverseThreshold,EdgeFilter)
Cartoon effect received by combining oil paint algorithm and edge detecting
OriginalImage Original ARGB image
R Radius of oil paint algorithm
Level Available levels of intensity
InverseThreshold Inverse threshold
EdgeFilter Edge detecting mask
returns Cartoon effect result

Cartoon(OriginalImage,R,Level,InverseThreshold)
Cartoon effect received by combining oil paint algorithm and Sobel edge detecting
OriginalImage Original ARGB image
R Radius of oil paint algorithm
Level Available levels of intensity
InverseThreshold Inverse threshold
returns Cartoon effect result

cmyk2rgb(cmyk)
Transforms CMYK color model to RGB
cmyk CMYK values [C, M, Y, K]
returns RGB color

CMYKLayers(OriginalImage)
Creates CMYK layesr from RGB image
OriginalImage Original ARGB image
returns CMYK layers as RGB bitmaps

color2greyscale(pixel)
Converts RGB pixel to greyscale using luminance method
pixel RGB pixel
returns Greyscale pixel

ColorAccent(OriginalImage,h,range)
Color accent filtration
OriginalImage Original ARGB image
h Hue of accented color
range Range of acceptance
returns Color accent filtration

ColorFiltration(OriginalImage,color)
Image color filtration with defined color filter
OriginalImage Original ARGB image
color Color filter. Available color filters are: Magenta, Yellow, Cyan, Magenta-Yellow, Cyan-Magenta, Yellow-Cyan
returns Result of color filtration

ContrastStretching(OriginalImage,RMinSet,RMaxSet)
Converts ARGB images to greyscale using luminance method and brighten using contrast stretching method.
Brightness minimum and maximum available values are by default 0 and 255.

OriginalImage Original ARGB image
RMinSet Minimum available brightness value
RMaxSet Maximum available brightness value
returns Brigthen greyscaled image

ContrastStretching(OriginalImage)
onverts ARGB images to greyscale using luminance method and brighten using contrast stretching method.
Brightness minimum and maximum available values are by default 0 and 255.

OriginalImage Original ARGB image
returns Brigthen greyscaled image

CreateCursor(imageName,cursorPath,size,xHotSpot,yHotSpot)
Create a cursor file.
imageName The file path or ImageList image to create cursor from. Best results will be obtained from a square image.
cursorPath The full path to save the cursor file (using extension *.cur).
size The pixel size of cursor.
xHotSpot Pixel from left of cursor hot spot, indexed from 0.
For images where the aspect ratio is maintained, the xHotSpot is also scaled.

yHotSpot Pixel from top of cursor hot spot, indexed from 0.
returns
CreateIcon(imageName,iconPath)
Create an icon file with 16*16, 24*24, 32*32, 64*64, 128*128 and 256*256 embedded images.
To change these defaults use SetSizes method.

imageName The file path or ImageList image to create icon from. Best results will be obtained from a square image.
iconPath The full path to save the icon file (using extension *.ico).
returns "SUCCESS" or "FAILED"

DFT(OriginalImage)
Discrete Fourier Transform of image
OriginalImage Original ARGB image
returns Image spectrum

DFT(Data)
Discrete Fourier Transform of two-dimensional signal
Data Two-dimensional signal
returns Spectrum

GammaCorrection(OriginalImage,Gamma)
Converts image to greyscale and perform gamma correction
OriginalImage Original ARGB image
Gamma Gamma correction coefficient
returns Gamma corrected image

GammaCorrectionGS(OriginalImage,Gamma)
Gamma correction
OriginalImage Original ARGB image
Gamma Gamma correction coefficient
returns Gamma corrected image

GF1()
Gausian filter
returns Gausian filter

GF2()
Gausian filter
returns Gausian filter

GF3()
Gausian filter
returns Gausian filter

GMatrix(OriginalImage)
Separates green color layer
OriginalImage Original ARGB image
returns Green color layer

Histogram(OriginalImage)
Converts ARGB images to greyscale using luminance method and returns histogram
OriginalImage Original ARGB image
returns Image histogram (each list position corresponds to brightness level)

HistogramShift(OriginalImage,offset)
Converts ARGB images to greyscale using luminance method and shifts its histogram with respect to given offset.
OriginalImage Orignal ARGB image
offset Shift offset
returns Shifted greyscaled image

HistoramEqualization(OriginalImage)
Converts ARGB images to greyscale using luminance method and enhances contrast using equalization method.
OriginalImage Original ARGB image
returns Greyscaled contrast-enhances image

HPF1()
High pass filter
returns High pass filter

HPF2()
High pass filter
returns High pass filter

HPF3()
High pass filter
returns High pass filter

HPF4()
High pass filter
returns High pass filter

hsv2rgb(hsv)
Transforms HSV color model to RGB
hsv HSV values [H, S, V]
returns RGB color

iDFT(Spectrum)
Inverse Discrete Fourier Transform
Spectrum Image spectrum
returns Image

iDFT2(Spectrum)
Inverse Discrete Fourier Transform
Spectrum Signal spectrum
returns Signal

ImageCloseGS(OriginalImage,size)
Image to greyscale convertion and opening with element of given size
OriginalImage Orignal ARGB image
size Opening element size
returns Result of opening operation

ImageCloseGS(OriginalImage)
Image to greyscale convertion and closing with 3x3 element
OriginalImage Orignal ARGB image
returns Result of closing operation

ImageDilatationFilterGS(OriginalImage)
Converts ARGB images to greyscale using luminance method and calculates image filtartion with dilatation mask of 3 x 3 dimension.
OriginalImage Orignal ARGB image
returns Filtered image

ImageDilatationFilterGS(OriginalImage,size)
Converts ARGB images to greyscale using luminance method and calculates image filtartion with dilatation mask of given size.
OriginalImage Orignal ARGB image
size Dilatation mask dimension
returns Filtered image

ImageErosionFilterGS(OriginalImage)
Converts ARGB images to greyscale using luminance method and calculates image filtartion with erosion mask of 3 x 3 dimension.
OriginalImage Orignal ARGB image
returns Filtered image

ImageErosionFilterGS(OriginalImage,size)
Converts ARGB images to greyscale using luminance method and calculates image filtartion with erosion mask of given size.
OriginalImage Orignal ARGB image
size Erosion mask dimension
returns Filtered image

ImageFilterColor(OriginalImage,Filter)
Calculates image convolution with given filter mask.
OriginalImage Original ARGB image
Filter Filter mask
returns Filtered image

ImageFilterColor(OriginalImage,Filter)
Calculates image convolution with given filter mask.
OriginalImage Original ARGB image
Filter Filter mask
returns Filtered image

ImageFilterColor(OriginalImage,Filter,Coef)
Calculates image convolution with given filter mask.
OriginalImage Original ARGB image
Filter Filter mask
Coef Normalization coefficient
returns Filtered image

ImageFilterGS(OriginalImage,Filter)
Converts ARGB images to greyscale using luminance method and calculates image convolution with given filter mask.
OriginalImage Original ARGB image
Filter Filter mask
returns Filtered greyscaled image

ImageFilterGS(OriginalImage,Filter,Coef)
Converts ARGB images to greyscale using luminance method and calculates image convolution with given filter mask.
Normalization using given coefficient.

OriginalImage Original ARGB image
Filter Filter mask
Coef Normalization coefficient
returns Filtered greyscaled image

ImageFilterGS(OriginalImage,Filter)
Converts ARGB images to greyscale using luminance method and calculates image convolution with given filter mask.
OriginalImage Original ARGB image
Filter Filter mask
returns Filtered greyscaled image

ImageKuwaharaFilterColor(OriginalImage,FilterSize)
Kuwahara filtration
OriginalImage Original ARGB image
FilterSize Kuwahara filter size
returns Filtred image

ImageKuwaharaFilterGS(OriginalImage,FilterSize)
Image to greyscale convertion and kuwahara filtration
OriginalImage Original ARGB image
FilterSize Kuwahara filter size
returns Filtred image

ImageMedianFilterColor(OriginalImage,size)
Calculates image filtartion with median mask of given size.
OriginalImage Orignal ARGB image
size Median mask dimension
returns Filtered image

ImageMedianFilterGS(OriginalImage,size)
Converts ARGB images to greyscale using luminance method and calculates image filtartion with median mask of given size.
OriginalImage Orignal ARGB image
size Median mask dimension
returns Filtered image

ImageOpenGS(OriginalImage,size)
Image to greyscale convertion and opening with element of given size
OriginalImage Orignal ARGB image
size Opening element size
returns Result of opening operation

ImageOpenGS(OriginalImage)
Image to greyscale convertion and opening with 3x3 element
OriginalImage Orignal ARGB image
returns Result of opening operation

ImagePrewittFilterColor(OriginalImage)
Calculates module of image convolution with Prewitt operators (horizontal and vertical axis)
OriginalImage Original ARGB image
returns Filtered image

ImagePrewittFilterGS(OriginalImage)
Converts ARGB images to greyscale using luminance method and calculates module of image convolution with Prewitt operators (horizontal and vertical axis)
OriginalImage Original ARGB image
returns Filtered image

ImageSDROMFilterColor(OriginalImage)
Ccalculates image filtartion with SD-ROM mask of size 3.
OriginalImage Orignal ARGB image
returns Filtred image

ImageSDROMFilterColor(OriginalImage,size,thresholds)
Calculates image filtartion with SD-ROM mask of given size.
OriginalImage Orignal ARGB image
size SD-ROM mask size
thresholds Array of thresholds
returns Filtred image

ImageSDROMFilterGS(OriginalImage)
Converts ARGB images to greyscale using luminance method and calculates image filtartion with SD-ROM mask of size 3.
OriginalImage Orignal ARGB image
returns Filtred image

ImageSDROMFilterGS(OriginalImage,size,thresholds)
Converts ARGB images to greyscale using luminance method and calculates image filtartion with SD-ROM mask of given size.
OriginalImage Orignal ARGB image
size SD-ROM mask size
thresholds Array of thresholds
returns Filtred image

ImageSobelFilterColor(OriginalImage)
Calculates module of image convolution with Sobel operators (horizontal and vertical axis)
OriginalImage Original ARGB image
returns Filtered image

ImageSobelFilterGS(OriginalImage)
Converts ARGB images to greyscale using luminance method and calculates module of image convolution with Sobel operators (horizontal and vertical axis)
OriginalImage Original ARGB image
returns Filtered image

InverseImage(OriginalImage,threshold)
Converts ARGB image to greyscale using luminance method and inverses it with respect to given threshold
OriginalImage Original ARGB image
threshold Inverse threshold
returns Inversed image

iSDFT(Spectrum)
Inverse shifted Discrete Fourier Transform
Spectrum Image spectrum
returns Image

iSDFT2(Spectrum)
Inverse shifted Discrete Fourier Transform
Spectrum Signal spectrum
returns Signal

LaplaceF1()
Laplace filter
returns Laplace filter

LaplaceF2()
Laplace filter
returns Laplace filter

LaplaceF3()
Laplace filter
returns Laplace filter

LaplaceF4()
Laplace filter
returns Laplace filter

LogaritmicScaling(OriginalImage)
Image histogram normalization using 10-base logarithm scaling
OriginalImage Original AGB image
returns Normalized image

LPF1()
Low pass filter
returns Low pass filter

LPF2()
Low pass filter
returns Low pass filter

LPF3()
Low pass filter
returns Low pass filter

LPF4()
Low pass filter
returns Low pass filter

Magnitude(Spectrum)
Calculates array of magnitudes from array of complex elements
Spectrum Complex values array
returns Magnitudes values array

Matrix2Image(Matrix)
Converts array elements into pixel values (without normalization)
Matrix Array
returns Greyscale image

Matrix2Image(Matrix)
Converts array elements into pixel values (without normalization)
Matrix Array
returns Greyscale image

Matrix2ImageLog(Matrix)
Converts array elements into pixel values (values normalized using 10-base logarithm)
Matrix Array
returns Greyscale image

Matrix2ImageMax(Matrix)
Converts array elements into pixel values (values normalized using maximum element)
Matrix Array
returns Greyscale image

MaxBrightness(OriginalImage)
Returns image maximum brightness level
OriginalImage Original ARGB image
returns Maximum brightness level in given image

MinBrightness(OriginalImage)
Returns image minimum brightness level
OriginalImage Original ARGB image
returns Minimum brightness level in given image

NegativeImageColor(OriginalImage)
Calculate image negative
OriginalImage Original ARGB image
returns Negative

NegativeImageGS(OriginalImage)
Converts ARGB image to greyscale using luminance method and calculates its negative
OriginalImage Original ARGB image
returns Negative

OilPaint(OriginalImage,R,Level)
Oil paint filtration
OriginalImage original ARGB image
R Radius of oil paint algorithm
Level Available levels of intensity
returns Oil paint filtred image

Phase(Spectrum)
Calculates array of phases from array of complex elements
Spectrum Complex values array
returns Phases values array

Resize(OriginalImage,Width,Height)
Image resize using nearest neighbour method
OriginalImage Original image
Width Output width
Height Output height
returns Resized image

Resize2(OriginalImage,Width,Height)
Image resize using bilinear interpolation method
OriginalImage Original image
Width Output width
Height Output height
returns Resized image

rgb2cmyk(pixel)
Transforms RGB color model to CMYK
pixel RGB color
returns CMYK values [C, M, Y, K]

rgb2hsv(pixel)
Transforms RGB color model to HSV
pixel RGB color
returns HSV values [H, S, V]

RGBHistogram(OriginalImage)
Returns color image histogram
OriginalImage Original ARGB image
returns Image histogram (dimension 0 corresponds to color code (0 ->Red, 1 -> Green, 2 -> Blue), dimension 1 - each position corresponds to brightness level)

RGBLayers(OriginalImage)
Seperates values of each RGB layer
OriginalImage Original ARGB image
returns [Red, Green, Blue] image layers as Bitmaps

RGBMatrix(OriginalImage)
Seperates values of each RGB layer
OriginalImage Original ARGB image
returns [Red, Green, Blue] image layers

RMatrix(OriginalImage)
Separates red color layer
OriginalImage Original ARGB image
returns Red color layer

Rotate(OriginalImage,Angle,xCenter,yCenter)
Image rotation
OriginalImage Original image
Angle Rotate angle in degrees
xCenter X Center
yCenter Y Center
returns Rotated image

Rotate(OriginalImage,Angle)
Image rotation
OriginalImage Original image
Angle Rotate angle in degrees
returns Rotated image

SDFT(Data)
Shifted Discrete Fourier Transform of two-dimensional signal
Data Two-dimensional signal
returns Shifted spectrum

SDFT(OriginalImage)
Shifted Discrete Fourier Transform of image.
OriginalImage Original ARGB image
returns Shifted image spectrum

Sepia(OriginalImage,Coef)
Sepia filtration
OriginalImage Original ARGB image
Coef Sepia level
returns Sepia image

SetSizes(sizes)
Set the default icon sizes. This should be called before CreateIcon.
sizes A space separated list of integer icon sizes, default is "16 24 32 64 128 256".
An array of integer icon sizes may also be used.
The maximum size is 256.


Shift(Data)
Shifts array components
Data Original array
returns Shifted array

Shift(OriginalImage)
Transforms image into to shifted array of doubles
OriginalImage Original ARGB image
returns Shifted array

Sketch(OriginalImage)
Pen sketch effect received by combining laplace edge detecting, black and white transformation with inversion on point 35 and SDROM filter to eliminate smaller artefacts
OriginalImage Original ARGB image
returns Sketch effect image

SketchCharcoal(OriginalImage)
Charcoal sketch effect received by combining median filtration with mask size of 5, Sobel edge detecting, image inversion on point 80
OriginalImage Original ARGB image
returns Sketch effect image

SquareImage
Scale images to keep the aspect ratio of images square (width = height), "True" (default) or "False".
If set to "False" then the width of the icon or cursor will be scaled to maintain the image aspect ratio, while maintaining the set height.


SubtractImages(Left,Right)
Converts ARGB images to greyscale using luminance method and subtracts
Left Minuend image
Right Subtrahend image
returns Product of subtraction

TiltShift(OriginalImage)
Tilt shift filtration
OriginalImage Original ARGB image
returns Tilt shifted image

ToBlackwhite(OriginalImage,threshold)
Converts ARGB image to black and white and inverses it with respect to given threshold
OriginalImage Original ARGB image
threshold Threshold
returns Balck and white image

ToBlackwhiteInverse(OriginalImage,threshold)
Converts ARGB image to black and white and inverses it with respect to given threshold
OriginalImage Original ARGB image
threshold Threshold
returns Balck and white image

ToGreyscale(OriginalImage)
Converts ARGB image to greyscale using luminance method
OriginalImage Original ARGB image
returns Greyscaled image

ToGreyscaleAVG(OriginalImage)
Converts ARGB image to greyscale using average method
OriginalImage Original ARGB image
returns Greyscaled image

ToGreyscaleLightness(OriginalImage)
Converts ARGB image to greyscale using lightness method
OriginalImage Original ARGB image
returns Greyscaled image

LDImage
Provides methods to modify and image process images stored in ImageList.
Any effect parameter can be defaulted to "".


Add AddImages AddText
CloseWorkingImage ColorMatrix Copy
Crop DifferenceImages EffectAccent
EffectBlocks EffectBlue EffectBulge
EffectCartoon EffectCharcoal EffectContrast
EffectCyan EffectDefaults EffectEdge
EffectFishEye EffectFuzzy EffectGamma
EffectGray EffectGreen EffectHue
EffectInverse EffectJagged EffectLightness
EffectMagenta EffectNoiseRemoval EffectOilPaint
EffectPixelate EffectPosterise EffectRed
EffectReflect EffectRotate EffectSaturation
EffectSepia EffectSketch EffectSnow
EffectSolarise EffectSwirl EffectYellow
GetEffects GetImagePixels GetPixel
GetWorkingImagePixel GetWorkingImagePixelARGB HeightMap2NormalMap
Histogram LoadSVG MakeTransparent
MetaData Multiply NewImage
NormalMap OpenWorkingImage Remove
ReplaceColour Resize Rotate
Save SaveAs SetImagePixels
SetPixel SetWorkingImagePixel SplitImage
Statistics To32bitARGB UseFastPixelMethods

Add(image,red,green,blue)
Add colour values to image.
An image has pixels with R,G,B in the range 0 to 255.

image The ImageList image to modify.
red Red value to add.
green Geen value to add.
blue Blue value to add.

AddImages(image1,image2)
Add 2 images together.
An image has pixels with R,G,B in the range 0 to 255.
Both images must be the same dimension.

image1 The first ImageList image to add.
image2 The second ImageList image to add.
returns A new ImageList image with the result or "" on failure.

AddText(imageName,text,x,y,colour)
Annotate an image with text, using current GraphicsWindow font.
imageName An existing ImageList image.
text The text to add
x The left position of the text.
y The Top position of the text.
colour The text colour.

CloseWorkingImage(image)
Close and reset the image from a temporary working image.
image The working image, previously opened with OpenWorkingImage.

ColorMatrix(image,matrix)
Performs a colour matrix transformation on an image.
This can be used for all sorts of colour transformations.
See

image The ImageList image to modify.
matrix A 5*5 2D matrix.
Sepia Example:
matrix[1] = "1=0.393;2=0.349;3=0.272;4=0;5=0"
matrix[2] = "1=0.769;2=0.686;3=0.534;4=0;5=0"
matrix[3] = "1=0.189;2=0.168;3=0.131;4=0;5=0"
matrix[4] = "1=0;2=0;3=0;4=1;5=0"
matrix[5] = "1=0;2=0;3=0;4=0;5=1"


Copy(image)
Copy an image from the ImageList.
image The ImageList image to copy.
returns A new ImageList image or "" on failure.

Crop(image,x,y,width,height)
Crop an image from the ImageList.
The crop region must be entirely within the target image.

image The ImageList image to crop.
x The left position of the cropped image in pixels (indexed from 0).
y The top position of the cropped image in pixels (indexed from 0).
width The width of the cropped image in pixels.
height The height of the cropped image in pixels.

DifferenceImages(image1,image2)
Difference 2 images.
An image has pixels with R,G,B in the range 0 to 255.
Both images must be the same dimension.

image1 The first ImageList image to difference.
image2 The second ImageList image to difference.
returns A new ImageList image with the result or "" on failure.

EffectAccent(image,hue,range)
Converts to colour accent effect.
image The ImageList image to modify.
hue Accent Hue (0 o 360, default 0 (red)).
range Accent range (default 40).

EffectBlocks(image,size)
Converts to block effect.
image The ImageList image to modify.
size Blocking size factor (default 5).

EffectBlue(image)
Converts to blue colour.
image The ImageList image to modify.

EffectBulge(image,factor)
Converts to bulge effect (similar to FishEye).
image The ImageList image to modify.
factor Bulge factor, may be less than 1 for pinch effect (default 2).

EffectCartoon(image,radius,levels,inverse)
Converts to cartoon effect.
image The ImageList image to modify.
radius Cartoon radius (odd number, default 7).
levels Cartoon levels (default 10).
inverse Cartoon inverse threshold (default 40).

EffectCharcoal(image)
Converts to charcoal effect.
image The ImageList image to modify.

EffectContrast(image,contrast)
Converts to high contrast effect.
image The ImageList image to modify.
contrast Contrast factor (default 2), less than 1 reduces contrast.

EffectCyan(image)
Converts to cyan colour.
image The ImageList image to modify.

EffectDefaults
Get or set an array of default effect parameters.

EffectEdge(image)
Converts to Prewitt edge effect.
image The ImageList image to modify.

EffectFishEye(image,factor)
Converts to fisheye effect.
image The ImageList image to modify.
factor FishEye factor, should be greater than 1 (default 2).

EffectFuzzy(image,size)
Converts to fuzzy effect.
image The ImageList image to modify.
size Pixel region to make fuzzy (default 4).

EffectGamma(image,gamma)
Converts to gamma effect.
image The ImageList image to modify.
gamma Gamma factor, values less than 1 lighten and greater than 1 darken (default 2).

EffectGray(image)
Converts to gray scale.
image The ImageList image to modify.

EffectGreen(image)
Converts to green colour.
image The ImageList image to modify.

EffectHue(image,hue)
Converts to modify Hue.
image The ImageList image to modify.
hue Hue shift (0 to 360, default 180).

EffectInverse(image)
Converts to inverse colour.
image The ImageList image to modify.

EffectJagged(image,size)
Converts to jagged effect.
image The ImageList image to modify.
size Pixel region size to make jagged (default 4).

EffectLightness(image,lightness)
Converts to modify Lightness.
image The ImageList image to modify.
lightness Lightness multiplier (default 2).

EffectMagenta(image)
Converts to magenta colour.
image The ImageList image to modify.

EffectNoiseRemoval(image)
Converts to noise removal effect.
image The ImageList image to modify.

EffectOilPaint(image,radius,levels)
Converts to oil paint effect.
image The ImageList image to modify.
radius Oil paint radius (odd number, default 7).
levels Oil paint levels (default 20).

EffectPixelate(image,size)
Converts to pixelate effect.
image The ImageList image to modify.
size Pixelating size factor (default 16).

EffectPosterise(image,level)
Converts to posterise effect.
image The ImageList image to modify.
level Posterise level (default 50).

EffectRed(image)
Converts to red colour.
image The ImageList image to modify.

EffectReflect(image,flip)
Converts to X or Y reflection effect.
image The ImageList image to modify.
flip 0 to flip X and 1 to flip Y (default 0).

EffectRotate(image,rotation)
Converts to 90 degree rotation effect.
image The ImageList image to modify.
rotation 0 for +90, 1 for 180 and 2 for 270(-90) degree rotation (default 0).

EffectSaturation(image,saturation)
Converts to modify Saturation.
image The ImageList image to modify.
saturation Saturation multiplier (default 2).

EffectSepia(image,threshold)
Converts to sepia effect.
image The ImageList image to modify.
threshold Sepia threshold (default 30).

EffectSketch(image)
Converts to pen sketch effect.
image The ImageList image to modify.

EffectSnow(image,level)
Converts to snow effect.
image The ImageList image to modify.
level 1 in level pixels are randomly snow (default 25).

EffectSolarise(image,power)
Converts to solarise effect.
image The ImageList image to modify.
power Solarise power (default 2, quadratic).

EffectSwirl(image,factor)
Converts to swirl effect.
image The ImageList image to modify.
factor Swirl factor (default 1).

EffectYellow(image)
Converts to yellow colour.
image The ImageList image to modify.

GetEffects()
Get an array of the available image and webcam effects.
returns An array of effects, indexed by the effect number.

GetImagePixels(image)
Get a 2D array filled with all the pixels in an image.
image The ImageList image.
returns An array of hex based image pixel colours indexed by [x][y].

GetPixel(image,x,y)
Get a pixel colour.
image The ImageList image.
x The x pixel (indexed from 1).
y The y pixel (indexed from 1).
returns The pixel colour.

GetWorkingImagePixel(image,x,y)
Get the colour of a pixel from a temporary working image.
image The working image, previously opened with OpenWorkingImage.
x The x pixel coordinate (indexed from 1).
y The y pixel coordinate (indexed from 1).
returns The pixel colour or "" on failure.

GetWorkingImagePixelARGB(image,x,y)
Get the colour of a pixel from a temporary working image.
image The working image, previously opened with OpenWorkingImage.
x The x pixel coordinate (indexed from 1).
y The y pixel coordinate (indexed from 1).
returns The pixel colour, an array of A,R,G,B components indexed by "A", "R", "G", "B" or "" on failure.

HeightMap2NormalMap(image,scale)
Create a normal map image from a height map. The height is given by the brightness of each pixel.
image The height map ImageList image.
scale A scale factor for the elevation (default 1).
returns A new ImageList image with the resulting normal map.

Histogram(image)
Get histograms of colour pixel values.
image The ImageList image.
returns An array of colour histograms, indexed by 1,2,3 for R,G,B and 0 to 255.

LoadSVG(fileName)
Load an SVG file as an ImageList image.
fileName The SVG file.
returns The ImageList image.

MakeTransparent(image,colour)
Modify an ImageList image to make a selected colour transparent.
image The ImageList image.
colour The colour to make transparent.

MetaData(imageFile)
Get an array of image metadata.
imageFile The image file (not an ImageList image).
returns An array of metadata values indexed by hex id (Use quotes for indices with a to f in the hex values).
See https://msdn.microsoft.com/en-us/library/System.Drawing.Imaging.propertyitem.id%28v=vs.110%29.aspx for a list of ids.


Multiply(image,red,green,blue)
Multiply colour values of image.
An image has pixels with R,G,B in the range 0 to 255.

image The ImageList image to modify.
red Red value to multiply by.
green Geen value to multiply by.
blue Blue value to multiply by.

NewImage(width,height,colour)
Create a new single colored 32bitARGB image in ImageList.
width The width of the new image.
height The height of the new image.
colour The colour of the new image.
returns The Name of the new created ImageList image on success, else "".

NormalMap(shapeName,sourceX,sourceY,sourceZ,texture,ambient,intensity)
Modify an image to show a gray scale (or modified image if texture is set) shadow effect based on a normal map image.
shapeName An image shape normal map (R,G,B colours represent normal vecors of a 3D image).
This is an image shape created using Shapes.AddImage containing the normal map image.

sourceX The x position of a light source relative to the image.
sourceY The y position of a light source relative to the image.
sourceZ The z position of a light source relative to the image, this is the height abouve the image.
This can be used to alter the effective contrast of the shadow effect.

texture An optional ImageList image or "" with texture (colour) to modify, it should be the same dimensions as the normal map image.
The texture image may be changed on subsequent calls.

ambient Optional ambient light intensity if texture is set (default 0.3).
intensity Optional light intensity if texture is set (default 2).

OpenWorkingImage(image)
Open a temporary working image for fast pixel level manipulation.
After the temporary working image is finished with it should be set to the image using CloseWorkingImage.

image The ImageList image to open as a temporary working image.

Remove(image)
Remove an image from the ImageList.
image The ImageList image to delete.

ReplaceColour(image,colourFrom,colourTo,tolerance)
Replace one colour in an ImageList image with another.
image The ImageList image.
colourFrom The colour to replace.
colourTo The replacement colour to apply.
tolerance A tolerance for the colour to match (default 0 - exact match).
ARGB pixel values all within the tolerance will be replaced.


Resize(image,width,height)
Resize an image from the ImageList.
image The ImageList image to resize.
width The width in pixels.
height The height in pixels.

Rotate(image,angle)
Rotate an image.
image The ImageList image to modify.
angle The angle to rotate the image clockwise by in degrees.

Save(image,fileName)
Save an image from the ImageList as a jpg.
image The ImageList image to save.
fileName The file to save the image as.

SaveAs(image,fileName)
Save an image from the ImageList in different formats set by the file extension.
image The ImageList image to save.
fileName The file to save the image as.
Accepted file type extensions include *.bmp, *.gif, *.jpg, *.png, *.tiff or *.ico.


SetImagePixels(pixels)
Create a new image from a 2D array of pixel colour values - see GetImagePixels for format of pixels.
pixels An array of hex based image pixel colours indexed by [x][y].
returns An ImageList image created from the pixels.

SetPixel(image,x,y,colour)
Set a pixel colour.
image The ImageList image.
x The x pixel (indexed from 1).
y The y pixel (indexed from 1).
colour The colour to set the pixel.

SetWorkingImagePixel(image,x,y,colour)
Set the colour of a pixel in a temporary working image.
image The working image, previously opened with OpenWorkingImage.
x The x pixel coordinate (indexed from 1).
y The y pixel coordinate (indexed from 1).
colour The colour to set the pixel to.

SplitImage(imageName,countX,countY)
Creates an array of subdivided images from an input image.
imageName The image file (local or network) to load.
Can also be an ImageList image.

countX The number of sub-images in the X direction.
countY The number of sub-images in the Y direction.
returns A 2D array of resulting images saved in ImageList.

Statistics(image)
Get the minimum, maximum, mean and STD for colour pixel values.
image The ImageList image.
returns An array of statistics values (0 to 255), indexed by "Min", "Max", "Mean", "STD" and 1,2,3 for R,G,B.

To32bitARGB(image)
Converts an ImageList image to Format ARGB (Alphachannel with 32bit/Pxl) if needed.
image The ImageList image.
returns "SUCCESS" or "FAILED".

UseFastPixelMethods
Use a fast pixel manipulation method (default "True").
This method can be turned off using this property.


LDInline
Include C#, VB or JScript code to use at runtime.
If multiple namespaces or classes are used, then all method, property or event names should be unique.
Alternatively a fully qualified namespace.type.name may be used.
Can be used to compile extensions.
May also be used with other .Net dlls compiled externally.
Method, property, event, class and used references can be obtained (public static only).

The current application assemblies are auto referenced.
Depending on .Net methods used additional assemblies may be required.
Additional assemblies are referenced by full dll path.
Assembly dlls are often found in the following or similar locations:
C:\Windows\Microsoft.NET\Framework\v2.0.50727
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\v3.0

The TextWindow should be visible prior to using these methods if later use of the TextWindow is required.


Call Event Get
GetAssemblies GetEvents GetMethodParameters
GetMethods GetProperties GetReferences
GetTypes IncludeCS IncludeJScript
IncludeVB LoadDLL Set

Call(method,args)
Call a previously included method.
method The method name.
args The method arguments, "" for none, a single value or an array for more than 1 value.
returns Any results from the call or "FAILED".

Event(Event,callBack)
Set a callback subroutine for a previously included event.
Event The event name.
callBack The callback subroutine.

Get(property)
Get a previously included property.
property The property name.
returns The property value or "FAILED".

GetAssemblies(fullName)
Get an array of inline assemblies used.
These are the referenced assemblies that are actually used.

fullName Get the fully qualified name (with version, culture and PublicKeyToken) "True" or the basic name "False".
returns Array of assembly names and dll locations.

GetEvents()
Get an array of inline events loaded.
returns Array of event names and handler type.

GetMethodParameters(method)
Get an array of inline method loaded parameters (arguments).
method The method name.
returns Array of parameter names and type.

GetMethods(fullName)
Get an array of inline methods loaded.
fullName Get the full name (namespace.type.method) "True" or just the method name "False".
returns Array of method names and return type.

GetProperties()
Get an array of inline properties loaded.
returns Array of property names and type.

GetReferences(fullName)
Get an array of inline references added.
These are the referenced added, they may or may not be used.

fullName Get the fully qualified name (with version, culture and PublicKeyToken) "True" or the basic name "False".
returns Array of reference names and dll locations.

GetTypes()
Get an array of inline class types loaded.
returns Array of class types and namespace.

IncludeCS(source,assemblies,dllName)
Include and compile a C# Class(es). Can be the contents of a file read with File.ReadContents().
source The C# source.
assemblies An array of any additional assemblies required.
dllName An optional path to create a dll (+xml) output, use "" to perform in-memory.
returns "FAILED" or "SUCCESS"

IncludeJScript(source,assemblies,dllName)
Include and compile a JScript Module(s). Can be the contents of a file read with File.ReadContents().
source The JScript source.
assemblies An array of any additional assemblies required.
dllName An optional path to create a dll output, use "" to perform in-memory.
returns "FAILED" or "SUCCESS"

IncludeVB(source,assemblies,dllName)
Include and compile a VB Module(s). Can be the contents of a file read with File.ReadContents().
source The VB source.
assemblies An array of any additional assemblies required.
dllName An optional path to create a dll (+xml) output, use "" to perform in-memory.
returns "FAILED" or "SUCCESS"

LoadDLL(dllName)
Use a previously compiled and saved dll.
dllName The dll path.

Set(property,value)
Set a previously included property.
property The property name.
value The property value.

LDIOWarrior
Access IO-Warrior devices.
See http://www.codemercs.com/io-warrior/?L=1


Detatch GetName GetPID
GetReportSize GetSerialNumber GetSpecialReportSize
GetVersion GetVID Initialise
LastError LCDWrite Read
Timeout Write

Detatch()
Disconnect all IO-Warrior devices.

GetName(id)
Get the device name.
id The device number (indexed from 1).
returns The device name or "".

GetPID(id)
Get the device PID.
id The device number (indexed from 1).
returns The device PID (hex) or 0.

GetReportSize(id)
Get the report size.
Number of bytes in a Read/Write.
This the report size for channel 0.

id The device number (indexed from 1).
returns The report size or 0.

GetSerialNumber(id)
Get the device serial number.
id The device number (indexed from 1).
returns The device serial number or "".

GetSpecialReportSize(id)
Get the special report size.
Number of bytes in a special Read/Write.
This the report size for channel 1.

id The device number (indexed from 1).
returns The special report size or 0.

GetVersion(id)
Get the device firmware version.
id The device number (indexed from 1).
returns The device firmware version or 0.

GetVID()
Get the device VID (Common to all IOWarrior types).
returns The device VID (hex) or 0.

Initialise()
Initialise IO-Warrior devices.
returns The number of devices.

LastError()
Get the last system error message.
"" for no error (probably only useful for detailed error analysis of underlying system calls).

returns Last error number.

LCDWrite(id,text)
Write text to the LCD (untested).
id The device number (indexed from 1).
text The text to write.

Read(id,channel,blocking,count)
Read from the IO-Warrior device.
id The device number (indexed from 1).
channel The channel to read (indexed from 0).
blocking "True" (return after the state changes) or "False" (return with current state).
count The number of bytes to read (if zero, then the ReportSize is used if channel is 0 or SpecialReportSize if channel is 1).
See GetReportSize and GetSpecialReportSize.

returns An array of read bytes [0 to 255].

Timeout
The timeout for read and writes in ms.
Default 1000.


Write(id,channel,data)
Write to the IO-Warrior device.
id The device number (indexed from 1).
channel The channel to write to (indexed from 0).
data An array of bytes to send [0 to 255].
The array size should be ReportSize for channel 0 and SpecialReportSize for channel 1.
See GetReportSize and GetSpecialReportSize.

returns The number of bytes successfully written.

LDList
This object provides a way of storing values like an array that reorders itself as items are added or removed.
A list is an efficient array store (much faster than SmallBasic arrays) that can be indexed by integers and perform various other operations.
The indexing is automatically updated (indexed from 1) as the list changes.


Add Append Clear
Contains Copy Count
CreateFromIndices CreateFromValues Distinct
Except Find FindIndices
GetAt IndexOf InsertAt
Intersect Print Read
Remove RemoveAt Reverse
SetAt SortByNumber SortByText
SubList ToArray Union
Write

Add(listName,value)
Adds a value to the end of a specified list.
listName The name of the list.
value The value to add.
returns The number of items in the list or -1 on failure.

Append(listName1,listName2)
Appends a second list to the end of a first list.
listName1 The name of the first list.
listName2 The name of the second list to append to listName1.
returns The number of items in the list or -1 on failure.

Clear(listName)
Remove all values from a specified list.
listName The name of the list.
returns The number of items in the list or -1 on failure.

Contains(listName,value)
Check if a value is present within the specified list.
listName The name of the list.
value The value to check.
returns "True" or "False".

Copy(listName)
Copy a list.
listName The name of the list.
returns A copy of the list.

Count(listName)
Gets the count of items in the specified list.
listName The name of the list.
returns The number of items in the list or -1 on failure.

CreateFromIndices(sbArray)
Copy a SmallBasic array indices to a list.
sbArray The SmallBasic array.
returns The created list.

CreateFromValues(sbArray)
Copy a SmallBasic array to a list.
The array indices are ignored by the list.

sbArray The SmallBasic array.
returns The created list.

Distinct(listName)
Get a sub list of unique values from the specified list.
The text comparison is case insensitive.

listName The name of the list.
returns The sub list.

Except(listName1,listName2)
Get a sub list of non-shared values between two specified lists.
The text comparison is case insensitive.

listName1 The name of the first list.
listName2 The name of the second list.
returns The except list.

Find(listName,match,exact)
Get a sub list from the specified list where a text match is found.
The text match is case insensitive.

listName The name of the list.
match The match text.
exact An exact match (case insensitive) "True" or the match text is contained in the list "False".
returns The sub list.

FindIndices(listName,match,exact)
Get a sub list of indices from the specified list where a text match is found.
The text match is case insensitive.

listName The name of the list.
match The match text.
exact An exact match (case insensitive) "True" or the match text is contained in the list "False".
returns The sub list of indices in the list where a match is found.

GetAt(listName,index)
Get a value from a specified list by index (starting from 1).
listName The name of the list.
index The value index to get.
returns The list value.

IndexOf(listName,value)
Get the index (starting from 1) of the first occurance of a value from the specified list.
listName The name of the list.
value The value to get index of (0 for not found).
returns The value index or 0.

InsertAt(listName,index,value)
Insert a value in a specified list by index (starting from 1).
listName The name of the list.
index The index to insert at.
value The value to insert.
returns The number of items in the list or -1 on failure.

Intersect(listName1,listName2)
Get a sub list of shared values between two specified lists.
The text comparison is case insensitive.

listName1 The name of the first list.
listName2 The name of the second list.
returns The intersection list.

Print(listName)
Print a list to the TextWindow.
listName The name of the list.
returns The number of items in the list or -1 on failure.

Read(filePath)
Read a list from a file.
filePath The full path to read the list from.
returns The list if the operation was successful, otherwise "".

Remove(listName,match,exact)
Remove all occurances from the specified list where a text match is found.
The text match is case insensitive.

listName The name of the list.
match The match text.
exact An exact match (case insensitive) "True" or the match text is contained in the list "False".
returns The number of items in the list or -1 on failure.

RemoveAt(listName,index)
Remove a value from a specified list by index (starting from 1).
listName The name of the list.
index The value index to remove.
returns The number of items in the list or -1 on failure.

Reverse(listName)
Reverse the order of values in the specified list.
listName The name of the list.
returns The number of items in the list or -1 on failure.

SetAt(listName,index,value)
Set (replace) a value in a specified list by index (starting from 1).
listName The name of the list.
index The index to set.
value The value to set.
returns The number of items in the list or -1 on failure.

SortByNumber(listName)
Sort a specified list with values treated as numbers.
All values must be numbers.

listName The name of the list.
returns The number of items in the list or -1 on failure.

SortByText(listName)
Sort a specified list with values treated as text strings (lexical sort).
The sort is case insensitive.

listName The name of the list.
returns The number of items in the list or -1 on failure.

SubList(listName,start,length)
Get a sub list from the specified list.
listName The name of the list.
start The first index of the sub list.
length The length of the sub list.
returns The sub list.

ToArray(listName)
Convert a list to a SmallBasic array.
Not advised for large lists.

listName The name of the list.
returns The Small Basic array.

Union(listName1,listName2)
Get a sub list of combined values (duplicates single counted) between two specified lists.
The text comparison is case insensitive.

listName1 The name of the first list.
listName2 The name of the second list.
returns The union list.

Write(listName,filePath,append)
Save a list to file.
One line per list value is used.

listName The name of the list.
filePath The full path to save the list to.
append Append to end of existing file "True" or create a new file "False".
returns The number of items in the list or -1 on failure.

LDLogic
Logic operations.
To evaluate an expression for use with these options, use LDMath.Evaluate3.
Example:
input = 3.1
result = LDLogic.Switch(LDMath.Evaluate3(input+"<5"),"OK","New input required")


And_ CaseSensitive EQ
GE GT LE
LT NE Not
Or_ Switch XOr

And_(value1,value2)
The And operator. The trailing underscore is to keep SB parser happy not using reserved keyword AND.
And_("True","True") = "True"
And_("False","False") = "False"
And_("True","False") = "False"
And_("False","True") = "False"

value1 The first value ("True" or "False").
value2 The second value ("True" or "False").
returns "True" or "False".

CaseSensitive
Set if string comparisons are case sensitive ("True", default) or not ("False").

EQ(value1,value2)
The equality operator.
Checks if value1 is equal to value2.
It also works for strings, where a lexical comparison is made.

value1 The first value.
value2 The second value.
returns "True" or "False".

GE(value1,value2)
The greater than or equal operator.
Checks if value1 is greater than or equal to value2.
It also works for strings, where a lexical comparison is made.

value1 The first value.
value2 The second value.
returns "True" or "False".

GT(value1,value2)
The greater than operator.
Checks if value1 is greater than value2.
It also works for strings, where a lexical comparison is made.

value1 The first value.
value2 The second value.
returns "True" or "False".

LE(value1,value2)
The less than or equal operator.
Checks if value1 is less than or equal to value2.
It also works for strings, where a lexical comparison is made.

value1 The first value.
value2 The second value.
returns "True" or "False".

LT(value1,value2)
The less than operator.
Checks if value1 is less than value2.
It also works for strings, where a lexical comparison is made.

value1 The first value.
value2 The second value.
returns "True" or "False".

NE(value1,value2)
The inequality operator.
Checks if value1 is not equal to value2.
It also works for strings, where a lexical comparison is made.

value1 The first value.
value2 The second value.
returns "True" or "False".

Not(value)
The Not operator.
Not("True") = "False"
Not("False") = "True"

value The value to operate on ("True" or "False").
returns "True" or "False".

Or_(value1,value2)
The Or operator. The trailing underscore is to keep SB parser happy not using reserved keyword OR.
Or_("True","True") = "True"
Or_("False","False") = "False"
Or_("True","False") = "True"
Or_("False","True") = "True"

value1 The first value ("True" or "False").
value2 The second value ("True" or "False").
returns "True" or "False".

Switch(condition,value1,value2)
A sorthand conditional statement.
condition A condition or variable that evaluates to "True" or "False".
value1 The value to return if condition is "True".
value2 The value to return if condition is "False".
returns value1 or value2.

XOr(value1,value2)
The XOr (exclusive or) operator.
XOr("True","True") = "False"
XOr("False","False") = "False"
XOr("True","False") = "True"
XOr("False","True") = "True"

value1 The first value ("True" or "False").
value2 The second value ("True" or "False").
returns "True" or "False".

LDMath
Trig functions with degrees.
Other assorted maths functions and calculations.


ArcCos ArcSin ArcTan
Base2Decimal Convert2Cartesian Convert2Radial
Cos Cosh Decimal2Base
E Evaluate Evaluate2
Evaluate3 Exp FixDecimal
FixSigFig MaxNumber MinNumber
RandomNumberSeed Rotate Sin
Sinh Tan Tanh
Truncate

ArcCos(cos)
ArcCos in degrees.
cos The Cos of the angle.
returns The angle in degrees.

ArcSin(sin)
ArcSin in degrees.
sin The Sin of the angle.
returns The angle in degrees.

ArcTan(tan)
ArcTan in degrees.
tan The Tan of the angle.
returns The angle in degrees.

Base2Decimal(number,Base)
Convert a base number to a decimal integer.
number The base number to convert (non negative).
Base The base to convert from (2 binary) (8 octal) (16 hex) or other bases up to 36.
returns The number as a decimal integer or "FAILED".

Convert2Cartesian(x1,y1,dist,angle)
Calculate the coordinates of a point 2, from point 1 and the distance and angle to point 2.
x1 The X coordinate of point 1.
y1 The Y coordinate of point 1.
dist The distance to point 2.
angle The angle to point 2 in degrees.
returns A 2 element array with the coordinates of point 2.

Convert2Radial(x1,y1,x2,y2)
Calculate the distance and angle between two points.
x1 The X coordinate of point 1.
y1 The Y coordinate of point 1.
x2 The X coordinate of point 2.
y2 The Y coordinate of point 2.
returns A 2 element array with the distance and the angle in degrees from point 1 to point 2.

Cos(angle)
Cos of an angle in degrees.
angle The angle in degrees.
returns The Cos of the angle.

Cosh(angle)
Hyperbolic cosine.
angle Angle in radians.
returns Hyperbolic cosine.

Decimal2Base(number,Base)
Convert a decimal integer to another base.
number The decimal integer to convert (non negative).
Base The base to convert to (2 binary) (8 octal) (16 hex) or other bases to 36.
returns The number in the requested base or "FAILED".

E
Natural logarithm base.

Evaluate(expression)
Evaluate a string expression to a number or boolean (if possible).
The JScript command 'eval' is used and may therefore allow more complex JScript manipulations (also see LDInline).
The TextWindow should be visible prior to using this method if later use of the TextWindow is required.

expression The expression to evaluate, e.g. "(9/6) + 3" or "2.1 > 1.5".
returns The evaluated result.

Evaluate2(expression)
Evaluate a string expression to a number (if possible).
An alternative to Evaluate that behaves nicely with the TextWindow.

expression The expression to evaluate, e.g. "1e6 + 6/4".
returns The evaluated result.

Evaluate3(expression)
Evaluate a string expression to a boolean "True" or "False" (if possible).
An alternative to Evaluate that behaves nicely with the TextWindow.

expression The expression to evaluate to a boolean, e.g. "21.3 > 16".
returns The evaluated result ("True" or "False").

Exp(value)
Exponential of a number e^x.
value The value to raise e to the power of.
returns e^x

FixDecimal(number,digits)
Round a number to a fixed number of decimal places. Additional training decimal 0s are added if required.
number The number to change.
digits The number of decimal places.
returns The modified number.

FixSigFig(number,digits)
Round a number to a fixed number of significant figures.
number The number to change.
digits The number of significant figures.
returns The modified number.

MaxNumber
The maximum number that Small Basic can handle.

MinNumber
The minimum number that Small Basic can handle.

RandomNumberSeed
Set the seed for random numbers. The seed should be an integer number and be set before Math.GetRandomNumber is called.
The random number sequence will be initialised by the seed and can be used for testing when a repeatable sequence of random numbers is required.


Rotate(x1,y1,x2,y2,angle)
Rotate point 2 clockwise about point 1.
x1 The X coordinate of point 1.
y1 The Y coordinate of point 1.
x2 The X coordinate of point 2.
y2 The Y coordinate of point 2.
angle The angle to rotate point 2 around point 1 in degrees.
returns A 2 element array with the coordinates of the rotated point 2.

Sin(angle)
Sin of an angle in degrees.
angle The angle in degrees.
returns The Sin of the angle.

Sinh(angle)
Hyperbolic sine.
angle Angle in radians.
returns Hyperbolic sine.

Tan(angle)
Tan of an angle in degrees.
angle The angle in degrees.
returns The Tan of the angle.

Tanh(angle)
Hyperbolic tangent.
angle Angle in radians.
returns Hyperbolic tangent.

Truncate(value)
Get the integral part of a number.
value The number to truncate.
returns The integral part of the number (removing decimal fraction).

LDMathX
Extended maths methods.

FFTComplex FFTForward FFTImaginary
FFTInverse FFTReal

FFTComplex(real,imaginary)
Create an array of complex values from arrays of real and imaginary parts.
real An array of real data.
imaginary An array of imaginary data.
returns An array of complex data (real amplitude and imaginary phase), "MISMATCH" or "FAILED".
For each complex pair the index is the real part and the value is the imaginary part.


FFTForward(real)
Compute a FFT (Fast Fourier Transform).
real An array of real values to calculate the FFT from.
returns An array of complex data (real amplitude and imaginary phase) or "FAILED".
For each complex pair the index is the real part and the value is the imaginary part.


FFTImaginary(complex)
Get the imaginary part of an array of complex data.
complex An array of complex data (real amplitude and imaginary phase).
For each complex pair the index is the real part and the value is the imaginary part.

returns An array of the imaginary part of the data or "FAILED".

FFTInverse(complex)
The inverse of a FFT (Fast Fourier Transform).
complex An array of complex data (real amplitude and imaginary phase).
For each complex pair the index is the real part and the value is the imaginary part.

returns An array of inverse FFT values or "FAILED".

FFTReal(complex)
Get the real part of an array of complex data.
complex An array of complex data (real amplitude and imaginary phase).
For each complex pair the index is the real part and the value is the imaginary part.

returns An array of the real part of the data or "FAILED".

LDMatrix
A 2-Dimensional matrix structure that can be used to solve linear equations or other methods.
An error will result in a return value "FAILED";


Add Copy CopyNew
CopyToSBArray Create Delete
GetValue Inverse Multiply
SetValue Transpose View

Add(matrix1,matrix2,result)
Add two matrices, the number of rows and columns of the 3 matrices given must be the same.
Alternatively, if the second matrix is a scalar number then it is added to each element of the first matrix.

matrix1 The first matrix.
matrix2 The second matrix (or scalar value).
result The result matrix.
returns "FAILED" or "" for success.

Copy(matrix1,matrix2)
Copy one matrix to an existing matrix.
The dimensions of the 2 matrices must be the same.

matrix1 The matrix to copy from.
matrix2 The matrix to copy to.
returns "FAILED" or "" for success.

CopyNew(matrix)
Copy one matrix to a new matrix.
matrix The matrix to copy.
returns A copy of the matrix or "FAILED".

CopyToSBArray(matrix)
Copy LDMatrix type to SmallBasic array type.

The reverse operation (SmallBasic to LDMatrix) isn't possible becuase the SmallBasic indexes are not necessarily contiguous integers.

matrix The matrix name.
returns The SmallBasic array or "FAILED".

Create(rows,cols)
Create a matrix object.
Row and column matrices can be defined with rows = 1 or cols = 1 respectively.

rows The number of rows.
cols The number of columns.
returns The matrix or "FAILED".

Delete(matrix)
Delete an existing matrix (not generally required, but can save memory if lots of matrices are created).
matrix The matrix name.
returns "FAILED" or "" for success.

GetValue(matrix,row,col)
Get value in matrix.
matrix The matrix name.
row The row at which to get the value (indexed starting from 1).
col The column at which to get the value (indexed starting from 1).
returns The value or "FAILED".

Inverse(matrix,inverse)
Calculate the inverse of a matrix (using Gaussian Elimination).
The number of rows and columns of the matrix and inverse must be the same (square matrices).
A singular matrix returns "SINGULAR" and the inverse matrix will be incorrect.

matrix The matrix to invert (unmodified by inversion).
inverse The inverse matrix.
returns "FAILED" or "SINGULAR" or "" for success.

Multiply(matrix1,matrix2,result)
Multiply two matrices, the number of columns of the first and rows of the second matrix must be the same.
The number of rows and columns of the result matrix must be the rows of the first and columns of the second.
Alternatively, if the second matrix is a scalar number then it is multiplied by each element of the first matrix and the dimensions of the first and result must be the same.

matrix1 The first matrix.
matrix2 The second matrix (or scalar value).
result The result matrix.
returns "FAILED" or "" for success.

SetValue(matrix,row,col,value)
Set value in matrix.
matrix The matrix name.
row The row at which to add the value (indexed starting from 1).
col The column at which to add the value (indexed starting from 1).
value The value.
returns "FAILED" or "" for success.

Transpose(matrix,transpose)
Calculate the transpose of a matrix.
The number of rows and columns of the matrix and transpose must be reversed (cols = rows and vice versa).

matrix The matrix to transpose.
transpose The resulting transposed matrix.
returns "FAILED" or "" for success.

View(matrix,modal)
View a matrix for dubugging purposes.
matrix The matrix to display.
modal The matrix display will pause all other actions until it is closed. ("True" or "False").
returns None.

LDMusic
Extends the Sound.PlayMusic method to include a variety of instrument sounds.
Also, multi-channel music can be created.
Due to the large number of instrument names, it is easy to miss the following properties:
Instrument, Velocity, Volume, Pan and Channel.


Channel EndNote Instrument
InstrumentName Pan PlayMusic
PlayMusic2 PlayNote Reset
Velocity Volume

Channel
Set the MIDI channel (1 to 16, default 1).
Used by PlayMusic, Instrument, Velocity, Volume and Pan.


EndNote(value)
Stop a note being played.
value The note to stop (this is the value returned by PlayNote when the note was started).

Instrument
Set the musical instrument (1 to 128).
1 Acoustic_Grand_Piano
2 Bright_Acoustic_Piano
3 Electric_Grand_Piano
4 Honky_tonk_Piano
5 Electric_Piano_1
6 Electric_Piano_2
7 Harpsichord
8 Clavi
9 Celesta
10 Glockenspiel
11 Music_Box
12 Vibraphone
13 Marimba
14 Xylophone
15 Tubular_Bells
16 Dulcimer
17 Drawbar_Organ
18 Percussive_Organ
19 Rock_Organ
20 Church_Organ
21 Reed_Organ
22 Accordion
23 Harmonica
24 Tango_Accordion
25 Acoustic_Guitar_nylon
26 Acoustic_Guitar_steel
27 Electric_Guitar_jazz
28 Electric_Guitar_clean
29 Electric_Guitar_muted
30 Overdriven_Guitar
31 Distortion_Guitar
32 Guitar_harmonics
33 Acoustic_Bass
34 Electric_Bass_finger
35 Electric_Bass_pick
36 Fretless_Bass
37 Slap_Bass_1
38 Slap_Bass_2
39 Synth_Bass_1
40 Synth_Bass_2
41 Violin
42 Viola
43 Cello
44 Contrabass
45 Tremolo_Strings
46 Pizzicato_Strings
47 Orchestral_Harp
48 Timpani
49 String_Ensemble_1
50 String_Ensemble_2
51 SynthStrings_1
52 SynthStrings_2
53 Choir_Aahs
54 Voice_Oohs
55 Synth_Voice
56 Orchestra_Hit
57 Trumpet
58 Trombone
59 Tuba
60 Muted_Trumpet
61 French_Horn
62 Brass_Section
63 SynthBrass_1
64 SynthBrass_2
65 Soprano_Sax
66 Alto_Sax
67 Tenor_Sax
68 Baritone_Sax
69 Oboe
70 English_Horn
71 Bassoon
72 Clarinet
73 Piccolo
74 Flute
75 Recorder
76 Pan_Flute
77 Blown_Bottle
78 Shakuhachi
79 Whistle
80 Ocarina
81 Lead_1_square
82 Lead_2_sawtooth
83 Lead_3_calliope
84 Lead_4_chiff
85 Lead_5_charang
86 Lead_6_voice
87 Lead_7_fifths
88 Lead_8_bass_lead
89 Pad_1_new_age
90 Pad_2_warm
91 Pad_3_polysynth
92 Pad_4_choir
93 Pad_5_bowed
94 Pad_6_metallic
95 Pad_7_halo
96 Pad_8_sweep
97 FX_1_rain
98 FX_2_soundtrack
99 FX_3_crystal
100 FX_4_atmosphere
101 FX_5_brightness
102 FX_6_goblins
103 FX_7_echoes
104 FX_8_sci_fi
105 Sitar
106 Banjo
107 Shamisen
108 Koto
109 Kalimba
110 Bag_pipe
111 Fiddle
112 Shanai
113 Tinkle_Bell
114 Agogo
115 Steel_Drums
116 Woodblock
117 Taiko_Drum
118 Melodic_Tom
119 Synth_Drum
120 Reverse_Cymbal
121 Guitar_Fret_Noise
122 Breath_Noise
123 Seashore
124 Bird_Tweet
125 Telephone_Ring
126 Helicopter
127 Applause
128 Gunshot


InstrumentName(instrument)
Get an instrument name from its number.
instrument The instrument number.
returns
Pan
Set the key pan balance left (-100) or right (100) (default 0).

PlayMusic(notes)
Plays musical notes.
notes A set of musical notes to play. The format is a subset of the Music Markup Language supported by QBasic.
example code LDMusic.Instrument = LDMusic.Xylophone
LDMusic.PlayMusic("O5 C8 C8 G8 G8 A8 A8 G4 F8 F8 E8 E8 D8 D8 C2")


PlayMusic2(notes,instrument,velocity,volume,pan,channel)
Plays musical notes with specified instrument and MDI channel.
Also set volume, pan (balance) and velocity (key hit speed).

notes A set of musical notes to play. The format is a subset of the Music Markup Language supported by QBasic.
instrument The instrument number.
velocity The key velocity (1 to 128, default 100).
volume Volume (0 to 100, default 50).
pan Pan left (-100) or right (100) (default 0).
channel The MIDI channel (1 to 16).

PlayNote(octave,note,channel)
Play an individual note (allows multi-channel instruments).
octave The octave (0 to 8).
note The note ("A","F#","B-" etc).
channel The MIDI channel (1 to 16).
returns The note value being played.

Reset()
Reset (stop all music on all channels).

Velocity
Set the key velocity (1 to 128).
This is how hard a key was pressed (default 100).


Volume
Set the key volume (0 to 100, default 50).

LDNetwork
Network or web methods.

DownloadFile GetGameData HighScore
LAN Ping SetGameData

DownloadFile(localFile,remoteFile)
Similar To Network.DownloadFile, except the download file is input and handles larger files better.
localFile The local file name to save the downloaded file.
remoteFile The remote network file.
returns The size of the file in bytes or -1 for failue.

GetGameData(game)
Download some data (previously saved) for a game.
game The game name (a unique case sensitive name for each game or version is required).
returns The stored data on success.

HighScore(game,user,score)
Upload a potential high score to the web.
All values are case sensitive and the score should be an integer number.

game The game name (a unique name for each game or version is required).
user The user name.
score The score.
returns An array with the current high score user name and their score.

LAN(timeout)
Get a list of the devices and their addresses connected to your local area network (LAN, home network, 192.168.1.xx).
timeout A timeout in ms, e.g. 1000.
returns An array of IP address and device names with ping time, indexed by IP address.

Ping(IP,timeout)
Ping an IP address and return the roundtrip time.
IP The IP address (or url) to ping.
timeout A timeout in ms, e.g. 1000.
returns The roundtrip time on success (ms) or -1 on failure

SetGameData(game,data)
Upload some data for a game.
game The game name (a unique case sensitive name for each game or version is required).
data The data to store, may be an array.
returns The stored data on success.

LDPhysics
Physics extension using Box2D engine.

AddChain AddExplosion AddFixedAnchor
AddFixedShape AddInactiveShape AddMovingAnchor
AddMovingShape AddRope AttachShapes
AttachShapesWithJoint AttachShapesWithRotation BoxShape
BrakeTire ChainColour DetachJoint
DetachShapes DisconnectShape DoTimestep
FollowShapeX FollowShapeY GetAllShapesAt
GetAngle GetCollisions GetContacts
GetInertia GetMass GetPan
GetPosition GetRotation GetShapeAt
GetTireInformation GetTireProperties GetVelocity
GroupShapes Help LoadImagesAsCircles
MaxPolygonVertices MaxProxies MoveTire
PanView PositionIterations RayCast
ReadJson RemoveChain RemoveFrozen
RemoveRope RemoveShape Reset
RopeColour Scaling SetAABB
SetAngle SetBoundaries SetBullet
SetDamping SetForce SetGravity
SetGroup SetImpulse SetJointMotor
SetPosition SetRotation SetShapeGravity
SetTire SetTireProperties SetTorque
SetVelocity TimeStep TimestepControl
ToggleMoving ToggleRotation ToggleSensor
TurnTire UngroupShapes UnsetBullet
VelocityIterations VelocityThreshold WakeAll
WriteJson

AddChain(shape1,shape2)
Add a chain between two existing shapes.
shape1 First shape.
shape2 Second shape.
returns The chain name.

AddExplosion(posX,posY,power,damping,colour)
Make an explosion, which consists of 50x20kg particles blast apart over 500ms.
posX The X coordinate of the explosion.
posY The Y coordinate of the explosion.
power The explosion force, this is the initial velocity of the blast particles.
damping A damping for the blast, the smaller this value the larger the blast range (default 10).
colour An optional colour of the explosion particles ("" for none).

AddFixedAnchor(posX,posY)
Add a new small, transparent shape to be used as a fixed anchor point.
posX The X coordinate of the anchor.
posY The Y coordinate of the anchor.
returns The anchor shape name.

AddFixedShape(shapeName,friction,restitution)
Add an existing SmallBasic shape to the physics engine as a fixed (non-dynamic) shape with friction and restitution that affects shapes that hit it.
shapeName The name of the shape.
friction The shape friction (usually 0 to 1).
restitution The shape restitution or bounciness (usually 0 to 1).
returns None.

AddInactiveShape(shapeName)
Add an existing SmallBasic shape to the physics engine as an inactive (non-dynamic and non-interacting) shape which only moves with the PanView method.
shapeName The name of the shape.
returns None.

AddMovingAnchor(posX,posY)
Add a new small, transparent and high density shape to be used as a moving anchor point.
posX The X coordinate of the anchor.
posY The Y coordinate of the anchor.
returns The anchor shape name.

AddMovingShape(shapeName,friction,restitution,density)
Add an existing SmallBasic shape to the physics engine as a moving (dynamic) shape.
shapeName The name of the shape.
friction The shape friction (usually 0 to 1).
restitution The shape restitution or bounciness (usually 0 to 1).
If a negative value is set for restitution, then the shape will be added with a very small size which may be used to add an inactive image that can be grouped within an irregular compound shape that matches the image boundary.

density The shape density (default 1).
returns None.

AddRope(shape1,shape2)
Add a rope between two existing shapes.
shape1 First shape.
shape2 Second shape.
returns The rope name.

AttachShapes(shape1,shape2)
Connect two shapes to move together as one. The shapes are connected with a distance joint and may wobble a bit if they are hit.
shape1 The first shape name.
shape2 The second shape name.
returns None.

AttachShapesWithJoint(shape1,shape2,type,collide,parameters)
Connect two shapes to move together as one with one of several joint types.
These can be advanced and require reference to Box2D manual.
In many cases it is best to prevent shape rotation for the joints to behave as desired.
Multiple joints may also be applied to shapes.
The methods use the initial shape positions, so set these first.

shape1 The first shape name.
shape2 The second shape name.
type One of the following joint types.

"Distance" - maintain a fixed distance between the shapes.
"Gear" - link Prismatic or Revolute joints (previously created) of 2 shapes.
"Line" - move the shapes along a line initially connecting the shapes.
"Mouse" - move the shape to follow the mouse (both shape names should be the same).
"Prismatic_H" - move shapes vertically along a line between the two shapes.
"Prismatic_V" - move shapes horizontally along a line between the two shapes.
"Pulley" - a pulley system, one shape moves up as the other moves down - position the shapes initially at the extreme points of the pulley motion.
"Revolute" - the shapes can rotate about each other.

collide The connected shapes can interact with each other "True" or "False" (default).
parameters Optional parameters (default ""), multiple parameters are in an array.

"Distance" - damping ratio (default 0)
"Gear" - gear ratio, first joint, second joint (default 1, auto detect joints)
"Line" - X direction, Y direction, lower translation, upper translation (default line connecting shapes, no limits)
"Mouse" - max acceleration, damping ratio (default 10000, 0.7)
"Prismatic_H" - X direction, Y direction, lower translation, upper translation (default 1,0, no limits)
"Prismatic_V" - X direction, Y direction, lower translation, upper translation (default 0,1, no limits)
"Pulley" - pulley ratio (block and tackle) (default 1)
"Revolute" - lower angle, upper angle (default no limits)

returns The joint name.

AttachShapesWithRotation(shape1,shape2)
Connect two shapes to move together as one, but allow the shapes to rotate about each other.
shape1 The first shape name.
shape2 The second shape name.
returns None.

BoxShape(shapeName,x1,y1,x2,y2)
Set a shape to remain within a box within the view.
This is similar to PanView, except that the view pans automatically to keep the specified shape within a box region of the GraphicsWindow.
Only one shape can be boxed. To unset shape box, set the shapeName to "".

shapeName The shape to box or "".
x1 The left x coordinate of the box.
y1 The top y coordinate of the box.
x2 The right x coordinate of the box.
y2 The bottom y coordinate of the box.

BrakeTire(shapeName)
Apply a brake to a tire shape.
shapeName The tire shape to brake.

ChainColour
The colour to be used for chains.

DetachJoint(jointName)
Disconnect two shapes that were previously joined with a joint.
jointName The joint name.
returns None.

DetachShapes(shape1,shape2)
Disconnect two shapes that were previously attached.
shape1 The first shape name.
shape2 The second shape name.
returns None.

DisconnectShape(shapeName)
Disconnect shape from the physics engine without deleting the shape.
shapeName The shape name.
returns None.

DoTimestep()
Perform a time-step update.
returns None.

FollowShapeX(shapeName)
Set a shape to remain stationary at X position in the view.
This is similar to PanView, except that the view pans automatically to keep the specified shape at a constant visual X location.
Only one shape can be followed in X direction. To unset shape following, set the shapeName to "".

shapeName The shape to follow or "".
returns None.

FollowShapeY(shapeName)
Set a shape to remain stationary at Y position in the view.
This is similar to PanView, except that the view pans automatically to keep the specified shape at a constant visual Y location.
Only one shape can be followed in Y direction. To unset shape following, set the shapeName to "".

shapeName The shape to follow or "".
returns None.

GetAllShapesAt(posX,posY)
Get an array of all the physics engine shapes (if any) at the input coordinates.
The coordinates for this method are the physics engine coordinates if panning is present.

posX The X coordinate.
posY The Y coordinate.
returns An array of shape names or "".

GetAngle(shapeName)
Get the angle of rotation for the shape.
shapeName The shape name.
returns The angle of rotation in degrees.

GetCollisions(shapeName)
Get an array of all the shapes that the specified shape collided with during the last DoTimestep().
shapeName The shape to check for collisions.
returns An array of all the shapes collided with (may be empty "" or "Wall" for a static obstacle).

GetContacts(posX,posY,distance)
Get a list of shapes that collided within a distance of a specified contact point.
posX The X coordinate of a contact position to check.
posY The Y coordinate of a contact position to check.
distance A maximum distance from the contact point for the contact.
returns An array of contacts, with each contact being an array of 2 shape names.

GetInertia(shapeName)
Get the moment of inertia of a shape.
shapeName The shape name.
returns The inertia of the shape.

GetMass(shapeName)
Get the mass of a shape.
shapeName The shape name.
returns The mass of the shape.

GetPan()
Get the current pan offset, see PanView, FollowShapeX(Y) and BoxShape.
World coordinates = screen coordinates + pan offset.

returns A 2 element array with the current pan offset.

GetPosition(shapeName)
Get the centre of the shape coordinates.
shapeName The shape name.
returns A 2 element array with the shape centre position.

GetRotation(shapeName)
Get the shape rotation speed.
shapeName The shape name.
returns The angular rotation speed degrees/s.

GetShapeAt(posX,posY)
Get the shape (if any) at the input coordinates.
The coordinates for this method are the screen coordinates if panning is present.

posX The X coordinate.
posY The Y coordinate.
returns The shape name at the input position or "".

GetTireInformation(shapeName)
Get tire information, it includes:

Skid (if this value exceeds the property AntiSkid, then the tire is skidding)
Crash (the value is the speed of the impact)

shapeName The tire shape.
returns An array of information, indexed by the information name, e.g. "Skid".

GetTireProperties(shapeName)
Get tire properties, they include:

AntiSkid (higher value reduces skid)
Drag (higher value increases forward/backward drag)
Brake (higher value increases braking power)
Straighten (higher value restores steering more quickly)
BrakeStraighten (higher value restores steering more quickly while braking)

shapeName The tire shape.
returns An array of properties, indexed by the property name, e.g. "AntiSkid".

GetVelocity(shapeName)
Get the velocity of the shape.
shapeName The shape name.
returns A 2 element array with the shape velocity.

GroupShapes(shape1,shape2)
Solidly group two shapes to move together as one. Shape1 is added to shape2 to act as one shape.
shape1 The first shape name.
shape2 The second shape name.
returns None.

Help()
This function is just to display this help.

The extension uses Box2D (http://box2d.org) as an engine and provides an interface between it and the graphics capabilities of SmallBasic.

Only shapes that are connected to the physics engine take part in the motion physics, for example you may add normal shapes (e.g. a gun and not connect it to the physics engine). Once a shape is connected to the engine, it is best to only interact with it through the methods provided by the extension. All positions are in the SmallBasic GraphicsWindow pixels and refer to shape centres.

Image and text shapes are treated as rectangles, and ellipses as circles; there is also triangle and convex polygon support, but not lines. Images may be treated as circles by setting the property LoadImagesAsCircles to "True".

One issue that Box2D has difficulty with is small fast moving objects that can 'tunnel' through other shapes without being deflected (see the SetBullet option).

Another problem is shapes of very different size and hence mass, especially large shapes when they are connected together. It may be necessary to modify the density for these (the Anchor options are an attempt to automate this a bit), otherwise the default density of 1 is good. Resist the temptation to connect too many shapes together.

It may be possible to improve the stability of some 'difficult' models using the TimestepControl settings, but the defaults look good for most cases.

Do not call the physics methods inside SmallBasic event subroutines directly, rather set flags that can be processed in a main game loop.

There are sample SmallBasic programs and a Getting Started Guide that comes with the extension dll - this is the best place to start.

Report bugs and problems to the SmallBasic forum (), but first simplify your SmallBasic code to isolate the issue before providing a short 'runnable' code sample.

returns None.

LoadImagesAsCircles
Toggle whether image shapes will be loaded as circles - "True" or "False" (default is "False").

MaxPolygonVertices
The physics engine maximum number of vertices on convex polygons (default 8).

MaxProxies
The physics engine maximum number of objects 'proxies' (default 1024).

MoveTire(shapeName,force)
Move a tire shape, apply a forward or backward force.
shapeName The tire shape to move.
force The force to apply, positive is forward, negative is backward.

PanView(panHorizontal,panVertical)
Pan the camera view, including window boundaries.
panHorizontal Pan in the horizontal direction (negative is left).
panVertical Pan in the vertical direction (negative is up).
returns None.

PositionIterations
The physics engine position iterations (default 2).

RayCast(shapeName,angle,distance)
Cast an invisible ray to detect the proximity of shapes.
shapeName The shape to cast the ray from.
angle The angle in degrees to check, this can also be an array of angles.
distance A maximum distance to check.
returns An array of results, indexed by the shape name ("Wall" for a static obstacle) with a value equal to its distance.
The shapes are sorted to list them nearest first.
If an array of input angles is used, then only the nearest shape for each angle is returned and the value is the angle, not the distance.


ReadJson(fileName,scale,reverseY,stationary,offsetX,offsetY)
Read in a json script compatible with R.U.B.E. and create a LDPhysics model.
See https://www.iforce2d.net/rube for more details.

fileName The full path to the json file to read.
scale Scale all shapes, default 1 (no scaling).
reverseY Reverse the Y direction up to down ("True" or "False").
stationary Set all shapes to be initially at rest, joint motors are still enabled ("True" or "False").
offsetX Add an x coordinate offset to all shapes.
offsetY Add a y coordinate offset to all shapes, especially useful when reverseY is set.
returns A text array containing the LDPhysics commands used to create the model.

RemoveChain(shapeName)
Remove a chain.
shapeName The chain name.
returns None.

RemoveFrozen()
Removes all frozen shapes - outside the AABB for the engine.
returns None.

RemoveRope(shapeName)
Remove a rope.
shapeName The rope name.
returns None.

RemoveShape(shapeName)
Remove a shape.
shapeName The name of the shape.
returns None.

Reset()
Reset (delete all physics engine attached shapes).
returns None.

RopeColour
The colour to be used for ropes.

Scaling
The physics engine scaling (pixel/m, default 10). It is not recommended to change this.

SetAABB(minX,maxX,minY,maxY)
The physics engine AABB (axis-aligned bounding box). The units are the engine units of m. A Reset is required after setting. It is not recommended to change this.
minX The left coordinate of the universe (default -100).
maxX The right coordinate of the universe (default 200).
minY The top coordinate of the universe (default -100).
maxY The bottom coordinate of the universe (default 200).
returns None.

SetAngle(shapeName,angle)
Reset the angle of rotation for a shape.
shapeName The shape name.
angle The angle of rotation in degrees.
returns None.

SetBoundaries(left,right,top,bottom)
Set solid boundaries (positioning a boundary outside the GraphicsWindow removes it).
left The left boundary X value.
right The right boundary X value.
top The top boundary Y value.
bottom The bottom (ground) boundary Y value.
returns None.

SetBullet(shapeName)
Set a shape as a bullet. This prevents 'tunnelling' of fast moving small objects at the expense of performance.
shapeName The shape name.
returns None.

SetDamping(shapeName,linear,angular)
Set a damping factor for a shape (default 0).
shapeName The shape to modify.
linear Linear damping factor.
angular Angular damping factor.
returns None.

SetForce(shapeName,forceX,forceY)
Set a force to apply to a shape (Remember F = ma).
shapeName The shape to modify.
forceX X component of the force.
forceY Y component of the force.
returns None.

SetGravity(gravX,gravY)
Set the gravity direction and magnitude (default 0,100).
gravX The X component of gravity.
gravY The Y component of gravity.
returns None.

SetGroup(shapeName,group,mask)
Control which sprites interact (collide) with other shapes.
shapeName The shape to modify.
group The group that the current shape belongs to (default 0). This should be an integer between 0 and 15.
mask An array of groups that this shape will collide with (default all groups 0,1,2,..,14,15).
To allow the shape to only interact with groups 0, 1 and 4 would be "1=0;2=1;3=4;".

returns None.

SetImpulse(shapeName,impulseX,impulseY)
Set an impulse to a shape (a kick).
shapeName The shape to modify.
impulseX X component of the impulse.
impulseY Y component of the impulse.
returns None.

SetJointMotor(jointName,speed,maxForce)
Set a motor for selected joints (Line, Prismatic_H, Prismatic_V and Revolute).
jointName The joint name.
speed The desired motor speed.
maxForce The maximum motor force (torque for Revolute).
A zero value turns motor off.


SetPosition(shapeName,posX,posY,angle)
Reset shape position.
shapeName The shape to modify.
posX X component shape centre.
posY Y component shape centre.
angle The angle of rotation in degrees.
returns None.

SetRotation(shapeName,rotation)
Set shape rotation speed.
shapeName The shape to modify.
rotation The angular rotation speed degrees/s.
returns None.

SetShapeGravity(shapeName,gravX,gravY)
Set the gravity direction and magnitude for an individual shape (default 0,100).
shapeName The shape to modify.
gravX The X component of gravity.
gravY The Y component of gravity.
returns None.

SetTire(shapeName)
Set an object to act as a drivable tire for a top down game.
Usually gravity will be 0 and the shape should already be added to the engine.
The object should be initially positioned facing forward up on the display.

shapeName The shape to make a tire.

SetTireProperties(shapeName,properties)
Set tire properties, they include:

AntiSkid (higher value reduces skid)
Drag (higher value increases forward/backward drag)
Brake (higher value increases braking power)
Straighten (higher value restores stearing more quickly)
BrakeStraighten (higher value restores stearing more quickly while braking)

shapeName The tire shape.
properties An array of one or more properties to set.
The index is one of the properties (case sensitive) and the value is the property value.


SetTorque(shapeName,torque)
Set a torque to a shape (a rotational kick).
shapeName The shape to modify.
torque The torque to apply.
returns None.

SetVelocity(shapeName,velX,velY)
Set the velocity of a shape.
shapeName The shape to modify.
velX X component of the velocity.
velY Y component of the velocity.
returns None.

TimeStep
The physics engine timestep size (default 0.025).

TimestepControl(timestep,velocityIterations,positionIterations)
Modify default timestep control parameters - also can be set using individual parameters.
timestep Time-step (default 0.025).
velocityIterations Velocity iterations (default 6).
positionIterations Position iterations (default 2).
returns None.

ToggleMoving(shapeName)
Toggle a moving shape to be fixed and vice-versa.
This method also sets the rotation to be on or off to match if it is moving or fixed.

shapeName The shape name.

ToggleRotation(shapeName)
Toggle a shape to not rotate and vice-versa.
This method toggles the rotation property for fixed and moving shapes.

shapeName The shape name.

ToggleSensor(shapeName)
Toggle a shape to act as a sensor and vice-versa.
A sensor shape does not interact with other shapes, but still provides collision data.

shapeName The shape name.

TurnTire(shapeName,torque)
Turn a tire shape, steer left or right.
shapeName The tire shape to turn.
torque The torque, rotation force to apply, positive is turn right, negative is turn left.

UngroupShapes(shape1,shape2)
Remove shape group pairing.
shape1 The first shape name.
shape2 The second shape name.
returns None.

UnsetBullet(shapeName)
Unset a shape as a bullet. This reverts the shape to normal collision detection.
shapeName The shape name.
returns None.

VelocityIterations
The physics engine velocity iterations (default 6).

VelocityThreshold
The physics engine velocity threshold for inelastic collisions 'sticky walls' (default 1).

WakeAll()
Wake all sleeping shapes - shapes sleep due to no applied forces or contacts. They wake automatically on any contact or applied force, so this action is rarely required.
returns None.

WriteJson(fileName)
Write out a json script compatible with R.U.B.E. from current LDPhysics model.
See https://www.iforce2d.net/rube for more details.

fileName The full path to the json file to create.

LDProcess
Control an external application.

GetProcesses Start Stop

GetProcesses()
Get a list of system processes.
returns An array of all the system process names, indexed by the process ID.

Start(application,arguments)
Start an external application.
application The full path of the application to start e.g. "C:\Program Files (x86)\Microsoft\Small Basic\SB.exe".
arguments Arguments to give to the command or "" if none.
returns Process ID of started application, -1 if failed or -2 if attached to existing process.

Stop(ID)
Stop an external process.
ID The process ID to stop.
returns "True" or "False" for success or failure.

LDQueue
This object provides a way of storing values.
It is similar to a stack, except that is is fist-in first-out, like a queue.
You can enqueue (add) a value to the end of the queue and dequeue (remove) the first value at the front of the queue.
You can only enqueue and dequeue the values one by one.


Dequeue Enqueue GetCount

Dequeue(queueName)
Remove (and get) the value from the front of the specified queue.
queueName The name of the queue.
returns The value from the queue.

Enqueue(queueName,value)
Adds a value to the end of the specified queue.
queueName The name of the queue.
value The value to enqueue.

GetCount(queueName)
Gets the count of items in the specified queue.
queueName The name of the queue.
returns The number of items in the specified queue.

LDRegex
Regex (regular expression) text manipulation utilities.

Match Replace

Match(input,pattern,caseSensitive)
Perform a regex match.
input The input string to perform the match on (unaltered).
pattern The regex pattern string.
caseSensitive If the regex match is case sensitive ("True" or "False").
returns An array of match values, indexed by the location index in the input (position).

Replace(input,pattern,replacement,caseSensitive)
Perform a regex find and replace.
input The input string to perform the replacement on (unaltered).
pattern The regex pattern string.
replacement The regex replacement string.
caseSensitive If the regex replace is case sensitive ("True" or "False").
returns A modified version of the input string after the regex replace.

LDResources
Save and load resources to a binary file.
The resources are stored in a single file with the same name and location as the source, with extension sbres.
Resources indlude all ImageList images, all sounds played with Sound.Play, as well as optionally other files or variables.


AddFile AddText CleanTemp
ExtractFile Files Images
Load Save Sounds
Texts

AddFile(fileName)
Add any file to the resources to be stored.
fileName The full path to the file.
returns "SUCCESS" or "FAILED".

AddText(text)
Add text, or may be variable (including arrays) to the resources to be stored.
text The text or a Small Basic variable to add to the resources.

CleanTemp()
Delete temporary sound files.

ExtractFile(fileName)
Extract a saved file to the current directory (Program.Directory).
fileName The filename returned by Files method.
returns "SUCCESS" or "FAILED".

Files
Get an array of loaded files, that may be extracted with ExtractFile method.

Images
Get an array of loaded images, pre-loaded for use with ImageList.

Load()
Load all previously saved resources from the sbres file.
ImageList and sounds are all auto loaded ready for use.
Sound files are re-created in your %temp% folder since they are required by Sound.Play.

returns "SUCCESS" or "FAILED".

Save()
Save all resource to the sbres file.
This includes all ImageList images, pre-run sounds (Sound.Play) as well as any added files or text/variables.

returns "SUCCESS" or "FAILED".

Sounds
Get an array of loaded sounds, pre-loaded for use with Sound.Play.

Texts
Get an array list of all loaded text/variables.

LDScrollBars
GraphicsWindow ScrollBars - can be used for a scrolling game.

Warning - Do not alter the GraphicsWindow size using GraphicsWindow.Width or GraphicsWindow.Height AFTER scrollbars have been added.
In this case use LDGraphicsWindow.Width and LDGraphicsWindow.Height.

For large scrolling regions see Rasterize property.


Add HorizontalScroll KeyScroll
Modify MouseScroll Rasterize
ScrollBarChanged VerticalScroll Visibility

Add(width,height)
Add Scroll Bars to the GraphicsWindow.
The input width and height are those that can be scrolled to.
A value of 0 prevents a scrollbar appearing.

width The width of the scrollable region.
height The height of the scrollable region.

HorizontalScroll
Get or Set the horizontal ScrollBar position.

KeyScroll
Set if scrollbars will move with arrow keys "True" (default) or "False".

Modify(action)
Move scrollbars.
action Allowed actions include the following.
"PageDown", "PageUp", "PageLeft" and "PageRight"
"ScrollToTop", "ScrollToBottom", "ScrollToLeftEnd" and "ScrollToRightEnd"
"ScrollToHome", "ScrollToEnd"


MouseScroll
Set if scrollbars will move with mouse wheel "True" (default) or "False".
Hold the shift key down to scroll horizontally with mouse wheel.


Rasterize
Rasterize drawables "True" (default) or "False".
When more than 100 objects are drawn (not Shapes) SmallBasic will rasterise these to an image for performance reasons.
For a very large scrollable region this will run out of memory and can be disabled here.
If it is disabled, then don't use more than 100 drawable objects.
This property should be set before LDScrollBars.Add is called.


ScrollBarChanged
Event when a scroll operation occurs

VerticalScroll
Get or Set the vertical ScrollBar position.

Visibility
Get or Set the ScrollBars' visibility.
"True" or "False".


LDSearch
Bing online search methods.
Includes web, image, video, news and spelling suggestions.


Count GetImage GetNews
GetProof GetSpelling GetVideo
GetWeb Language

Count
The maximum number of web search results, default 50.

GetImage(search)
Do a Bing search for Web images.
search The search text.
returns An array of results, index url and value description.

GetNews(search)
Do a Bing search for Web news.
search The search text.
returns An array of results, index url and value description.

GetProof(text,mode)
Do a text spell check (proof). This is for longer text with more detailed information like in Word.
text The text to proof.
mode A mode "Proof" (default for longer text) or "Spell" (for short or single word checks).
returns An array of spelling and other suggestions or "" if no suggestions found.

GetSpelling(search)
Do a Bing search for Web spelling or alternative search suggestions.
search The search text.
returns An array of spelling or alternative suggestions or "" if no suggestions found.

GetVideo(search)
Do a Bing search for Web videos.
search The search text.
returns An array of results, index url and value description.

GetWeb(search)
Do a Bing search for Web sites.
search The search text.
returns An array (up to 50) of results, index url and value description.

Language
The language culture to use, default is current culture.
es-AR,en-AU,de-AT,nl-BE,fr-BE,pt-BR,en-CA,fr-CA,es-CL,da-DK,fi-FI,fr-FR,de-DE,zh-HK,en-IN,en-ID,en-IE,it-IT,ja-JP,ko-KR,en-MY,es-MX,nl-NL,en-NZ,no-NO,zh-CN,pl-PL,pt-PT,en-PH,ru-RU,ar-SA,en-ZA,es-ES,sv-SE,fr-CH,de-CH,zh-TW,tr-TR,en-GB,en-US,es-US


LDServer
Server and Client communication between computers.
Separate programs are required for the server and client - this is for the server.


AutoMessages Broadcast ClientConnected
ClientDisconnected ClientMessage Close
CloseDelay Disconnect GetClients
IP LastClient LastClientConnected
LastClientDisconnected LastClientMessage Port
SendMessage Start Stop

AutoMessages
Show TextWindow connection messages when in auto mode "True" (default) or "False".

Broadcast(message)
Send a message to all clients.
message The message may be any variable including an array.
returns A array of values "SUCCESS", "NOT_CONNECTED", "NO_CLIENT" or "FAILED" with the Client Name being the index.

ClientConnected
Event when a client connects.

ClientDisconnected
Event when a client disconnects.

ClientMessage
Event when a client sends a message to the server.

Close(clientName)
Disconnect and close (End) a client.
clientName The client name, usually Client1, Client2 etc.
A list of current clients can be obtained from the method GetClients or found from the ClientConnected event.

returns "SUCCESS", "NOT_CONNECTED", "NO_CLIENT" or "FAILED"

CloseDelay
A delay in ms (default 100) when disconnecting to allow a message to be sent before connection closed (Stop, Disconnect and Close).
This delay should also be set for clients in LDClient.CloseDelay.


Disconnect(clientName)
Disconnect a client.
clientName The client name, usually Client1, Client2 etc.
A list of current clients can be obtained from the method GetClients or found from the ClientConnected event.

returns "SUCCESS", "NOT_CONNECTED", "NO_CLIENT" or "FAILED"

GetClients()
Get a list of current connected clients.
returns An array of current client names or "" for none.

IP
The IP address of the server (it is defaulted to the current LAN IP).
If you want to use over the internet, then a web IP will be needed.


LastClient
The last client name.

LastClientConnected
The last client connected name.

LastClientDisconnected
The last client disconnected name.

LastClientMessage
The last client message.

Port
The windows port to use (default 100).

SendMessage(clientName,message)
Send a message to a client.
clientName The client name, usually Client1, Client2 etc.
A list of current clients can be obtained from the method GetClients or found from the ClientConnected event.

message The message may be any variable including an array.
returns "SUCCESS", "NOT_CONNECTED", "NO_CLIENT" or "FAILED"

Start(auto)
Start the server.
auto Enable auto message passing "True" or "False".
If this is used (recommended) then all client data is passed via server to all other clients,
and no processing of send and receive events is required.
The data is updated to arrays of data (indexed by client name) that is returned from the client Update methods.
The auto option should be the same for server and all clients.

returns The current connection parameter ip:port (e.g. "192.168.1.60:100"), or "FAILED".
This is the parameter to use to connect from the client.


Stop()
Stop the current server and close all clients.
returns "SUCCESS" or "FAILED"

LDSettings
The Settings library consists of helpers that allow programs to
store and retrieve user settings.


FilePath GetValue SetValue

FilePath
Gets or sets the file path for the settings file.

GetValue(name)
Gets the value for the setting identified by the specified name.
name The Name of the setting.
returns The Value of the setting.

SetValue(name,value)
Sets a value for a setting identified by the specified name.
name The Name of the setting.
value The Value of the setting.

LDShapes
Shapes extension utilities.

AddAnimatedGif AddAnimatedImage AddPolygon
AddRegularPolygon AddStar AnimateOpacity
AnimateRotation AnimateZoom AnimationCount
AnimationInterval AnimationPause AnimationResume
AnimationSet BrushColour BrushEllipse
BrushGradient BrushImage BrushPolygon
BrushRectangle BrushRoundedRectangle BrushShape
BrushText Centre FastMove
Font GetAllShapes GetAllShapesAt
GetColour GetLeft GetOpacity
GetProperties GetProperty GetTop
Height LastEventShape LastEventType
Move MoveLine MovePolygon
MoveTriangle Overlap OverlapBox
OverlapCircle OverlapDetail PenColour
PenStyle PenWidth RasteriseTurtleLines
RemoveTurtleLines ResetTurtle ReSize
RotateAbout SetImage SetProperty
SetShapeEvent SetSize SetTurtleImage
ShapeEvent Skew Width
ZIndex ZoomAll

AddAnimatedGif(imageName,repeat)
Creates an animated gif shape.
Do not add a very large number of these or performance may be degraded.

imageName The animated gif file (local or network) to load.
repeat Continuously repeat the animation "True" or "False".
returns The animated gif shape name.

AddAnimatedImage(imageName,repeat,countX,countY)
Creates an animation from a single image with multiple images on one layer.
Do not add a very large number of these or performance may be degraded.

imageName The image file (local or network) to load.
Can also be an ImageList image.

repeat Continuously repeat the animation "True" or "False".
countX The number of sub-images in the X direction.
countY The number of sub-images in the Y direction.
returns The animated shape name.

AddPolygon(points)
Creates a polygon shape.
points An array of coordinates for the polygon corners with the form points[i][1] = x, points[i][2] = y.

The number of points must be 3 or more.

returns The polygon shape name.

AddRegularPolygon(numPoint,radius)
Creates a regular polygon shape.
numPoint The number of polygon sides.
radius The centre to corner distance.
returns The regular polygon shape name.

AddStar(numPoint,innerRadius,outerRadius)
Creates a star shape.
Fun effects can be created with negative distances.

numPoint The number of star points.
innerRadius The centre to inner points' distance.
outerRadius The centre to outer points' distance.
returns The star shape name.

AnimateOpacity(shapeName,interval,count)
Set a shape to animate opacity, flash (fade out and in).
shapeName The shape or control to flash.
interval The interval in ms for a complete flash cycle.
A value of 0 will stop the flashing.

count The number of flashes.
A value of 0 will flash continuously.


AnimateRotation(shapeName,interval,count)
Set a shape to animate rotation (rotate continuously).
shapeName The shape or control to rotate.
interval The interval in ms for a complete 360 degree rotation.
A value of 0 will stop the rotation.
A value less than 0 will rotate anti-clockwise.

count The number of rotations.
A value of 0 will rotate continuously.


AnimateZoom(shapeName,interval,count,scaleX,scaleY)
Set a shape to animate zooming (in and out).
shapeName The shape or control to zoom.
interval The interval in ms for a complete zoom cycle.
A value of 0 will stop the zooming.

count The number of zoom cycles.
A value of 0 will zoom continuously.

scaleX The X zoom scale factor.
scaleY The Y zoom scale factor.

AnimationCount(shapeName)
Get the number of images in an animated image.
shapeName The animated image shape name.
returns The number of images in the animated image.

AnimationInterval
The update interval for animated images in ms (default 100).
A value of zero will pause all animated image updates, for example allowing AnimationSet to set images as required.
This is an internal timer that applies to all animated images that are not paused or completed a non-repeating cycle.


AnimationPause(shapeName)
Pause an animated image.
Paused images can still be updated using AnimationSet

shapeName The animated image shape name.

AnimationResume(shapeName)
Resume a previously paused animated image.
shapeName The animated image shape name.

AnimationSet(shapeName,image)
Reset animated image to a selected image.
shapeName The animated image shape name.
image The selected animated image number (indexed from 1).

BrushColour(shapeName,colour)
Set shape Brush colour.
shapeName The shape or control name.
colour The new brush colour.
returns None.

BrushEllipse(brush,x,y,width,height)
Draw an ellipse filled with a gradient of colours.
brush A previously created gradient or image brush (LDShapes.BrushGradient LDShapes.BrushImage).
x The x co-ordinate of the ellipse.
y The y co-ordinate of the ellipse.
width The width of the ellipse.
height The height of the ellipse.
returns None.

BrushGradient(colours,orientation)
Create a linear or radial gradient brush.
colours An array of colours to apply to the shape in a gradient.
orientation The orientation for the gradient.
"H" horizontal.
"V" vertical.
"DU" diagonally up.
"DD" diagonally down.
"R" radial (default if "")

returns The gradient brush name.

BrushImage(imageName)
Create an image brush.
These brushes should work anywhere that BrushGradient can be used.

imageName The image to load to the brush.
Value returned from ImageList.LoadImage or local or network image file.

returns The image brush name.

BrushPolygon(brush,points)
Draw a polygon filled with a gradient of colours.
brush A previously created gradient or image brush (LDShapes.BrushGradient LDShapes.BrushImage).
points An array of coordinates for the polygon corners with the form points[i][1] = x, points[i][2] = y.

The number of points must be 3 or more.

returns None.

BrushRectangle(brush,x,y,width,height)
Draw a rectangle filled with a gradient of colours.
brush A previously created gradient or image brush (LDShapes.BrushGradient LDShapes.BrushImage).
x The x co-ordinate of the rectangle.
y The y co-ordinate of the rectangle.
width The width of the rectangle.
height The height of the rectangle.
returns None.

BrushRoundedRectangle(brush,x,y,width,height,radius)
Draw a rounded rectangle filled with a gradient of colours.
brush A previously created gradient or image brush (LDShapes.BrushGradient LDShapes.BrushImage).
x The x co-ordinate of the rectangle.
y The y co-ordinate of the rectangle.
width The width of the rectangle.
height The height of the rectangle.
radius The radius of the rounded corners.
returns None.

BrushShape(shapeName,brush)
Set a shape Brush style as a gradient of colours.
shapeName The shape or control name.
brush A previously created gradient or image brush (LDShapes.BrushGradient LDShapes.BrushImage).
returns None.

BrushText(text,background,foreground)
Create a text brush.
These brushes should work anywhere that BrushGradient can be used.

text The text to add to the brush.
The current GraphicsWindow font is used.

background The background colour.
foreground The foreground (pen) colour.
returns The text brush name.

Centre(shapeName,x,y)
Centre the shape on a point, also works for zoomed shapes.
shapeName The shape or control name.
x The x coordinate of the centre.
y The y coordinate of the centre.
returns None.

FastMove(shapeName,x,y)
Moves the shape with the specified name to a new position.
This method is maximally optimised for speed.

shapeName The name of the shape to move.
x The x co-ordinate of the new position.
y The y co-ordinate of the new position.

Font(shapeName,family,size,bold,italic)
Set shape Font.
shapeName The shape or control name.
family The new font family name
See LDUtilities.FontList() for available font families.

size The new font size.
bold The new font bold state ("True" or "False").
italic The new font italic state ("True" or "False").
returns None.

GetAllShapes()
Get an array of all currently created shapes.
returns An array of shape names.

GetAllShapesAt(x,y)
Get an array of all of the shapes (if any) at the specified coordinates.
The coordinates could be the mouse coordinates for example.

x The X coordinate
y The Y coordinate
returns An array of shape names or "False".
For multiple shapes, the returned array is ordered from top visual layer to bottom.


GetColour(shapeName)
Get shape Brush and Pen colours.
shapeName The shape or control name.
returns A 3 element array
1) shape brush (or background) colour in hex format
2) shape opacity (0 to 100)
3) shape pen (or foreground) colour in hex format


GetLeft(shapeName)
Get the left position of a shape (works for triangles, polygons and lines).
Also works for shapes while animating.

shapeName The shape or control name.
returns The x coordinate of the left edge of the shape.

GetOpacity(shapeName)
Gets the opacity of a shape.
shapeName The name of the shape.
returns The opacity of the object as a value between 0 and 100. 0 is completely transparent and 100 is completely opaque.

GetProperties(shapeName)
Get a list of shape properties. These are .Net UIElement properties.
shapeName The shape or control name.
returns An array of properties and their values.

GetProperty(shapeName,property)
Get a shape property. This is a .Net UIElement property.
shapeName The shape or control name.
property The property name to get.
returns The value of the property.

GetTop(shapeName)
Get the top position of a shape (works for triangles, polygons and lines).
Also works for shapes while animating.

shapeName The shape or control name.
returns The y coordinate of the top edge of the shape.

Height(shapeName)
Get the shape's visible (including zoom) height.
shapeName The shape or control name.
returns The shape visible height.

LastEventShape
The last shape for which an event occured (ShapeEvent).

LastEventType
The last shape event type which an event occured (ShapeEvent). May be one of the following.
"MouseDown"
"MouseUp"
"MouseEnter"
"MouseLeave"
"GotFocus"
"LostFocus"


Move(shapeName,x,y)
Moves a triangle or polygon top-left position.
This method also works for lines (Shapes.AddLine).

shapeName The shape name (a triangle, polygon or line shape).
x The X (left) coordinate for the triangle, polygon or line.
y The Y (top) coordinate for the triangle, polygon or line.
returns None.

MoveLine(shapeName,x1,y1,x2,y2)
Moves a line shape.
shapeName The shape name (a line created with Shapes.AddLine).
x1 The first X coordinate to move the line to.
y1 The first Y coordinate to move the line to.
x2 The second X coordinate to move the line to.
y2 The second Y coordinate to move the line to.
returns None.

MovePolygon(shapeName,points)
Moves a polygon shape.
shapeName The shape name (a polygon created with LDShapes.AddPolygon).
points An array of new coordinates for the polygon corners with the form points[i][1] = x, points[i][2] = y.

The number of points must be 3 or more and can change with each call.

returns None.

MoveTriangle(shapeName,x1,y1,x2,y2,x3,y3)
Moves a triangle shape.
shapeName The shape name (a triangle created with Shapes.AddTriangle).
x1 The first X coordinate to move the triangle to.
y1 The first Y coordinate to move the triangle to.
x2 The second X coordinate to move the triangle to.
y2 The second Y coordinate to move the triangle to.
x3 The third X coordinate to move the triangle to.
y3 The third Y coordinate to move the triangle to.
returns None.

Overlap(shape1,shape2)
Checks for shape overlap (collision detection for any ellipse or rectangle shape types).
The first shape should be unZoomed and unRotated.

shape1 The first shape name.
shape2 The second shape name.
returns "True" or "False".

OverlapBox(shape1,shape2)
Checks for shape overlap of bounding boxes (collision detection).
shape1 The first shape name.
shape2 The second shape name.
returns "True" or "False".

OverlapCircle(shape1,shape2)
Checks for shape overlap of bounding circles (collision detection).
shape1 The first shape name.
shape2 The second shape name.
returns "True" or "False".

OverlapDetail
Following a call to an Overlap method, this property provides additional detail abut the intersection.
Result may be one of:
"Empty" - no intersection
"FullyContains" - shape1 is completely inside shape2
"Intersects" - overlap but neither is fully contained
"FullyInside" - shape2 is completely inside shape1


PenColour(shapeName,colour)
Set shape Pen colour.
shapeName The shape or control name.
colour The new pen colour.
returns None.

PenStyle(shapeName,dash,space)
Set shape Pen style (dash, dot etc).
shapeName The shape name.
dash The dash length.
space The space length.
returns None.

PenWidth(shapeName,width)
Set shape Pen width.
shapeName The shape or control name.
width The new pen width.
returns None.

RasteriseTurtleLines()
Rasterise all turtle trail lines.
When the number of turtle trails is large the program may slow due to the number of line shapes (trails) present.
This converts the turtle trails from line shapes to background drawings.


RemoveTurtleLines()
Remove all turtle trail lines.

ResetTurtle()
Reset the Turtle after a GraphicsWindow.Clear().
returns None.

ReSize(shapeName,width,height)
Resize shape width and height (an absolute version of zoom).
shapeName The shape or control name.
width The shape width.
height The shape height.
returns None.

RotateAbout(shapeName,x,y,angle)
Rotate a shape about a point.
shapeName The shape name.
x The X coordinate to rotate the shape about.
y The Y coordinate to rotate the shape about.
angle The angle in degrees to rotate the shape.
returns None.

SetImage(shapeName,imageName)
Set or change an image in a button or image shape.
shapeName The image or button name.
imageName The image to load.
Value returned from ImageList.LoadImage or local or network image file.

returns None.

SetProperty(shapeName,property,value)
Set a shape property. This is a .Net UIElement property.
shapeName The shape or control name.
property The property name to set.
value The value to set the property to.

SetShapeEvent(shapeName)
Register a shape to record mouse events: MouseDown, MouseUp, MouseEnter, MouseLeave, GotFocus and LostFocus.
shapeName The shape or control to add.

SetSize(shapeName,width,height)
Reset the size of a shape as if it was created with the new size.
The position (top left point) is unchanged.

shapeName The shape or control name.
width The shape width.
height The shape height.
returns None.

SetTurtleImage(imageName,size)
Set the turtle to an image.
imageName The image to load for the turtle.
Value returned from ImageList.LoadImage or local or network image file.

size The size to scale the turtle to (default turtle is 16).

ShapeEvent
Event when a shape event occurs to a registered shape (SetShapeEvent)

Skew(shapeName,angleX,angleY)
Skews the shape with the specified name by the specified angles.
shapeName The name of the shape to skew.
angleX The angle to skew the shape in the X direction.
angleY The angle to skew the shape in the Y direction.
returns None.

Width(shapeName)
Get the shape's visible (including zoom) width.
shapeName The shape or control name.
returns The shape visible width.

ZIndex(shapeName,z_index)
Set shape z index (layer position negative are background and positive are foreground - default 0).
shapeName The shape or control name.
z_index The z-index (zero, positive or negative interger).
returns None.

ZoomAll(scaleX,scaleY)
Zoom all shapes.
scaleX The x-axis zoom level.
scaleY The y-axis zoom level.

LDShell
Functions for extended file infos, LNK/URL shortcuts and Shell apps. (All code and methods provided by Pappa Lapub).

AllDetails ApplyVerbOn CascadeWindows
DateTimeSettings DTIconsHide DTIconsOn
DTIconsShow DTIconsToggle ExploreFolder
GetAllDetailNamesFor GetAllDetailsFor GetAllVerbsFor
GetDetail GetSetting GetSystemInfo
LinkCreate LinkGetProperty LinkSetProperty
Name OpenFolder RestoreWindows
RunBox SelectFolder ShellLink
ShellLinkGet ShellLinkSet ShowDesktop
ShowFileProperties SpecialFolderConstants SpecialFolderList
SpecialFolderPaths SpecialFolders StartSettings
Switch3D TileAllHoriz TileAllVert
ToggleDesktop Version

AllDetails
Gets all available extended properties as Array ("idx=property name;", where -1=Infotip, 0=Name, .. up to 286=Total bitrate (or ev. ?Full bitrate? on engl systems)).

ApplyVerbOn(path,verb)
Apply the given Verb (contextmenu item) for the given file or folder.
List of available Verbs (for a filetype or folder) under 'GetAllVerbsFor'.

path The full file- or folder path.
verb The Verb to apply (case- and '&' insensitive).
returns "SUCCESS" on success, else "FAILED".

CascadeWindows()
Orders all opended windows in cascades on the desktop (Revert with RestoreWindows).

DateTimeSettings()
Shows the dialog for date- and time settings.

DTIconsHide()
Hides all desktop icons.

DTIconsOn
Gets weather the desktop icons are currently visible ("True" or "False").

DTIconsShow()
Shows all hidden desktop icons again.

DTIconsToggle()
Toggles the view of all desktop icons automatically (On/Off).

ExploreFolder(path)
Opens a specified folder in a Windows Explorer window. (parent folder for existing file path). In new tab in QTTabBar.
path The folder path to open in explorer (file path opens parent folder). The folder must exist.

GetAllDetailNamesFor(path,step1)
Gets the names of all available extended properties for a given file or folder as Array (up to max. 316, w/o -1=Infotip).
path The full file- or folder path.
step1 Indizes in speps by 1? "True" or "False" (default, real property ID).
returns The names of all available extended properties as Array ("idx=property name;...", w/o Infotip) on success, else "FAILED".

GetAllDetailsFor(path)
Gets all available extended properties for the given file or folder as Array (up to max. 316, without -1=Infotip).
path The full file- or folder path.
returns All available extended properties as Array ("property name=value;...", without Infotip) on success, else "FAILED".

GetAllVerbsFor(path)
Gets all available Verbs (contextmenu items) for a given filetype or folder as Array.
Applying of a Verb on file/folder under see 'ApplyVerbOn'.

path The full file- or folder path.
returns All available Verbs as Array ("idx=verb;...", w/o '&') on success, else "FAILED".

GetDetail(path,infoType)
Gets the value of an extended property for a given file or folder.
path The full file- or folder path.
infoType The ID number or name of the property (eg. -1="Infotip"/"", 0="Name", 1="Size", etc.)
ID numbers and names of available properties under s. 'AllDetails'.

returns The value of the property if available, else "". "FAILED" on failure (eg. missing path).
Infotip lines separated by lf and ending with crlf.


GetSetting(value)
Gets values for global Shell settings (s. folder opions-view, CheckedStatus).
value An integer constant for the value to get (eg. 1, 2, 4, "8", "32" etc.).
returns "True" or "False" on success, else "FAILED".
example
ShowAllObjects = SBShell.GetSetting(1)
ShowExtensions = SBShell.GetSetting(2)
ShowInfoTip = SBShell.GetSetting(8192)
ShowSuperHidden = SBShell.GetSetting(262144)


GetSystemInfo(info)
Gets a given Systeminformation.
info The name of the value to get. Options:
"DirectoryServiceAvailable", "DoubleClickTime", "ProcessorLevel", "ProcessorSpeed", "ProcessorArchitecture", "PhysicalMemoryInstalled", "IsOS_DomainMember"
(Only XP: "IsOS_Professional", "IsOS_Personal").

returns The queried value on success, else "" or "FAILED".

LinkCreate(shortcut,target)
Creates a new lnk/url shortcut (Shell32). Further editing with 'LinkSetProperty'.
shortcut The full path for the new lnk/url shortcut file.
target The full path of the target file/-folder resp. URL address.
returns The full file path of the created shortcut on success, else "FAILED".

LinkGetProperty(shortcut,property)
Gets properties of a lnk/url shortcut link, like target pfad, arguments etc.
shortcut The full path of the lnk/url shortcut link file.
property The property to get (case independent, * for Urls) like:
"Target" target path *
"Args" arguments
"Folder" working directory
"Desc" comment *
"HotKey" shortcut key comb * (default: 0)
"Style" window style * (1 normal, 3 max, 7 min)
"Icon" icon path

returns The value of the property if available or "". "FAILED" on failure.

LinkSetProperty(shortcut,target,args,folder,desc,icoPath,icoIdx,hotkey,style)
Modifies properties of an existing lnk/url shortcut link, like target path, arguments etc. (* for Urls).
shortcut The full path of an existing lnk/url shortcut link file.
target * The full path of the target file/-folder resp. URL address.
args Startparameter when launching the shortcut or "" (for url).
folder The full path of the start folder or "" (for url).
desc * Comment or description for the shortcut or "".
icoPath * Full path of the icon file for the shortcut or "".
icoIdx * Index of the icon in the icon file (default: 0, for .ico).
hotkey * keys combination to launch the shortcut link (default: 0).
style * Window style when launching the shortcut (default: 1 normal, 3 max, 7 min).
returns The full file path of the modified shortcut on success, else "FAILED".

Name
Gets the name of the executing assembly for this extension.

OpenFolder(path)
Opens explorer with the given file-/folder path (parent folder for existing file path). In new tab in QTTabBar.
path Opens the specified folder (file path opens parent folder). The folder must exist.

RestoreWindows()
Restores all minimized windows in the taskbar (after ShowDesktop, TileAll.., CascadeWindows) again.

RunBox()
Shows the Run(box) Dialog.

SelectFolder(title,initDir)
Shows a folder selection dialog.
title The title to show on the dialog.
initDir The start folder when the dialog opens or "" for last selected folder (default: Computer).
returns The full folder path after selection or "" when canceled, else "FAILED".

ShellLink(shortcut,target)
Creates a new lnk/url shortcut (IWshRuntimeLibrary). Further editing with 'ShellLinkSet'.
shortcut The full path for the new lnk/url shortcut file.
target The full path of the target file/-folder resp. URL address.
returns The full file path of the created shortcut on success, else "FAILED".

ShellLinkGet(shortcut,property)
Gets properties of a lnk/url shortcut link, like target pfad, arguments etc. (IWshRuntimeLibrary).
shortcut The full path of the lnk/url shortcut link file.
property The property to get (case independent, * for Urls) like:
"Target" target path *
"Args" arguments
"Folder" working directory
"Desc" comment *
"HotKey" shortcut key comb * (default: 0)
"Style" window style * (1 normal, 3 max, 7 min)
"Icon" icon path,Idx (default: ,0)

returns The value of the property if available or "". "FAILED" on failure.

ShellLinkSet(shortcut,target,args,folder,desc,icon,hotkey,style)
Modifies properties of an existing lnk/url shortcut link, like target path, arguments etc. (* for Urls) (IWshRuntimeLibrary).
shortcut The full path of an existing lnk/url shortcut link file.
target * The full path of the target file/-folder resp. URL address.
args Startparameter when launching the shortcut or "" (for url).
folder The full path of the start folder or "" (for url).
desc * Comment or description for the shortcut or "".
icon * The full path (resp. path,Idx) of the icon for the shortcut link or "". 'Idx' is Index of the icon in in the file (default: 0, for .ico).
hotkey * keys combination to launch the shortcut link (default: 0).
style * Window style when launching the shortcut (default: 1 normal, 3 max, 7 min).
returns The full file path of the modified shortcut on success, else "FAILED".

ShowDesktop()
Minimizes all opened windows into the taskbar and showes the desktop (Revert with RestoreWindows).

ShowFileProperties(filePath)
Opens the shell properties dialog for a given file or folder path (GW is needed for that, not available from TW or Console).
filePath The full file- or folder path.

SpecialFolderConstants
Gets a list of all CSIDL numbers and their according special System-/Shell folder names as Array ("csidl=folder name;").

SpecialFolderList(csidl)
Gets all items in a special system/shell folder (upper level only).
csidl The CSIDL number of the system folder (0 to 47, constants and names of available folders under s. SpecialFolderConstants).
returns The names of all objects in the system folder as Array (only upper level) on success, else "FAILED".
example
eg. CSIDL for:
3 Control panel
5 my documents
8 Recent
9 SendTo
10 RecBin
16 Desktop folder
17 Computer
20 Fonts
32 Temp Inet Files


SpecialFolderPaths
Gets a list of all special System-/Shell folder names and their according folder paths as Array ("folder name=path;").

SpecialFolders
Gets a list of all special System folders as Array ("folder name=path;"). For Shell folders s. 'SpecialFolderPaths'.

StartSettings()
Shows the dialog for startmenü/taskbar settings.

Switch3D()
Orders all opended windows in a 3D stack on the desktop to select through (with arrow keys).

TileAllHoriz()
Orders all opened windows horizontally tiled on the desktop (Revert with RestoreWindows).

TileAllVert()
Orders all opened windows vertically tiled on the desktop (Revert with RestoreWindows).

ToggleDesktop()
Toggles the view of the (windowless) desktop on and off (s. ShowDesktop/RestoreWindows).

Version
Gets the current file version of this extension (else 0.0.0.0).

LDSort
Sort arrays (the sorting of character strings may be case sensitive or insensitive).

ByIndex ByValue ByValueWithIndex
CaseSensitive

ByIndex(array)
Sort an array of any dimension by the index (key).
array The array to sort.
returns A sorted array.

ByValue(array)
Sort a 1D array by the value (the indices are re-numbered from 1).
array The array to sort.
returns A sorted array.

ByValueWithIndex(array)
Sort a 1D array by the value (the indices are unchanged, but sorted).
array The array to sort.
returns A sorted array.

CaseSensitive
String comparisons are case sensitive "True" or "False".

LDSound
A Sound Recorder. A microphone (may be internal) is required.
System sounds can also be played (if they are set appropriately).


Asterisk Beep Exclamation
Hand MusicPlayTime Pause
Question Resume Start
Stop Tone Volume

Asterisk()
Play system Asterisk sound.

Beep()
Play system Beep sound.

Exclamation()
Play system Exclamation sound.

Hand()
Play system Hand sound.

MusicPlayTime(fileName)
Gets the play time for a music file.
fileName The full path of the music file e.g. "C:\Users\Public\Music\song.mp3".
returns The file play time in seconds (0 if failed).

Pause()
Pause a recording.

Question()
Play system Question sound.

Resume()
Resume a paused recording.

Start()
Start recording sound.

Stop(wavFile)
Stop and save current sound recording.
wavFile The full path to a wav file to save the recording.
The extension will be set to ".wav" if it is not already.

returns "SUCCESS" or "FAILED".

Tone(frequency,duration)
Play a system tone sound with frequency and duration.
Uses the motherboard speaker (not the sound card) and may be low quality or not available.

frequency The tone frequency (from 37 to 32767 Hz).
duration The tone duration in ms.

Volume(command)
Change the volume of sounds.
command One of the following options to change the sound volume level.
"Up" increase volume level.
"Down" decrease volume level.
"Mute" toggle between mute and un-mute volume level.


LDSpeech
The Speech library allows text to be spoken and speech recognition.

LastSpoken LastSpokenConfidence Listen
Speak Speed Vocabulary
Voice Voices Volume

LastSpoken
Text of the last speech spoken (and recognised) by the computer.

LastSpokenConfidence
The last speech spoken detection confidence of correctness (0 to 1).

Listen
Event when speech is spoken (and recognised) by the computer.
A good microphone, lots of training or consise dictionary are needed to get decent results.


Speak(text)
Speak some text.
text Text to be spoken.
returns None.

Speed
Speed of speech (-10 to 10).

Vocabulary(dictionary)
Set a vocabulary of words and phrases for the speech regonition to use.
If this is unset, then a large language vocabulary is used and the results will generally be less good (unusable).
Also distinct phrases can have a better recognition than single words.

dictionary An array of words or phrases to be recognised.
If it is empty, then the default language vocabulary is used.

returns None.

Voice
The current voice.

Voices()
Returns an array of available voices.
returns An array of available voices.

Volume
Volume of speech (0 to 100).

LDStatistics
Performs statistics on a 1D array of data.

Count Differentiate DistBinomial
DistNormal DistTriangular DistUniform
Frequency GeometricMean HarmonicMean
Integrate InterpolateX InterpolateY
Max Mean Median
Min Mode PDev
SDev SetArray Sum
Sum2

Count
The number of data points.

Differentiate(array)
Calculate the derivative of a 1D data array.
array The array to differentiate (array[x]=y).
returns A 1D array of the Derivative of the input array.

DistBinomial(n,p)
Create an array with a Binomial distribution.

This is like the probablity of getting k heads from 20 (n) coin tosses, with a probablity for each toss getting a heads of 0.5 (p).

n The number of tries.
p The probablity of success for each try.
returns A 1D array of the Binomial distribution, probablity of k successes (Array[k] = y).

DistNormal(distMean,distSTD,size)
Create an array with a Normal distribution.
distMean The mean of the distribution.
distSTD The standard deviation of the distribution.
size The number of points.
returns A 1D array of the Normal distribution (Array[x] = y).

DistTriangular(rangeMin,rangeMax,size)
Create an array with a Triangular distribution.
rangeMin The minimum value.
rangeMax The maximum value.
size The number of points.
returns A 1D array of the Triangular distribution (Array[x] = y).

DistUniform(rangeMin,rangeMax,size)
Create an array with a Uniform distribution.
rangeMin The minimum value.
rangeMax The maximum value.
size The number of points.
returns A 1D array of the Uniform distribution (Array[x] = y).

Frequency(array,bins,normalised)
Calculate a frequency distribution from array of data.
array The array to create the frequency distribution from.
bins The number of bins spanning the data.
normalised Is the frequency normalised to integrate to 1 ("True" or "False").
returns Frequency distribution as an array (array[bin]=frequency).

GeometricMean
The geometric mean of the data points (all points > 0).

HarmonicMean
The harmonic mean of the data points (all points > 0).

Integrate(array)
Calculate the integral of a 1D data array.
array The array to integrate (array[x]=y).
returns A 1D array of the Integral of the input array.

InterpolateX(array,y)
Interpolate a 1D data array to find the value of x(y).

The values of y should be monotonically increasing with x.

array The array to interpolate (array[x]=y).
y The value of y (may be an array of y values).
returns The interpolated value x or an array of x values.

InterpolateY(array,x)
Interpolate a 1D data array to find the value of y(x).

The values of x should be monotonically increasing.

array The array to interpolate (array[x]=y).
x The value of x (may be an array of x values).
returns The interpolated value y or an array of y values.

Max
The maximum value of the data points.

Mean
The arithmetic mean of the data points.

Median
The median of the data points.

Min
The minimum value of the data points.

Mode
The mode of the data points.

PDev
The population deviation of the data points.

SDev
The standard deviation of the data points.

SetArray(array)
Set a 1D array of numbers to perform some statistics on.

This command must be called before any statistics are calculated.

array The array to perform statistics on.
returns An array of the data sorted.

Sum
The sum of data points.

Sum2
The sum of the squares of the data points.

LDStopwatch
Accurate system stopwatches.

Add DelayUpTo ElapsedMilliseconds
ElapsedTicks Frequency Reset
Restart Start Stop

Add()
Create a new stopwatch.
returns The stopwatch name.

DelayUpTo(delay)
Delay up to a maximum interval since the last time this is called.
Useful in a game loop to maintain an even play speed.

delay The maximum delay in ms.

ElapsedMilliseconds(stopwatch)
Gets the total elapsed time measured in milliseconds.
stopwatch The stopwatch name.
returns Elapsed milliseconds.

ElapsedTicks(stopwatch)
Gets the total elapsed time measured in timer ticks for very short intervals.
stopwatch The stopwatch name.
returns Elapsed ticks.

Frequency
Get the frequency of the stopwatch timer in ticks per second.
This represents the finest resolution of time your hardware can measure with ElapsedTicks.


Reset(stopwatch)
Stops the current stopwatch and resets the elapsed time to 0.
stopwatch The stopwatch name.

Restart(stopwatch)
Stops the current stopwatch, resets the elapsed time to 0 and restarts the stopwatch.
stopwatch The stopwatch name.

Start(stopwatch)
Starts or resumes the current stopwatch.
stopwatch The stopwatch name.

Stop(stopwatch)
Stops the current stopwatch.
stopwatch The stopwatch name.

LDText
Text manipulations.

Compare FastStringAppend FastStringClear
FastStringGet FastStringNew FindAll
GetHeight GetWidth Replace
Split Trim

Compare(text1,text2)
Lexically compare 2 text strings, the comparison is case insensitive and culture invariant.
text1 The first string to compare.
text2 The second string to compare.
returns An integer:
less than zero (text1 is less than text2)
zero (strings are equal)
greater than zero (text1 is greater than text2)


FastStringAppend(fastString,text)
Append a string value to a fast string object.
fastString A fast string object.
text The test to append.

FastStringClear(fastString)
Reset a fast string object to "".
fastString A fast string object.

FastStringGet(fastString)
Get the current text in a fast string.
fastString A fast string object.
returns The current fast string text.

FastStringNew()
Create a new fast string appending object.
returns The fast string append object.

FindAll(text,find)
Get all occurances of a subtext in some text.
text The text to search.
find The subtext to search for.
returns An array with the positions of the start of each subtext or 0 for none.

GetHeight(text)
Get the height in pixels that text will be displayed in the GraphicsWindow with the current font.
The GraphicsWindow must be open to use this method.

text The text to get the height.
returns The width in pixels.

GetWidth(text)
Get the width in pixels that text will be displayed in the GraphicsWindow with the current font.
The GraphicsWindow must be open to use this method.

text The text to get the width.
returns The width in pixels.

Replace(text,find,replace)
Find and Replace all occurances of one text with another.
text A text to modify.
find The text to find and replace.
replace The text to replace the found text.
returns A modified copy of the input text.

Split(text,separator)
Split a variable into an array delimiated by a separator.
text A text string to split.
separator A separator string (e.g. " "), or an array of separator strings.
returns A result array of deliminated texts.

Trim(text)
Return a string with all leading and trailing 'white space' removed.
text A string to trim.
returns A trimmed copy of the input string.

LDTextWindow
TextWindow utilities.
Includes low level keyboard events.


Capture Encoding Hide
KeyDown KeyUp LastKey
Print Read ReadNumber
SendKey SetColour SetColours
Show

Capture(fileName,border)
Save the TextWindow as an image file (png, jpg, bmp, gif, tiff or ico).

The window must be visible and a short delay may be required after updating the window before calling.

fileName The file to save the image to (*.png, *.jpg, *.bmp, *.gif, *.tiff or *.ico).
If this is set to "", then the image is created internally as an ImageList.

border Include the window border ("True" or "False").
returns The ImageList image if fileName is "", otherwise if output to a file, then "" is returned.

Encoding
Set extended encoding for the TextWindow.
Allowed values are:
"ASCII" (default), "Unicode", "UTF7", "UTF8"


Hide()
Hide the TextWindow.
Replacement for standard method that may fail (do not mix these methods).


KeyDown
Low level event when a key is pressed down.
This event is independent of any window focus, i.e. not just for TextWindow or GraphicsWindow.


KeyUp
Low level event when a key is released.
This event is independent of any window focus, i.e. not just for TextWindow or GraphicsWindow.


LastKey
Last key pressed or released.

Print(border)
Print the TextWindow contents.

The window must be visible and a short delay may be required after updating the window before calling.

border Include the window border ("True" or "False").
returns None.

Read(delay)
Read from a TextWindow with a maximum delay.
This sends a Return (ENTER) to the TextWindow after the delay.
If the user presses Return before the delay is completed, then no further action is taken.

delay A maximum delay in ms before the Read is terminated.
returns The text that was read from the TextWindow.

ReadNumber(delay)
Read a number from a TextWindow with a maximum delay.
This sends a Return (ENTER) to the TextWindow after the delay.
If the user presses Return before the delay is completed, then no further action is taken.

delay A maximum delay in ms before the Read is terminated.
returns The number that was read from the TextWindow.

SendKey(window,key)
Send a key to a window. This is the same a typing the key into a window.
window The window title e.g. TextWindow.Title or GraphicsWindow.Title.
key The key to send e.g. "Return"

SetColour(index,colour)
Replace one of the standard TextWindow colours.
There are 16 available colours, by default they are indexed 0 to 15:
Black (0), DarkBlue (1), DarkGreen (2), DarkCyan (3), DarkRed (4), DarkMagenta (5), DarkYellow (6), Gray (7),
DarkGray (8), Blue (9), Green (10), Cyan (11), Red (12), Magenta (13), Yellow (14), White (15).
Note that you can still use TextWindow.BackgroundColor and TextWindow.ForegroundColor to use the new colours (with the original colour names), alternatively the colours can be selected using LDTextWindow.SetColours from the indices.
The colours must be set using either method before they are applied.

index The stanadard colour index colour to replace.
colour Any colour to replace a standard colour with.

SetColours(fgIndex,bgIndex)
Set the current foreground and background colour indices.
fgIndex The foreground colour index (0 to 15).
bgIndex The background colour index (0 to 15).

Show()
Show the TextWindow and give it focus.
Replacement for standard method that may fail (do not mix these methods).


LDTimer
Additional timers.

Add AddTick Interval
LastTimer Pause Resume
Tick

Add()
Create a new timer. All timers created with this method call the event subroutine defined by Tick.
returns The timer name.

AddTick(tick)
Create a new timer. This timer only calls its own event subroutine.
tick The event subroutine for this timer.
returns The timer name.

Interval(timer,interval)
Starts or resumes a timer.
timer The timer name.
interval Sets the interval (in milliseconds) specifying how often the timer should raise the Tick event. This value can range from 10 to 100000000.

LastTimer
The last timer created with Add that raised an event.

Pause(timer)
Pauses a timer. Tick events will not be raised.
timer The timer name.

Resume(timer)
Resumes a timer from a paused state. Tick events will now be raised.
timer The timer name.

Tick
Raises an event when a timer created with Add ticks.

LDTranslate
Language translation methods.

Languages Translate

Languages()
Get an array of language codes and their language.
The array indices are the required language codes for the Translate method.

returns The 1D array of language codes and names.

Translate(input,languageFrom,languageTo)
Translate a text from one language to another.
input The text to translate.
languageFrom The language code to translate from.
languageTo The language code to translate to.
returns The translated text.

LDUnits
A general editable unit conversion system.
All units and dimensions are case sensitive.
A base unit consists of a single dimension and name, and are all independent.
A derived unit consists of a description, name and units definition consisting of base or other derived units, and optional additive term, usually 0.
A unit is parsed by separting . / + - and *, then recursively resolving derived unit conversions, bracketed () terms first.
Values (especially those with a decimal point '.' or minus '-') should be contained in ().
A unit may be prefixed by a prefix or number value (e.g. m is mili 0.001, K is kilo 1000 etc).
Any unit may be postfixed by a power.
A typical unit may be "mile/hr", "m/s2" or "MJ/day" etc and can be any combination of base and derived units.
Any pair of unis that are dimensionally the same can be converted.
An additive value is only used for non-compound unit conversions (e.g. C to F).
To avoid obscure prefix unit conflicts use a full prefix name (e.g. min could be 60 seconds or 0.001 inches, the latter should be milliin).
Currency conversions are updated daily.


AddBaseUnit AddConstant AddDerivedUnit
Convert Export GetBaseUnits
GetConstants GetDerivedUnits GetDimensions
GetErrors GetPrefixes Import

AddBaseUnit(dimension,name)
Add a base unit to the system.
dimension The base unit dimension (e.g. TEMPERATURE).
name The unit name (be careful it doesn't confict with existing unit names).

AddConstant(description,name,value)
Add a dimensionless constant to the system.
description An optional long name or description of the constant.
name The constant name (be careful it doesn't confict with existing constant names).
value The derived constant value.

AddDerivedUnit(description,name,units,add)
Add a derived unit to the system.
description An optional long name or description of the derived unit.
name The unit name (be careful it doesn't confict with existing unit names).
units The derived unit definition.
add An optional addition term.

Convert(value,fromUnit,toUnit)
Convert a value from one unit to another.
value The value to convert.
fromUnit The units to convert from.
toUnit The units to convert to.
returns The converted value or "FAILED" (usually non-existant unit or inconsistant dimensions).

Export()
Export the current unit system to a file (units.txt in the current program folder).

GetBaseUnits()
Get a list of current base units.
returns An array of available base units, indexed by unit dimension.
The array values are the base unit names.


GetConstants()
Get a list of current constants.
returns An array of available constants, indexed by constant name with (description).
The array values are the constant values.


GetDerivedUnits()
Get a list of current derived units.
returns An array of available derived units, indexed by unit name with (description).
The array values are the base (or derived units) used for conversion.


GetDimensions(unit)
Get an array of dimensions for a unit.
unit The unit to get dimensins of.
returns An array indexed by dimension and value of the dimension power or "".

GetErrors()
Get an array of error messages if a Convert fails or conflicts are found for added units or constants.
returns Array of error messages or "".

GetPrefixes()
Get a list of current prefixes.
returns An array of available prefices, indexed by prefix name.
The array value is the prefix value.


Import()
Import a unit system from a file (units.txt in the current program folder).

LDUtilities
General

AvailableCultures CaptureScreen CleanTemp
ColourList CSVDeliminator CurrentCulture
DPIX DPIY FixFlickr
FontList ForceInvoke GetCultureInvariantNumber
GetCurrentCultureNumber GetNextMapIndex IsNumber
KeyDown NetworkURL Priority
SendClick ShowErrors ShowFileErrors
ShowNoShapeErrors ShowPrintPreview UseDispatcher
UseExpression Version

AvailableCultures()
Get an array of available cultures.
returns An array indexed by culture names, with the value set to a description.

CaptureScreen(fileName)
Save the entire visible screen as an image file (png, jpg, bmp, gif, tiff or ico).
A short delay may be required after updating the window before calling.

fileName The file to save the image to (*.png, *.jpg, *.bmp, *.gif, *.tiff or *.ico).
If this is set to "", then the image is created internally as an ImageList.

returns The ImageList image if fileName is "", otherwise if output to a file, then "" is returned.

CleanTemp()
Delete all Small Basic related files from the temp folder.
These are files with extensions tmp, pdb and dll.
Other applications may also use these, so best to use with no other apps running.

returns The number of files deleted.

ColourList()
Get an array of available colour names.
returns An array of colour names.

CSVDeliminator
A single character deliminator for reading and writing CSV files
Default ","


CurrentCulture
Get or set the current culture.

DPIX
Get the display device X DPI (dots per inch) resolution.

DPIY
Get the display device Y DPI (dots per inch) resolution.

FixFlickr()
Fix the Flickr object

FontList()
Get an array of available font names.
returns An array of font names.

ForceInvoke
Experimental option to speed some interactions with SmallBasicLibrary objects.
0 no force (default), 1 force Invoke (serial), 2 force BeginInvoke (async)


GetCultureInvariantNumber(input)
Get a number expressed in the culture invariant form.
A number must be culture invariant in order to be treated as a number in calculations.
A current culture number is how it is input or output.
For example "3.14" is culture invariant, while "3,14" is French culture.

input A number expressed in the current culture.
returns The number expressed in culture invariant form or input on failure.

GetCurrentCultureNumber(input)
Get a number expressed in the current culture.
A number must be culture invariant in order to be treated as a number in calculations.
A current culture number is how it is input or output.
For example "3.14" is culture invariant, while "3,14" is French culture.

input A culture invariant number.
returns The number expressed in the current culture or input on failure.

GetNextMapIndex(listName)
Get the next integer for object names.
For example Buttons are labeled "Button1", "Button2" etc.
This method returns the integer index that would be used for the next object added.

listName The map (list) type, valid listNames (Case sensitive) are:
"Button"
"TextBox"
"ImageList"
"Ellipse"
"Image"
"Line"
"Rectangle"
"Text"
"Triangle"
"Polygon"
"Control"

returns The next object index to be used (0 on failure).

IsNumber(input)
Test if the input will be treated by SmallBasic as a number.
This is a culture invariant number, e.g. "3.14", but not "3,14" or "24x".

input The input to test.
returns "True" or "False"

KeyDown(key)
Get if a key is down.
Useful for simplified keyboard game control.

key The key to get down state, eg "Space".
returns The key down state ("True" or "False")

NetworkURL
Set the web address for use with LDNetwork if gamedata and highscore methods are handled on another server.

Priority
Experimental option to speed some dispatcher interactions with SmallBasicLibrary objects.
1 to 10, (default 7, Render)


SendClick(x,y,button)
Send a mouse click at the specified screen location. Note this is Mouse.MouseX/Y, not GraphicsWindow.MouseX/Y.
x The screen x position to click, -1 uses current mouse position.
y The screen y position to click, -1 uses current mouse position.
button The button to press ("Left", "Right" or "Middle")

ShowErrors
Report any detected errors to TextWindow "True" (default) or "False"

ShowFileErrors
Report any detected file not found errors to TextWindow "True" (default) or "False"

ShowNoShapeErrors
Report any detected shapeName not found in method "True" (default) or "False"

ShowPrintPreview
Show the print preview window when printing with LDGraphicsWindow.Print and LDTextWindow.Print ("True" or "False")
Default "True"


UseDispatcher
Experimental option to speed some interactions with SmallBasicLibrary objects.
"True" (default) or "False"


UseExpression
Experimental option to speed some interactions with SmallBasicLibrary objects.
"True" (default) or "False"


Version()
Gets the current version of the extension and displays a window with this information and a changelog.
returns The current version.

LDVector
3D vector algebra methods, useful for LD3DView manipulations.
All vectors or points are a 3 element array indexed by 1,2,3.


Add AngleBetween CrossProduct
DotProduct Length Multiply
Normalise Rotate RotatePoint
Subtract

Add(vector1,vector2)
Add 2 vectors.
vector1 The first vector.
vector2 The second vector.
returns The resulting vector or "" on failure.

AngleBetween(vector1,vector2)
Get the angle between 2 vectors.
vector1 The first vector.
vector2 The second vector.
returns The angle (in degrees) between the vectors or "" on failure.

CrossProduct(vector1,vector2)
Get the vector cross product of 2 vectors.
vector1 The first vector.
vector2 The second vector.
returns The vector cross product or "" on failure.

DotProduct(vector1,vector2)
Get the dot product of 2 vectors.
vector1 The first vector.
vector2 The second vector.
returns The dot product or "" on failure.

Length(vector)
Get the length of a vector.
vector The vector.
returns The vector length or "" on failure.

Multiply(vector,scalar)
Multiply a vector by a scalar.
vector The vector.
scalar A scalar number to resize the vector.
returns The rescaled vector or "" on failure.

Normalise(vector)
Normalise a vector to unit length.
vector The vector.
returns A rescaled vector of unit length or "" on failure.

Rotate(vector,about,angle)
Rotate one vector about a direction defined by a second vector.
vector The vector to rotate.
about The vector axis direction to rotate about.
angle The angle (in degrees) to rotate the vector by.
returns The rotated vector or "" on failure.

RotatePoint(point,center,about,angle)
Rotate a point about a specified center point and direction.
point The point to rotate.
center The point to rotate about.
about The vector axis direction to rotate about.
angle The angle (in degrees) to rotate the point by.
returns The rotated point or "" on failure.

Subtract(vector1,vector2)
Subtract one vector from another.
vector1 The first vector.
vector2 The second vector (to subtract from the first).
returns The resulting vector or "" on failure.

LDWaveForm
Create PPM (Pulse Position Modulation) sound signals to control RC (remote control) devices.
See http://blogs.msdn.com/b/smallbasic/archive/2014/05/10/smallbasic-pulse-position-modulation-extension.aspx.
Additonally create simple sound waveforms, which can be played asynchronously at the same time.

SlimDX runtme for .Net 4.0 requires to be installed before this object can be used (http://slimdx.org/download.php).


Amplitude Async Loop
Pan PlayDX7 PlayHarmonics
PlaySineWave PlaySquareWave PlayWave
PlayWavFile Stop Volume

Amplitude
Signal amplitude (maximum is 2^15 = 32768, default is 20262).

Async
Play the sound asynchronously (return before sound completes), "True" or "False" default.

Loop
Continuously loop the sound, "True" or "False" default.
Lopping sounds can be stopped by calling Stop method as they are playing.


Pan
The left (-100) to right (100) stereo panning, (default 0).

PlayDX7(channels)
Play DX7.
channels An array of values for each channel (values between 0 and 1, usually 8 channels).
returns The wave name or "" on failure.

PlayHarmonics(frequency,duration,harmonics)
Play a user defined wave form as a sum of harmonics.
frequency Frequency (HZ).
duration Duration (ms). If this is negative then the waveform is repeated (-duration) times.
harmonics Harmonic amplitudes.
This is an array, where the index is a harmonic multiple of the base frequency (2, 3, etc) and the value is the relative amplitude of the harmonic.
A square wave can be formed by (https://en.wikipedia.org/wiki/Square_wave):
For i = 3 To 21 Step 2
harmonics[i] = 1/i
EndFor
squareWave = LDWaveForm.PlayHarmonics(256,1000,harmonics)

returns The wave name or "" on failure.

PlaySineWave(frequency,duration)
Play a Sine wave form.
frequency Frequency (HZ).
duration Duration (ms). If this is negative then the waveform is repeated (-duration) times.
returns The wave name or "" on failure.

PlaySquareWave(frequency,duration)
Play a square wave form.
frequency Frequency (HZ).
duration Duration (ms). If this is negative then the waveform is repeated (-duration) times.
returns The wave name or "" on failure.

PlayWave(frequency,duration,waveform)
Play a user defined wave form.
frequency Frequency (HZ).
duration Duration (ms). If this is negative then the waveform is repeated (-duration) times.
waveform Form for the repeating wave.
This is an array, where the index is an increasing relative time (the actual value is normalised to the frequency) and the value is an amplitude (-1 to 1).
Example of a triangular wave would be "0=-1;1=1;2=-1;"

returns The wave name or "" on failure.

PlayWavFile(fileName,duration)
Play a wav file.
fileName The *.wav file.
duration Duration (ms). If this is negative then the waveform is repeated (-duration) times.
returns The wave name or "" on failure.

Stop(waveName)
Stop a playing sound.
waveName The sound wave name.

Volume
The volume to play the waveform (0 to 100).

LDWebCam
Provides access to a webcam.

Effect EffectBlocks EffectBlue
EffectBulge EffectContrast EffectCyan
EffectFishEye EffectFuzzy EffectGamma
EffectGray EffectGreen EffectHue
EffectInverse EffectJagged EffectLightness
EffectMagenta EffectNone EffectOilPaint
EffectParameter EffectPixelate EffectPosterise
EffectRed EffectReflect EffectRotate
EffectSaturation EffectSnow EffectSwirl
EffectYellow End Interval
Pause PreWin8Mode Resume
Snapshot SnapshotToFile SnapshotToImageList
Start

Effect
The current effect.
Can be set using the Effect properties.
(e.g. LDWebCam.Effect = LDWebCam.EffectGray).


EffectBlocks

EffectBlue

EffectBulge

EffectContrast

EffectCyan

EffectFishEye

EffectFuzzy

EffectGamma

EffectGray

EffectGreen

EffectHue

EffectInverse

EffectJagged

EffectLightness

EffectMagenta

EffectNone

EffectOilPaint

EffectParameter
Effect parameter - see LDImage effects for the parameter values for effects.

EffectPixelate

EffectPosterise

EffectRed

EffectReflect

EffectRotate

EffectSaturation

EffectSnow

EffectSwirl

EffectYellow

End()
End the webcam display, call this before removing the webcam shape.

Interval
The webcam update minimim delay between updates in ms (default 20).
It will in practice be larger in many cases, especialyy with effects set.


Pause()
Pause the webcam updates.

PreWin8Mode
Use pre-Windows 8 method.
"True" or "False" (default).


Resume()
Resume the webcam updates.

Snapshot()
Take a snapshot and save it as a jpg with a SaveAs dialog.

SnapshotToFile(fileName)
Take a snapshot and save it to a file.
fileName File to save jpg snapshot to.

SnapshotToImageList()
Take a snapshot and save it to the ImageList (memory loaded image).
returns Returns the name of the image that was loaded.

Start(width,height)
Start a webcam display object (SmallBasic shape). If this is called more than once, multiple copies af the same webcam image are be generated.

This object can be moved, zommed, rotated etc using the standard Shapes methods.

Maximum resolution usually at 640 x 480 pixels, smaller may be faster.

width The width of the webcam display object.
height The height of the webcam display object.
returns The name of the webcam display object.

LDWindows
Create additional GraphicsWindows.

All variables are shared between windows (global scope).
GraphicsWindow events must be registered for each window, but the event subroutine can be shared.
All other events can be registered once as normal.
All commands or methods apply to the current active window, set using CurrentID.
The original or default GraphicsWindow has id 0.


Activated Active Create
CurrentID LastActivated

Activated
Event when a window is activated.
Use this event with care - not recommended for most cases.


Active
Get or set the id of a window active state (top most).
-1 if no active windows.


Create()
Create a new GraphicsWindow.
returns An id for the created window.

CurrentID
Get or set the current window id.

LastActivated
Last window activated.

LDxml
xml file parsing methods.

AddNode Attributes AttributesCount
ChildrenCount FirstChild FirstNode
FromArray LastChild NextSibling
NodeInnerText NodeName NodeType
Open Parent PreviousSibling
RemoveNode RenameRoot Save
Switch ToArray View

AddNode(name,attributes,text,location)
Add a new node.
The current node is unchanged, it is not updated to be the new node.

name The new node element name.
attributes An array of attributes (values indexed by attribute name) for the new node or "".
text Inner text for the new node or "".
location Where the node is inserted.
"Append" - insert at the end of current node's child nodes.
"Prepend" - insert at the start of current node's child nodes.
"Before" - insert before the current node.
"After" - insert after the current node.

returns "SUCCESS" or "FAILED".

Attributes
Get an array of attribute text values indexed by attribute name or "" on failure.

AttributesCount
Get the number of attributes of the current node.

ChildrenCount
Get the number of children of the current node.

FirstChild()
Move the current node to the first child node if there is one.
returns "SUCCESS" or "FAILED".

FirstNode()
Set the current node to the first document node.
returns "SUCCESS" or "FAILED".

FromArray(array)
Performs the inverse function of ToArray method, create an xml document from an array definition.
array A Small Basic array with the correct format.
returns A name for the document or "FAILED".

LastChild()
Move the current node to the last child node if there is one.
returns "SUCCESS" or "FAILED".

NextSibling()
Move the current node to the next sibling node if there is one.
returns "SUCCESS" or "FAILED".

NodeInnerText
Get the inner text of the current node and all children or "" on failure.

NodeName
Get the name of the current node or "" on failure.

NodeType
Get the type of the current node.
May be one of many types, but commonly "Element" or "Text".


Open(fileName)
Open an existing xml file. This must be called before any other methods can be used.
fileName The full path to the xml file to open.
If this is "", then a new empty xml document is created.

returns A name for the document or "FAILED".

Parent()
Move the current node to the parent node if there is one.
returns "SUCCESS" or "FAILED".

PreviousSibling()
Move the current node to the previous sibling node if there is one.
returns "SUCCESS" or "FAILED".

RemoveNode()
Remove the current node and all child nodes.
The current node is reset to the previous sibling or parent node if no previous sibling exists.

returns The new current node "SIBLING", "PARENT" or "FAILED".

RenameRoot(name)
Rename the root element (default is "root").
name The name of the root element.
returns "SUCCESS" or "FAILED".

Save(fileName)
Save the current xml document to a file.
fileName The full path to the file to write the xml.
returns "SUCCESS" or "FAILED".

Switch(docName)
Switch to another open xml document. The current node for all documents are preserved.
docName The name returned by Open method.
returns "SUCCESS" or "FAILED".

ToArray()
Convert the current xml document to a Small Basic array.
The structure and depth of the array may be quite complex.
Each node has optional arrays "Attributes", and "Children" or "Data".
If there are are child nodes then they are indexed first by number to deliminate multiple children with the same name.

returns A Small Basic array or "FAILED".

View()
View XML for dubugging purposes.
returns None.

LDZip
Zip file compression utilities.

Remove UnZip Zip
ZipList

Remove(zipFile,files)
Remove a file (or directory with all sub files) from an existing zip archive.
zipFile The zip archive to remove a file from.
files An array of files to remove from the zip archive.
A single file or directory may also be deleted.
Any directories will be recursively removed from the zip.

returns An error message or "".

UnZip(zipFile,directory)
Uncompress a zip archive.
zipFile The zip archive to uncompress.
directory A directory to uncompress the files to (existing files will be overwritten).
returns An error message or "".

Zip(zipFile,files)
Compress files to a zip archive.
zipFile The zip archive file to create.
files An array of files to append to the zip archive.
A single file or directory may also be set.
Any directories will be recursively added to the zip.
Any white space in files or directories will be replaced with "_".

returns An error message or "".

ZipList(zipFile)
List the files in a zip archive.
zipFile The zip archive.
returns An array of file names in the zip or an error message.