2.3 BasScript Types
Header files:
include/bas_script_types.hinclude/bas_script.h
Overview
The BasScript builder relies on enums and variant aliases to describe BAS instruction arguments such as poses, speeds, registers, IO, wait conditions, and program-load parameters.
This page documents BasScript builder enums, their value meanings, and the pairing rules for variant parameters. Reserved enums are listed according to the public headers.
2.3.1 Motion-Related Enums
MovePoseType
MovePoseType selects where a motion instruction gets its target point. The public value is PR , which formats a pose-register reference as PR[index] .
| Value | BAS Notation | Description |
|---|---|---|
PR | PR | Pose-register based target |
SmoothType
SmoothType controls the transition mode when moving to the target point. It appears at the end of motion statements such as MOVEJ , MOVEL , MOVEC , and JUMP .
| Value | BAS Notation | Description |
|---|---|---|
FINE | FINE | Stop exactly at the point; no smoothing distance is appended |
SMOOTH_DISTANCE | SD | Blend by smoothing distance and continue using the smoothDistance parameter |
SpeedType
SpeedType controls whether the speed argument is a literal value or comes from an MR motion register. When MR is selected, speedValue is interpreted as an integer index and emitted as MR[index] .
| Value | Output Form | Description |
|---|---|---|
VALUE | Direct numeric literal | For example 100.0 or 500.0 |
MR | MR[index] | Speed is read from a motion register |
In VALUE mode, MoveJoint requires speed in the 0~100 range; MoveLine / MoveCircle require speed in the 0~5000 range.
2.3.2 Register, IO, and Logic Enums
RegisterType
RegisterType describes register operands that can be used in logic conditions, wait conditions, or CASE . It is used for "read a register for comparison" scenarios, not for assignment targets on the left side of ASSIGN .
| Value | BAS Notation | Description |
|---|---|---|
R | R | Numeric register |
SR | SR | String register |
MH | MH | Modbus holding register |
MI | MI | Modbus input register |
IOType
IOType describes IO operands that can be used in logic conditions, wait conditions, or CASE . It identifies the IO category; the concrete port number is still supplied by the index or value argument.
| Value | BAS Notation | Description |
|---|---|---|
DI | DI | Digital input |
DO | DO | Digital output |
AI | AI | Analog input |
AO | AO | Analog output |
RI | RI | Remote-control input |
RO | RO | Remote-control output |
UI | UI | User/dedicated input |
UO | UO | User/dedicated output |
GI | GI | Group input |
GO | GO | Group output |
TAI | TAI | Wrist analog input |
TAO | TAO | Wrist analog output |
TDI | TDI | Wrist digital input |
TDO | TDO | Wrist digital output |
IOStatus
IOStatus is the state constant used in IO conditions and IO assignment. Digital-output assignment, wait conditions, and logic conditions can all use it.
| Value | BAS Notation | Description |
|---|---|---|
ON | ON | Set, high level, or condition true |
OFF | OFF | Reset, low level, or condition false |
PULSE | PULSE | Pulse; assignment can include a pulse length |
POSITIVE_EDGE | PE | Rising edge |
NEGATIVE_EDGE | NE | Falling edge |
BooleanOperator
BooleanOperator is the condition connector or comparator used by IF , ELSEIF , WHILE , SKIP CONDITION , and WAIT .
| Value | BAS Notation | Description |
|---|---|---|
AND | AND | And |
OR | OR | Or |
EQ | = | Equal |
NE | <> | Not equal |
GT | > | Greater than |
GE | >= | Greater than or equal |
LT | < | Less than |
LE | <= | Less than or equal |
2.3.3 Assignment, Load, and Parameter Enums
AssignType
AssignType describes registers, frames, or output targets that can appear on either side of an ASSIGN statement. As param1 , it identifies the left-hand assignment target. As param2 , it identifies another register or target value referenced on the right-hand side.
| Value | BAS Target | Description |
|---|---|---|
R | R[index] | Numeric register |
MR | MR[index] | Motion register |
PR | PR[index] | Pose register |
PR_ELEMENT | PR[index].n | Pose-register sub-element |
SR | SR[index] | String register |
UF | UF[index] | User frame |
TF | TF[index] | Tool frame |
MH | MH[index] | Modbus holding register |
MI | MI[index] | Modbus input register |
DO | DO[index] | Digital output |
RO | RO[index] | Remote output |
GO | GO[index] | Group output |
AO | AO[index] | Analog output |
TAO | TAO[index] | Wrist analog output |
TDO | TDO[index] | Wrist digital output |
OtherType
OtherType is used by variant parameters such as AssignParam2 / LogiParam2 when the right-hand side is not a register or IO operand, but a literal, IO state, or current pose.
| Value | Meaning | Typical Scenario |
|---|---|---|
VALUE | Direct numeric value | ASSIGN / logic condition / CASE |
STRING | String literal | ASSIGN , CASE |
IO_STATUS | IO status constant | ASSIGN , WAIT |
CURRENT_POSE | Current pose | ASSIGN |
CurrentPose
CurrentPose is used as AssignValue_t only when OtherType::CURRENT_POSE is selected. It writes the current robot pose into the target.
| Value | BAS Notation | Description |
|---|---|---|
J_POS | J_POS | Current joint pose |
L_POS | L_POS | Current Cartesian pose |
LoadType
LoadType controls where Load() , Unload() , and Exec() get their program identifier. R / SR read the identifier from a register, STRING passes a program name directly, and VALUE passes a numeric literal directly.
| Value | Corresponding LoadValue_t | Description |
|---|---|---|
R | int32_t | Pass a register index and output R[index] |
SR | int32_t | Pass a register index and output SR[index] |
STRING | std::string | Pass a program name string and output STRING "name" |
VALUE | int32_t / Float64 | Output a numeric literal directly |
StrType
StrType controls where socket send/receive string content comes from or is written to.
| Value | Corresponding SocketValue_t | Description |
|---|---|---|
STRING | std::string | Send or receive a string directly |
SR | int32_t | Send from or receive into SR[index] |
ValueType
ValueType selects a generic numeric source and is commonly used by SetParam() , WaitTime() , and ModbusWriteMH() .
| Value | Output Form | Description |
|---|---|---|
VALUE | Numeric literal | Use the numeric literal directly |
R | R[index] | Read from a numeric register |
ParamType
ParamType identifies runtime parameters that BasScript::SetParam() can set.
| Value | BAS Notation | Description |
|---|---|---|
TF_NO | TF_NO | Tool frame number |
UF_NO | UF_NO | User frame number |
OVC | OVC | Global speed |
OAC | OAC | Global acceleration |
PAYLOAD_NO | PAYLOAD_NO | Payload number |
2.3.4 Reserved Enums
MathOperator
MathOperator is a reserved enum for arithmetic operators.
| Value | Intended Meaning |
|---|---|
ADD | Addition |
SUB | Subtraction |
MUL | Multiplication |
DIV | Division |
2.3.5 Variant Argument Combinations
This section describes the accepted shapes of builder arguments. Callers choose the variant form that matches the target BAS statement.
Assignment Statements
The third argument of AssignValue() declares the right-hand operand category. The fourth argument carries the right-hand operand value.
| Target Meaning | Third Argument | Fourth Argument | Output Meaning |
|---|---|---|---|
| Right side is another register or frame | AssignType | int32_t index | For example AssignType::MR + 8 outputs MR[8] |
| Right side is a PR sub-element | AssignType::PR_ELEMENT | int32_t PR index, with optValue as sub-element index | Outputs PR[index].n |
| Right side is a numeric literal | OtherType::VALUE | int32_t or Float64 | Outputs a direct numeric value |
| Right side is a string literal | OtherType::STRING | std::string | Outputs a quoted string |
| Right side is an IO state | OtherType::IO_STATUS | IOStatus | Outputs ON / OFF / PULSE , etc. |
| Right side is current pose | OtherType::CURRENT_POSE | CurrentPose | Outputs J_POS or L_POS |
Logic and Wait Conditions
Logic and wait conditions are built from "left operand + operator + right operand". The left operand is usually a register or IO; the right operand can again be a register, IO, literal, or status constant.
| Alias | Used By | Candidate Types | Selection Rule |
|---|---|---|---|
LogiParam1 | Left side of LogiIf / LogiElseIf / LogiWhile / LogiSkipCondition / Wait | RegisterType / IOType | Pass RegisterType for a register condition, IOType for an IO condition |
LogiParam2 | Right side of logic conditions, and LogiCase parameter | RegisterType / IOType / OtherType | Pass the matching type when referencing a register or IO; pass OtherType for literals, strings, or IO states |
LogiValue_t | Actual right-side value of a logic condition | int32_t / Float64 / std::string / IOStatus | Must match the choice in LogiParam2 |
WaitParam2 | Right side of Wait | ValueType / IOType / OtherType | Use ValueType for numeric waits, IOType for another IO, and OtherType::IO_STATUS for ON / OFF style states |
WaitValue_t | Actual right-side value of Wait | int32_t / Float64 / IOStatus | Must match the choice in WaitParam2 |
LogiCaseValue_t | Match value of LogiCase | int32_t / Float64 / std::string | Used for branches such as CASE 1 , CASE 3.14 , and CASE "name" |
Other Variant Arguments
| Alias | Used By | Candidate Types | Selection Rule |
|---|---|---|---|
SocketValue_t | SocketSend / SocketRecv | int32_t / std::string | Pass an SR index when StrType::SR is selected; pass a string when StrType::STRING is selected |
SetParamVal_t | SetParam / WaitTime | int32_t / Float64 | Direct values can be integer or floating point; when ValueType::R is selected, the value is interpreted as an R-register index |
LoadValue_t | Load / Unload / Exec | int32_t / Float64 / std::string | Pass an index for LoadType::R / SR , a program name for STRING , and a numeric literal for VALUE |
Reading Examples
The following combinations can be read directly from their output:
| Intent | Key Arguments | Output |
|---|---|---|
| Write MR[8] into R[5] | AssignType::R, 5, AssignType::MR, int32_t{8} | ASSIGN R[5] = MR[8] |
| Wait for DI[1] to become ON | IOType::DI, 1, OtherType::IO_STATUS, IOStatus::ON | WAIT COND DI[1] = ON |
| Send a socket string | StrType::STRING, std::string{"ping"} | SOCKET_SEND SK[index] "ping" |
| Execute by string program name | LoadType::STRING, std::string{"demo"} | EXEC STRING "demo" |
2.3.6 Common Pairing Rules
- The left operand of
Wait()does not supportRegisterType::SR. - When
WaitParam2isOtherType, onlyOtherType::IO_STATUSis supported. LogiSkipCondition()does not allowMH/MIon either side.- In
AssignValue(), whenparam1 == AssignType::PR_ELEMENT,optIndexmust be provided. - In
AssignValue(), whenparam2 == AssignType::PR_ELEMENT,valueis thePRindex andoptValueis the sub-element index. - In
AssignValue(), whenparam2 == OtherType::IO_STATUSandvalue == IOStatus::PULSE,optValueis the pulse length. - In
Wait(), whenparam2 == IOType,valuemust be the right-side IO port index. - In
Wait(), whenparam2 == ValueType::R,valuemust be the R-register index. - In
SocketSend()/SocketRecv(),StrType::SRaccepts only integer indexes, andStrType::STRINGaccepts only strings. - In
Load()/Unload()/Exec(),LoadTypeandLoadValue_tmust match one-to-one. The SDK does not automatically convert values into program-name strings.
2.3.7 Output Example
BasScript script("demo.bas"); // Create a BAS builder named demo.bas.
script.motion.MoveLine( // Append one MOVEL linear-motion statement.
MovePoseType::PR, // The target point comes from a PR pose register.
1, // Use PR[1] as the target point.
SpeedType::VALUE, // Use a literal speed value.
Float64{100.0}, // Emit linear speed as 100.0.
SmoothType::FINE // Stop at the point, with no smoothing distance.
); // End the MoveLine call.
// Generated: MOVEL PR[1] 100.0 FINE
script.AssignValue( // Append one ASSIGN statement.
AssignType::R, // Left side is an R numeric register.
1, // Left side is R[1].
OtherType::VALUE, // Right side is a literal value.
Float64{3.14} // The value to write is 3.14.
); // End the AssignValue call.
// Generated: ASSIGN R[1] = 3.14
script.AssignValue( // Append another ASSIGN statement.
AssignType::R, // Left side is an R numeric register.
5, // Left side is R[5].
AssignType::MR, // Right side references an MR motion register.
int32_t{8} // The right-side register is MR[8].
); // End the AssignValue call.
// Generated: ASSIGN R[5] = MR[8]
script.structure.Load( // Append one LOAD program statement.
LoadType::STRING, // Program identifier is a direct string.
std::string("demo_program") // Program name is demo_program.
); // End the Load call.
// Generated: LOAD STRING "demo_program"
script.structure.Wait( // Append one WAIT COND statement.
IOType::DI, // Left side checks digital input DI.
1, // Left-side port is DI[1].
OtherType::IO_STATUS, // Right side is an IO status constant.
IOStatus::ON // Wait until DI[1] becomes ON.
); // End the Wait call.
// Generated: WAIT COND DI[1] = ON
script.socket.SocketSend( // Append one SOCKET_SEND statement.
1, // Use socket channel SK[1].
StrType::STRING, // Send direct string content.
std::string("ping") // Send the string ping.
); // End the SocketSend call.
// Generated: SOCKET_SEND SK[1] "ping"