Adds a looper sub. Looper is similar to a timer with the lowest possible interval. There could be any number of looper subs. Example: AddLooper("Looper1")
'... SubLooper1
EndSub
ArrayAsvoid
Creates a single dimension array of the specified type, or Object if the type is not specified. The syntax is: Array As type (list of values). Example: DimDays() AsString = ArrayAsString("Sunday", "Monday", ...)
Asc (CharacterAsString) AsByte
Returns the byte (ASCII) value of the first character in the string.
Runs the given sub after the specified time elapses. Note that this call does not block the thread. SubName - Sub name as literal string. DelayMs - Delay in milliseconds. Tag - Value that will be passed to the called sub. This is useful when multiple CallSubPlus call the same sub. Example: CallSubPlus("DoSomething", 1000, 5)
'...
SubDoSomething(TagasByte)
EndSub
cEAsDouble
e (natural logarithm base) constant.
Ceil (NumberAsDouble) AsDouble
Returns the smallest double that is greater or equal to the specified number and is equal to an integer.
Stops executing the current iteration and continues with the next one.
Cos (RadiansAsDouble) AsDouble
Calculates the trigonometric cosine function. Angle measured in radians.
CosD (DegreesAsDouble) AsDouble
Calculates the trigonometric cosine function. Angle measured in degrees.
cPIAsDouble
PI constant.
CRLFAsStringLiteral
New line character. Value of Chr(13) and Chr(10). Note that in other B4X products the value is Chr(10).
Delay (DelayMsAsULong) Asvoid
Pauses the execution for the specified delay measured in milliseconds. Note that in most cases it is better to use a Timer or CallSubPlus instead.
DelayMicroseconds (DelayAsUInt) Asvoid
Pauses the execution for the specified delay measured in microseconds.
DimAsvoid
Declares a variable. Syntax: Declare a single variable: Dim variable name [As type] [= expression] The default type is String.
Declare multiple variables. All variables will be of the specified type. Dim variable1 [= expression], variable2 [= expression], ..., [As type] Note that the shorthand syntax only applies to Dim keyword. Example:Dima = 1, b = 2, c = 3AsInt
Declare an array: Dim variable(Rank1, Rank2, ...) [As type] Example:DimDays(7) AsString The actual rank can be omitted for zero length arrays.
ExitAsvoid
Exits the most inner loop. Note that Exit inside a Select block will exit the Select block.
FalseAsBoolean
Floor (NumberAsDouble) AsDouble
Returns the largest double that is smaller or equal to the specified number and is equal to an integer.
ForAsvoid
Syntax: For variable = value1 To value2 [Step interval] ... Next If the iterator variable was not declared before it will be of type Int.
Or: For Each variable As type In collection ... Next Examples: Fori = 1To10 Log(i) 'Will print 1 to 10 (inclusive). Next ForEachnAsIntInNumbers'an array Sum = Sum + n Next
Note that the loop limits will only be calculated once before the first iteration.
IfAsvoid
Single line: If condition Then true-statement [Else false-statement] Multiline: If condition Then statement Else If condition Then statement ... Else statement End If
IsNumber (TextAsString) AsBoolean
Tests whether the given string can be safely parsed as a number.
JoinBytes (ArraysOfObjects() AsObject) AsByte()
Concatenates the arrays of bytes to a single array. Think carefully before using this method. In most cases there are better solutions that require less memory (calling Write multiple times for example). Example: Dimb() asbyte = JoinBytes(Array("abc".GetBytes, ArrayasByte(13, 10)))
JoinStrings (Strings() AsString) AsString
Concatenates the strings to a single string. Think carefully before using this method. In most cases there are better solutions that require less memory. Example: DimsAsString = JoinStrings(ArrayAsString("Pi = ", cPI))
Log (OneOrMoreMessagesAsObject) Asvoid
Logs one or more messages. This is a special method. It can accept any number of parameters. The data is sent through the Serial object. Each parameter can be a String, number or an array of bytes (which will be treated as a string). Example: Log("x = ", x)
Converts the number to string with the specified minimum number of integers and maximum number of fractions.
Power (BaseAsDouble, ExponentAsDouble) AsDouble
Returns the Base value raised to the Exponent power.
QUOTEAsStringLiteral
Quote character.
ReturnAsvoid
Returns from the current sub and optionally returns the given value. Note that only primitives, numbers, strings and array of primitives can be returned. Syntax: Return [value]
Rnd (MininumAsLong, MaximumAsLong) AsLong
Returns a random number between Min (inclusive) and Max (exclusive).
RndSeed (SeedAsULong) Asvoid
Sets that random seed value. Example based on the analog value of a floating pin: dimpasPin p.Initialize(0, p.MODE_INPUT)
RndSeed(p.AnalogRead)
Round (NumberAsDouble) AsLong
Returns the whole number closest to the given number.
Runs an inline C function. Example: RunNative("testc", Null)
#If C voidtestc(B4R::Object* o) {
Serial.println(b4r_main::_i); //printaglobalvariablenamedi }
#End If
SelectAsvoid
Compares a single value to multiple values. Example: DimvalueAsInt = 7 Selectvalue Case1 Log("One")
Case2, 4, 6, 8 Log("Even")
Case3, 5, 7, 9 Log("Odd larger than one")
CaseElse Log("Larger than 9")
EndSelect
SenderAsObject
Returns the object that raised the event (if it was set).
Sin (RadiansAsDouble) AsDouble
Calculates the trigonometric sine function. Angle measured in radians.
SinD (DegreesAsDouble) AsDouble
Calculates the trigonometric sine function. Angle measured in degrees.
SizeOf (ObjectAsObject) AsUInt
Returns the size (number of bytes) of the given object. The object type must be known during compilation.
Sqrt (ValueAsDouble) AsDouble
Returns the positive square root.
StackBufferUsageAsUInt
Returns the usage of the stack memory buffer (set with #StackMemoryBuffer attribute).
SubAsvoid
Declares a sub with the parameters and return type. Syntax: Sub name [(list of parameters)] [As return-type] Parameters include name and type. The lengths of arrays dimensions should not be included. Example: SubMySub (FirstNameAsString, LastNameAsString, AgeAsInt, OtherValues() AsDouble) AsBoolean ...
EndSub In this example OtherValues is a single dimension array. The return type declaration is different than other declarations as the array parenthesis follow the type and not the name (which does not exist in this case).
TABAsStringLiteral
Tab character.
Tan (RadiansAsDouble) AsDouble
Calculates the trigonometric tangent function. Angle measured in radians.
TanD (DegreesAsDouble) AsDouble
Calculates the trigonometric tangent function. Angle measured in degrees.
TrueAsBoolean
TypeAsvoid
Declares a structure. Can only be used inside Process_Globals sub. Syntax: Type type-name (field1, field2, ...) Fields include name and type. Example: TypeMyType (NameAsString, ValueAsInt)
Dima, bAsMyType a.Value = 123
UntilAsvoid
Loops until the condition is true. Syntax: Do Until condition ... Loop
WhileAsvoid
Loops while the condition is true. Syntax: Do While condition ... Loop
Initializes the serial object and sets the baudrate. Uses the default 8N1 configuration. The baudrate should match the setting in the IDE if the serial will be used for logging.
StreamAsStream [read only]
Returns the internal stream. This can be used together with AsyncStreams to read or write from the serial.
Reads data from the stream and stores it in the buffer. Will attempt to read the specified number of bytes. Returns the number of bytes read. Buffer - Data will be written to this array. StartOffset - Index of the first byte in the array. Length - Number of bytes to read.
Writes the data to the stream. Returns the number of bytes written. All the bytes will be written to the stream if possible. Buffer - Data that will be written. StartOffset - Index of the first byte. Length - Number of bytes that will be written.
Initializes the timer. Note that you must set Enabled to True for the timer to start running. TickSub - The sub that will handle the tick event. Interval - Interval measured in milliseconds.
IntervalAsULong
Gets or sets the timer interval, measured in milliseconds.
Top