Abs (Double) As Double
Returns the absolute value of the number specified.
Dim d As Double d=Abs(23.9) //returns 23.9 d=Abs(-23.9) //returns 23.9
Acos (Double) As Double
Returns the arccosine of the value specified. The arccosine is the angle whose cosine is value. The returned angle is given in radians.
Dim d As Double Const PI=3.14159265358979323846264338327950 d=Acos(.5) //returns 1.0471976 d=Acos(.5)*180/PI //returns 60
Asc (String) As Integer
Returns as an Integer, the ASCII value for the first character of a String.
Dim a As Integer a = Asc("@") //returns 64
The Asc function returns the code point for the first character in the String passed. Characters 0 through 127 are the standard ASCII set. They will be the same on practically every platform. Asc returns the code point for whatever encoding the string is in. If the string is in MacRoman, you get the code point specified by MacRoman, and so forth.
If you need to get the ASCII code of the first byte of the string rather than the first character, use the AscB function.
AscB (String) As Integer
Returns as an Integer, the value for the first byte of a String.
MsgBox Str(AscB("a")) //returns 97 MsgBox Str(AscB("A")) //returns 65
The AscB function returns the code for the first byte in the String passed. If you need to get the character code of the first character of the string rather than the first byte, use the Asc function.
AscB should be used instead of Asc when the string represents binary data or when your application will run on a one-byte character set (such as the US system) and you want case-sensitivity.
Asin (Double) As Double
Returns the arcsine of the value specified.
Dim d as Double Const PI=3.14159265358979323846264338327950 d=Asin(.5) //returns 0.5235988 d=Asin(.5)*180/PI //returns 30
The arcsine is the angle whose sine is value. The Asin function returns the angle (in radians) of the sine passed to it. To express the arcsine in degrees, multiply the result by 180/PI.
Atan (Double) As Double
Returns the arctangent of the value specified. The arctangent is the angle whose tangent is value.
Dim d as Double Const PI=3.14159265358979323846264338327950 d=Atan(1) //returns 0.785398 (PI/4 radians) d=Atan(1)*180/PI // returns 45
Atan2 (Double, Double) As Double
Returns the arctangent of the point whose coordinates are x and y. The arctangent is the angle from the x-axis to a line drawn through the origin (0,0) and a point with coordinates x, y.
Dim d as Double Const PI=3.14159265358979323846264338327950 d=Atan2(1,0) //returns 1.57 d=Atan2(1,0)*180/PI //returns 90
The BitAnd method returns a UInt64 that is the result of comparing each bit of the two integers passed and assigning 1 to the bit position in the integer returned if both bits in the same position in the integer passed are 1. Otherwise, 0 is assigned to the bit position.
Dim i As Integer i = BitAnd(5, 3) // returns 1
The BitOr method returns a UInt64 that is the result of comparing each bit of the two integers passed and assigning 1 to the bit position in the integer returned if either of the bits in the same position in the integers passed are 1. Otherwise, 0 is assigned to the bit position.
Dim i As Integer i = BitOr(5, 3) // returns 7
The BitXor method returns a UInt64 that is the result of comparing each bit of the two integers passed and assigning 1 to the bit position in the integer returned if both bits in the same position in the integers passed are not equal. Otherwise, 0 is assigned to the bit position.
Dim i As Integer i = BitXor(5, 3) // returns 6
Timecode from Devices with Sony 9-pin protocol and compatible usually comes in BCD format (4 Bytes FFSSMMHH). This function converts it to a string (HH-MM-SS-FF)
dim sTC, sBCD as string //assign value to sBCD //by reading the value from a device sTC = BCDToTCString(sBCD)
Ceil (Double) As Double
Returns the value specified rounded up to the nearest Integer.
Dim d as Double d=Ceil(1.234) //returns 2
This Command is available only in Device Drivers. It is used to update a drop down list with parameter values.
ChangeCMD_MinMax("CueSpot","P1",res)
See Device Editor Automatic Parameters for more information.
CheckSum8Bit(string) As Integer
Returns the Check-sum of a string. Each byte of the string is treated as binary value (not as ASCII code) and is added to the Check-sum. If the Check-sum exceed 256 in “roll over” to zero.
Dim c as integer c = CheckSum8Bit("ABC") // returns 198 c = CheckSum8Bit(chr(1)+chr(2)+chr(3)) // returns 6
CheckSumMod255(string) As Integer
Returns the Check-sum of a string. Each byte of the string is treated as binary value (not as ASCII code) and is added to the Check-sum. The result is the Sum Mod 255.
Returns the XOR Checksum od a given string
dim sXor as string sXour = checksumXOR("My String to Checksum")
Returns the CRC16 Checksum of a given string
dim sCrc as string sCrc = CRC16("My String to Checksum")
Chr (Double) As String
Returns the character whose ASCII value is passed.
Dim Tab,CR,MyA as String Tab=Chr(9) //returns a tab CR=Chr(13) //returns carriage return MyA = Chr(65) //returns "A"
The Chr function will return a single byte String when running on single byte systems and return a double byte string when running on double byte systems. If you need to get a single byte string regardless of whether the system software is single or double byte, use the ChrB function.
ChrB (Double) As String
Returns a single byte String whose value is passed.
Dim s as String s=ChrB(32) //returns a space s=ChrB(13) //returns carriage return
The ChrB function returns a single byte string whose value is specified. ChrB should be used rather than Chr when value represents binary data.
If you need to get a single byte string when running on single byte system software and a double byte string when running on double byte system software, use the Chr function.
If you need to specify a code point above 127, use the Chr property of the TextEncoding class. With it, you specify both the encoding and the character code in that encoding.
Const name = value
Declares a value as a local constant.
Const Pi=3.14159265358979323846264338327950
The Const statement can be used in place of the Dim statement followed by an assignment statement when you are sure that the value of the variable should not change within the method. Using Const instead of Dim provides a convenient way to manage such values.
A Const statement can be placed anywhere in a method, including inside a conditional structure, such as an If statement, or a looping structure. Constants declared in this manner are local to the method.
Cos (Double) As Double
Returns the cosine of the given angle.
Dim d as Double Const PI=3.14159 d=Cos(45*PI/180) //returns 0.707
CountFields (String, String) As Integer
Returns the number of values (fields) in the string passed that are separated by the separator string passed. If the source string is binary data or you require case-sensitivity, use CountFieldsB instead.
The example below returns 5.
Dim count as Integer Dim s as String s="Dan*Smith*11/22/69*5125554323*Male" count=CountFields(s, "*")
The following example returns three because it counts the null “field” after the (unnecessary) final field delimiter.
Dim count as Integer Dim s as String s="Dan*Smith*" count=CountFields(s, "*")
Returns a CRC16 calculated checksum
Delay (String)
Waits the given number in ms. The given number must be a string.
Delay("1000") //Wait 1 Second
Dim i as integer i = 500 Delay(str(i)) //Wait 500 ms
Exit
The Exit statement causes control to exit a loop and jump to another line of code without the loop conditions being satisfied. The optional keywords enable you to control where execution will resume.
For i= 0 to 255 For j= 0 to 255 If myArray(i,j) = 23 then Exit For i End if Next Next
Exp( Double) As Double
Returns “e” to the power of the value specified.
Dim d as Double d=Exp(10) //returns 22026.4657948
Converts a string representing a double i.e. “1.204”) to a four byte float string
This is the code behind the function call
Sub FloatStringToStr(fString as string) As String //converts a string representing a float value ("1.2302") to a four byte float string Dim mb As MemoryBlock = New MemoryBlock(4) dim s,stmp as string dim FloatVal as Single FloatVal = CDbl(fString) mb.SingleValue(0) = FloatVal // automatic conversion between memoryblock and strings!! =) s = mb stmp = mid(s,4,1)+mid(s,3,1)+mid(s,2,1)+mid(s,1,1) return stmp End Sub
Floor( Double) As Double
Returns the value specified rounded down to the nearest Integer.
Dim d as Double d=Floor(1.234) //returns 1
For…Next
Executes a series of statements a specified number of times. The For Each…Next statement is a variation that executes once for each element of a one-dimensional array.
The counter variable in a For statement can be declared inside the For statement rather than externally, as a local variable. For example, the code:
Dim i as Integer For i=0 to 10 //your code goes here Next
The following example uses the DownTo keyword to decrement the counter:
Dim i as Integer For i=5 DownTo 1 Step 1 Beep Next
Format (Double, String) As String
Returns as a String a formatted version of the number passed based on the parameters specified. The Format function is similar to the way spreadsheet applications format numbers. Format will use the information based on the user's locale even if the user's locale is a Unicode-only locale.
Syntax
result = Format( number, formatSpec )
The formatSpec is a string made up of one or more special characters that control how the number will be formatted:
Character | Description |
---|---|
# | Placeholder that displays the digit from the value if it is present.If fewer placeholder characters are used than in the passed number, then the result is rounded. |
0 | Placeholder that displays the digit from the value if it is present.If no digit is present, 0 (zero) is displayed in its place. |
. | Placeholder for the position of the decimal point. |
, | Placeholder that indicates that the number should be formatted with thousands separators. |
% | Displays the number multiplied by 100. |
( | Displays an open paren. |
) | Displays a closing paren. |
+ | Displays the plus sign to the left of the number if the number is positive or a minus sign if the number is negative. |
- | Displays a minus sign to the left of the number if the number is negative. There is no effect for positive numbers. |
E or e | Displays the number in scientific notation. |
\character | Displays the character that follows the backslash. |
The absolute value of the number is displayed. You must use the + or - signs if you want the sign displayed.
Although the special formatting characters are U.S. characters, the actual characters that will appear are based on the current operating system settings. For example, Windows uses the settings in the user's Regional and Language Options Control Panel. Formatting characters are specified in similar ways on other operating systems.
The formatSpec can be made up of up to three formats separated by semicolons. The first format is the format to be used for positive numbers. The second format is the format to be used for negative numbers and the third format is the format to be used for zero.
The following are several examples that use the various special formatting characters.
Format | Number | Formatted String |
---|---|---|
#.## | 1.786 | 1.79 |
#.0000 | 1.3 | 1.3000 |
0000 | 5 | 0005 |
#% | 0.25 | 25% |
###,###.## | 145678.5 | 145,678.5 |
#.##e | 145678.5 | 1.46e+5 |
-#.## | -3.7 | -3.7 |
+#.## | 3.7 | +3.7 |
#.##;(#.##);\z\e\r\o | 3.7 | 3.7 |
#.##;(#.##);\z\e\r\o | -3.7 | (3.7) |
#.##;(#.##);\z\e\r\o | 0 | zero |
The following example returns the number 3560.3 formatted as $3,560.30.
Dim s as String s=Format(3560.3, "\$###,##0.00")
returns a string that contains a Timecode in the format “hh-mm-ss-ff”. The function uses the Global Framerate (Main Menu → Options) to determine the frames per second. The following example converts a framecode to a timecode.
dim tc as string tc = FramecodeToTimecode(123456)
Returns the day of the current month (1..31)
Result integer
Result integer (Sunday=0, Monday = 1…)
Gets the string value of a device variable.
In a Device Driver, the syntax is
dim s as string s = GetDeviceVar("VariableName")
In a Task, the syntax is
dim s as string s = GetDeviceVar("DeviceName","VariableName")
All Parameters are strings
Gets the String Value of a Global variable
Dim s as String s = GetGlobalVar("Test")
This Function call is not available in Device Drivers.
Result integer
Result integer
Result integer
Result string
This function returns a Timecode Time string. The format is HH:MM:SS:FF (FF = Frames). To determine the Timecode format, the function need a parameter for the framerate (fps)
Dim res as string dim framerate as integer framerate = 25 res = GetTime(framerate)
Result integer
Result integer
Hex (Integer) As String
Returns as a String the hexadecimal version of the number passed.
If the value is not a whole number, the decimal value will be truncated.
You can specify binary, hex, or octal numbers by preceding the number with the & symbol and the letter that indicates the number base. The letter b indicates binary, h indicates hex, and o indicates octal.
Dim hexVersion As String hexVersion=Hex(5) //returns "5" hexVersion=Hex(75) //returns "4B" hexVersion=Hex(256) //returns "100"
HexToStr (String) As String
Returns as a String hexadecimal numbers converted to string
dim s as string s = HexToStr("414243") // Returns "ABC", because "A" has ASCII code &h41 or 65 decimal, // "B" has ASCII code &h42 or 66 decimal etc.
If…Then…Else
Conditionally executes a group of statements, depending on the value of a Boolean expression.
When executing an If statement, the condition is tested. If condition is True, the statements associated with the If statement following the Then statement are executed. If condition is False and an Else clause follows, its statements will be executed. If condition is False and there is no Else clause or it is preceded by an ElseIf statement, the condition following the ElseIf statement is tested. After executing the statements following Then, ElseIf or Else execution continues with the statement that follows End If.
If error=-123 Then Beep MsgBox "Whoops! An error occured." End If
Dim theNumber As Integer Dim digits As Integer theNumber=33 If theNumber<10 Then digits=1 ElseIf theNumber<100 Then digits=2 ElseIf theNumber<1000 Then digits=3 Else digits=4 End If
InStr (Integer, String, String) As Integer
Returns the position of the first occurrence of a String inside another String. The first character is numbered 1.
Dim first As Integer first = InStr("This is a test", "t") //returns 1 first = InStr("This is a test", "is") //returns 3 first = InStr(4, "This is a test", "is") //returns 6 first = InStr("This is a test", "tester")//returns 0
InStrB (Integer, String, String) As Integer
If the find string is not found within the source string, 0 (zero) is returned. InStrB is case-sensitive; it treats source as a series of raw bytes. It should be used instead of InStr when the string represents binary data or when your application will run in a one-byte character set (such as the US system) and you want case-sensitivity.
Dim first As Integer first = InStrB("This is a test", "T") //returns 1 first = InStrB("This is a test", "t") //returns 11 first = InStrB("This is a test", "is") //returns 3 first = InStrB(4, "This is a test", "is") //returns 6 first = InStrB("This is a test", "tester")//returns 0 first = InStrB("This Is a test", "Is") //returns 6
Left (String, Integer) As String
Returns the first n characters in a source String.
Dim s As String s=Left("Hello World", 5) //returns "Hello" s="Hello World" s=s.Left(5) //returns "Hello"
LeftB (String, Integer) As String
Returns the first n bytes in a source String.
The LeftB function returns bytes from the source string starting from the left side (as the name implies). If you need to read characters rather than bytes, use the Left function.
This example uses the LeftB function to return the first 5 bytes from a string.
Dim s As String s=LeftB("Hello World", 5) //returns "Hello" s="Hello World" s=s.LeftB(5) //returns "Hello"
Len (String) As Integer
Returns the number of characters in the specified String.
Dim n As Integer n=Len("Hello world") //returns 11 Dim s as String s="Hello World" n=s.Len //returns 11
LenB (String) As Integer
Returns the number of characters in the specified String.
LenB treats string as a series of bytes, rather than a series of characters. It should be used when string represents binary data. If you need to know the number of characters in string rather than the number of bytes, use the Len function.
Log (Double) As Double
Returns the natural logarithm of the value specified.
Dim d As Double d=Log(10) //returns 2.3025851
Lowercase (String) As String
Converts all characters in a String to lowercase characters.
Dim s As String s=Lowercase("tHe Quick fOX") //returns "the quick fox" s=Lowercase("THE 5 LAZY DOGS") //returns "the 5 lazy dogs" s="tHe Quick fOX" s=s.Lowercase /returns "the quick fox"
LTrim (String) As String
Returns the String passed with leading (left side) whitespaces removed.
Dim s as String s=LTrim(" Hello World ") //Returns "Hello World " s=" Hello World " s=s.LTrim //Returns "Hello World "
Max (Double, Double) As Double
Returns the largest value passed to it.
Dim d As Double d=Max(3.01, 4.05) //returns 4.05 d=Max(3.012, 3.011, 1.56) //returns 3.012
Microseconds As Double
Returns the number of microseconds (1,000,000th of a second) that have passed since the user's computer was started.
Dim minutes As Integer minutes=Microseconds/1000000/60 MsgBox "Your computer has been on for "+ Str(minutes)+" minutes."
Because modern operating systems can stay running for so long, it's possible for the machine's internal counters to “roll over.” This means that if you are using this function to determine how much time has elapsed, you may encounter a case where this time is inaccurate.
Mid (String, Integer, Integer) As String
Returns a portion of a String. The first character is numbered 1.
Dim s As String s = Mid("This is a test", 6) //returns "is a test" s = Mid("This is a test", 11, 4) //returns "test" s="This is a test" s=s.Mid(11,4) //returns "test"
MidB (String, Integer, Integer) As String
Returns a portion of a String. The first character is numbered 1.
Dim s As String s=MidB("This is a test", 6) //returns "is a test" s=MidB("This is a test", 11, 4) //returns "test" s="This is a test" s=s.MidB(11,4) //returns "test"
MidB treats source as a series of bytes, rather than a series of characters. MidB should be used when source represents binary data. If you need to extract characters rather than bytes, use the Mid function. To determine the number of bytes in a String, use the LenB function.
Min (Double, Double) As Double
Returns the smallest of the numbers passed.
Dim d As Double d=Min(3.01, 4.05) //returns 3.01 d=Min(3.012, 3.011) //returns 3.011
Convert Milliseconds to Timecode. Returns a string that contains a Timecode in the format “hh-mm-ss-ff”. The function uses the Global Framerate (Main Menu → Options) to determine the frames per second. The following example converts a framecode to a timecode.
dim tc as string tc = msToTimecode(1000) // tc = 00-00-01-00
Nil
Used to determine if an object is nil (no value).
NthField (String, String, Integer) As String
Returns a field from a row of data. The first field is numbered 1. If you need to parse binary data, use NthFieldB instead.
This example returns “Smith”
Dim field As String field=NthField("Dan*Smith*11/22/69*5125554323*Male","*",2) //Field = smith
In the example above, the * is a field delimiter. The string “Dan*Smith*11/22/69*5125554323*Male” has 5 fields if * is the delimiter.
If / is choosen as delimiter, then the string has 3 fields:
Result = NTHField(StringWithFields, Delimmiter, Position)
Returns a field from a row of data. NthFieldB is identical to NthField except that it treats the source data as binary data. The first field is numbered 1.
This example returns “Smith”
Dim field As String field = NthFieldB("Dan*Smith*11/22/69*5125554323*Male", "*", 2)
Using the second syntax:
Dim s, field As String s = "Dan*Smith*11/22/69*5125554323*Male" field = s.NthFieldB("*", 2)
Oct (Integer) As String
Returns as a String, the octal version of the number passed.
Dim OctVersion As String OctVersion=Oct(5) //returns "5" OctVersion=Oct(75) //returns "113" OctVersion=Oct(256) //returns "400"
Pow (Double, Double) As Double
Returns the value specified raised to the power specified.
This example uses the Pow function to return four raised to the power of seven.
Dim d As Double d=Pow(4,7) //returns 16384
Redim Array(x,y)
Resizes the passed array.
This example reduces the aNames array to 11 elements.
Redim aNames(10)
This example adds 10 elements to the aNames array
Redim aNames( Ubound(aNames)+10)
This example reduces the aPeople array to 11 elements for the first dimension and 6 elements for the second dimension
Redim aPeople(10,5)
The Redim method is used to increase or reduce the number of elements in the array specified. Arrays are zero-based (the first element is zero) so you resize the array using a number that is one less than the number of elements you actually want. The number of parameters passed is the number of dimensions of the array being resized.
Rem any comment
Used to add comments to your code.
Replace (String, String, String) As String
Replaces the first occurrence of a String with another String.
Dim result As String result=Replace("The quick fox","fox","rabbit") //returns "The quick rabbit" result=Replace("The quick fox","f","b") //returns "The quick box" result=Replace("The quick fox","quick","") //returns "The fox"
ReplaceB (String, String, String) As String
Replaces the first occurrence of oldString in sourceString with newString. ReplaceB is the byte version of Replace.
ReplaceB is case-sensitive; it treats sourceString as a series of raw bytes. It should be used instead of Replace when the string represents a series of bytes or when your application will run in a one-byte character set (such as the US system) and you want case-sensitivity.
ReplaceAll (String, String, String) As String
Replaces all occurrences of a String with another String.
Dim result As String result=ReplaceAll("xyxyxy","x","z") //returns "zyzyzy" result=ReplaceAll("The quick fox"," ","") //returns "Thequickfox" result="The Quick Fox" result=result.ReplaceAll(" ",",") //returns "The,Quick,Fox"
ReplaceAllB (String, String, String) As String
The ReplaceAllB function replaces all occurrences of oldString in sourceString with newString. ReplaceAllB is case-sensitive because it treats the source string as a series of raw bytes.
ReplaceAllB is case-sensitive; it treats sourceString as a series of raw bytes. It should be used instead of ReplaceAll when the string represents a series of bytes or when your application will run in a one-byte character set (such as the US system) and you want case-sensitivity.
Right (String, Integer) As String
Returns the last n characters from the String specified.
Dim s As String s=Right("Hello World", 5) //returns "World" s="Hello World" s=s.Right(5) //returns "World"
RightB (String, Integer) As String
The RightB function returns bytes from the source string starting from the right side (as the name implies). RightB treats source as a series of bytes rather than a series of characters. It should be used when source represents binary data. If you need to read characters rather than bytes, use the Right function.
Rnd As Double
Returns a randomly generated number in the range 0 ⇐ Rnd < 1. The equivalent functionality is provided by the Random class as a special case. The Random class also provides additional options, such as a random number selected from a Normal distribution.
Round (Double) As Double
Returns the value specified rounded to the nearest Integer.
Dim d as Double d=Round(1.499) //returns 1 d=Round(1.500) //returns 2
RTrim (String) As String
Returns the String data type passed with trailing (right side) whitespaces removed.
Dim s as String s=RTrim(" Hello World ") //Returns " Hello World" s=" Hello World " s=s.RTrim //Returns " Hello World"
Rtrim uses the list of unicode “whitespace” characters at http://www.unicode.org/Public/UNIDATA/PropList.txt.
Select Case
Executes one of several groups of statements, depending on the value of an expression.
The Select Case statement is useful when there are several possible conditions that must be checked. Unlike an If statement, the Select Case statement will exit as soon as it finds a matching Case expression and executes any statements that follow the Case expression up to the next Case expression. If there are no Case expressions that match, the elseStatements are executed. The expression Case Else can be used as a synonym for Else. The Case statement can accept several types of expressions. The expression can be a single value, a comma-delimited list of values, a function that returns a value, a range of values specified with the 'To“ keyword, or an expression that uses the “Is” keyword to do an equality or inequality test. You can combine types of expressions, separating them by commas Here are some examples:
Case 2, 4, 6, 8 //several values Case 2 To 5 //range of values using To Case 2 To 5, 7,9,11 //Both separate values and range Case myFunction(x) // a Function Case Is >= 42 // greater than/equal to operator Case Is <19 //less than operator
Dim d as New MessageDialog //declare the MessageDialog object Dim b as MessageDialogButton //for handling the result d.icon= MessageDialog.GraphicCaution //display warning icon d.ActionButton.Caption="Save" d.CancelButton.Visible= True //show the Cancel button d.CancelButton.Cancel= True//esc key works for Cancel d.AlternateActionButton.Visible= True //show the "Don't Save" button d.Message="Save changes before closing?" d.Explanation="If you don't save your changes, you will lose " _ +"all that important work you did since your last coffee break." b=d.ShowModal //display the dialog Select Case b //b is a MessageDialogButton Case d.ActionButton //determine which button was pressed. //user pressed Save Case d.AlternateActionButton //user pressed Don't Save Case d.CancelButton //user pressed Cancel End Select
Sets a Device Variable to a new Value.
In a Device Driver, the syntax is
SetDeviceVar(VarName,NewValue)
In a Script, the syntax is
SetDeviceVar(DeviceName,VarName,NewValue)
All Parameters are Strings
// All Parameters are Strings SetGlobalVar(VarName,NewValue)
This Function call is not available in Device Drivers and Event Condition scripts, only in Tasks
Sin (Double) As Double
Returns the sine of the value specified.
Dim d As Double Const PI=3.14159265358979323846264338327950 d=Sin(0.5) //returns 0.4794255 d=Sin(30*PI/180) //returns .5
Converts a Single to a four byte single string
This is the code behind the function call
Sub SingleToStr(FloatVal as single) as String //converts a single (i.e. 0.023) to a four byte float string Dim mb As MemoryBlock = New MemoryBlock(4) dim s,stmp as string mb.SingleValue(0) = FloatVal // automatic conversion between memoryblock and strings!! =) s = mb stmp = mid(s,4,1)+mid(s,3,1)+mid(s,2,1)+mid(s,1,1) return stmp End Sub
Sqrt (Double) As Double
Returns the square root of the value specified.
Dim d As Double d=Sqrt(16) //returns 4
Str (Double) As String
Returns the String form of the value passed.
Dim s As String s=Str(123) //returns "123" s=Str(-123.44) //returns "-123.44" s=Str(123.0045) //returns "123.0045" Const Pi=3.14159265358979323846264338327950 s= Str(pi) // returns "3.141593" s= Str(3141592653589012345) // returns "3141592653589012345"
StrComp (String, String, Integer) As Integer
Makes a binary (case-sensitive) or text (lexicographic) comparison of the two strings passed and returns the result.
The following example returns -1 because the two strings are the same in every way except in case.
StrComp(“Spam”, “spam”, 1)
The following example returns -1 because in a text comparison of the two strings, string2 is greater than string1. The ASCII value of “s” is greater than the ASCII value of “S”.
StrComp(“Spam”, “spam”, 0)
StrToHex (String) As String
Returns a String of hexadecimal numbers
dim s as string s = HexToStr("ABC") // Returns "414243", because "A" has ASCII code &h41 or 65 decimal, // "B" has ASCII code &h42 or 66 decimal etc.
Tan (Double) As Double
Returns the tangent of the angle specified.
Dim d As Double Const PI=3.14159265358979323846264338327950 d=Tan(45*PI/180) //returns 1.0
Ticks as Integer
Returns the number of ticks (60th of a second) that have passed since the user's computer was started.
Dim minutes As Integer minutes=Ticks/60/60 MsgBox "Your computer has been on for"+ Str(minutes)+" minutes."
Because modern operating systems can stay running for so long, it's possible for the machine's internal counters to “roll over.” This means that if you are using this function to determine how much time has elapsed between two events, you may encounter a case where it appears that the stop time is prior to the start time.
returns a integer that contains the number of frames in a given timecode. The function uses the Global Framerate (Main Menu → Options) to determine the frames per second. The following example converts a timecodeto a framecode.
dim fc as integer fc = TimecodeToFramecode("10-05-12-21")
Titlecase (String) As String
Returns the String passed to it with all alphabetic characters in Titlecase.
Dim s As String s=Titlecase("tHe Quick fOX") //returns "The Quick Fox" s=Titlecase("THE LAZY DOG") //returns "The Lazy Dog"
Trim (String) As String
Returns the String passed with leading and trailing whitespaces removed.
Dim s as String s=Trim(" Hello World ") //Returns "Hello World"
Ubound (array) As Integer
Returns the index of the last element in an array.
The Ubound function can be used to determine the last element of an array, but it can also be used to determine the size of an array. It may appear at first that the last element number and the size of the array are the same but in fact they are not. All arrays have a zero element. In some cases element zero is used and in other cases it is not. You will need to keep this in mind when using the Ubound function to determine the number of values you have in the array. If the array is zero-based, then element zero is used to store a value and you will have to add one to the value returned by the Ubound function to make up for it.
This example replaces each occurrence of X in an array with Y.
Dim i As Integer For i=0 to Ubound(Names) If Names(i)="X" Then Names(i)="Y" End If Next
Uppercase (String) As String
Converts all characters in a String to uppercase characters.
Dim s As String s=Uppercase("tHe Quick fOX") //returns "THE QUICK FOX" s=Uppercase("the 5 lazy dogs") //returns "THE 5 LAZY DOGS"
Val (String) As Double
Returns the numeric form of a String.
Dim n As Integer n = Val("12345") //returns 12345 n = Val(" 12345") //returns 12345 n = Val("123 45") //returns 123 n = Val(" &hFFF") //returns 4095 n = Val(" &b1111") //returns 15
The Val function stops reading the String at the first character it doesn't recognize as part of a number. All other characters are automatically stripped. It does recognize prefixes &o (octal), &b (binary), and &h (hexadecimal). However, spaces are not allowed in front of the ampersand. That is, ” &hFF“ returns 0, but ” &hFF“ returns 255. The CDbl function is the same as the Val function but is used when you need to pass a String that uses a character other than the period (.) as the decimal separator. It uses the decimal character specified by the operating system. For example, on Windows XP, it is set in the Regional and Language Options Control Panel. Val should generally be used to convert internal data, but not data entered by the user. Val is not international-savvy, but CDbl is. The CStr function is the same as the Str function but is used when you need to pass a number that uses a character other than the period (.) as the decimal separator. It uses the decimal character specified by the operating system. Val returns zero if string contains no numbers.
Error Codes Compiler error numbers returned in errorNumber are shown below:
Error Number | Description |
---|---|
1 | Syntax does not make sense. |
2 | Type mismatch. |
3 | Select Case does not support that type of expression. |
4 | The compiler is not implemented (obsolete). |
5 | The parser's internal stack has overflowed. |
6 | Too many parameters for this function. |
7 | Not enough parameters for this function call. |
8 | Wrong number of parameters for this function call. |
9 | Parameters are incompatible with this function. |
10 | Assignment of an incompatible data type. |
11 | Undefined identifier. |
12 | Undefined operator. |
13 | Logic operations require Boolean operands. |
14 | Array bounds must be integers. |
15 | Can't call a non-function. |
16 | Can't get an element from something that isn't an array. |
17 | Not enough subscripts for this array's dimensions. |
18 | Too many subscripts for this array's dimensions. |
19 | Can't assign an entire array. |
20 | Can't use an entire array in an expression. |
21 | Can't pass an expression as a ByRef parameter. |
22 | Duplicate identifier. |
23 | The backend code generator failed. |
24 | Ambiguous call to overloaded method. |
25 | Multiple inheritance is not allowed. |
26 | Cannot create an instance of an interface. |
27 | Cannot implement a class as though it were an interface. |
28 | Cannot inherit from something that is not a class. |
29 | This class does not fully implement the specified interface. |
30 | Event handlers cannot live outside of a class. |
31 | It is not legal to ignore the result of a function call. |
32 | Can't use “Self” keyword outside of a class. |
33 | Can't use “Me” keyword outside of a class. |
34 | Can't return a value from a Sub. |
35 | An exception object required here. |
36-39 | Obsolete. |
40 | Destructors can't have parameters. |
41 | Can't use “Super” keyword outside of a class. |
42 | Can't use “Super” keyword in a class that has no parent. |