Skip to content

2.3 BasScript Types

Header files:

  • include/bas_script_types.h
  • include/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] .

ValueBAS NotationDescription
PRPRPose-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 .

ValueBAS NotationDescription
FINEFINEStop exactly at the point; no smoothing distance is appended
SMOOTH_DISTANCESDBlend 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] .

ValueOutput FormDescription
VALUEDirect numeric literalFor example 100.0 or 500.0
MRMR[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 .

ValueBAS NotationDescription
RRNumeric register
SRSRString register
MHMHModbus holding register
MIMIModbus 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.

ValueBAS NotationDescription
DIDIDigital input
DODODigital output
AIAIAnalog input
AOAOAnalog output
RIRIRemote-control input
RORORemote-control output
UIUIUser/dedicated input
UOUOUser/dedicated output
GIGIGroup input
GOGOGroup output
TAITAIWrist analog input
TAOTAOWrist analog output
TDITDIWrist digital input
TDOTDOWrist 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.

ValueBAS NotationDescription
ONONSet, high level, or condition true
OFFOFFReset, low level, or condition false
PULSEPULSEPulse; assignment can include a pulse length
POSITIVE_EDGEPERising edge
NEGATIVE_EDGENEFalling edge

BooleanOperator

BooleanOperator is the condition connector or comparator used by IF , ELSEIF , WHILE , SKIP CONDITION , and WAIT .

ValueBAS NotationDescription
ANDANDAnd
OROROr
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.

ValueBAS TargetDescription
RR[index]Numeric register
MRMR[index]Motion register
PRPR[index]Pose register
PR_ELEMENTPR[index].nPose-register sub-element
SRSR[index]String register
UFUF[index]User frame
TFTF[index]Tool frame
MHMH[index]Modbus holding register
MIMI[index]Modbus input register
DODO[index]Digital output
RORO[index]Remote output
GOGO[index]Group output
AOAO[index]Analog output
TAOTAO[index]Wrist analog output
TDOTDO[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.

ValueMeaningTypical Scenario
VALUEDirect numeric valueASSIGN / logic condition / CASE
STRINGString literalASSIGN , CASE
IO_STATUSIO status constantASSIGN , WAIT
CURRENT_POSECurrent poseASSIGN

CurrentPose

CurrentPose is used as AssignValue_t only when OtherType::CURRENT_POSE is selected. It writes the current robot pose into the target.

ValueBAS NotationDescription
J_POSJ_POSCurrent joint pose
L_POSL_POSCurrent 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.

ValueCorresponding LoadValue_tDescription
Rint32_tPass a register index and output R[index]
SRint32_tPass a register index and output SR[index]
STRINGstd::stringPass a program name string and output STRING "name"
VALUEint32_t / Float64Output a numeric literal directly

StrType

StrType controls where socket send/receive string content comes from or is written to.

ValueCorresponding SocketValue_tDescription
STRINGstd::stringSend or receive a string directly
SRint32_tSend from or receive into SR[index]

ValueType

ValueType selects a generic numeric source and is commonly used by SetParam() , WaitTime() , and ModbusWriteMH() .

ValueOutput FormDescription
VALUENumeric literalUse the numeric literal directly
RR[index]Read from a numeric register

ParamType

ParamType identifies runtime parameters that BasScript::SetParam() can set.

ValueBAS NotationDescription
TF_NOTF_NOTool frame number
UF_NOUF_NOUser frame number
OVCOVCGlobal speed
OACOACGlobal acceleration
PAYLOAD_NOPAYLOAD_NOPayload number

2.3.4 Reserved Enums

MathOperator

MathOperator is a reserved enum for arithmetic operators.

ValueIntended Meaning
ADDAddition
SUBSubtraction
MULMultiplication
DIVDivision

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 MeaningThird ArgumentFourth ArgumentOutput Meaning
Right side is another register or frameAssignTypeint32_t indexFor example AssignType::MR + 8 outputs MR[8]
Right side is a PR sub-elementAssignType::PR_ELEMENTint32_t PR index, with optValue as sub-element indexOutputs PR[index].n
Right side is a numeric literalOtherType::VALUEint32_t or Float64Outputs a direct numeric value
Right side is a string literalOtherType::STRINGstd::stringOutputs a quoted string
Right side is an IO stateOtherType::IO_STATUSIOStatusOutputs ON / OFF / PULSE , etc.
Right side is current poseOtherType::CURRENT_POSECurrentPoseOutputs 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.

AliasUsed ByCandidate TypesSelection Rule
LogiParam1Left side of LogiIf / LogiElseIf / LogiWhile / LogiSkipCondition / WaitRegisterType / IOTypePass RegisterType for a register condition, IOType for an IO condition
LogiParam2Right side of logic conditions, and LogiCase parameterRegisterType / IOType / OtherTypePass the matching type when referencing a register or IO; pass OtherType for literals, strings, or IO states
LogiValue_tActual right-side value of a logic conditionint32_t / Float64 / std::string / IOStatusMust match the choice in LogiParam2
WaitParam2Right side of WaitValueType / IOType / OtherTypeUse ValueType for numeric waits, IOType for another IO, and OtherType::IO_STATUS for ON / OFF style states
WaitValue_tActual right-side value of Waitint32_t / Float64 / IOStatusMust match the choice in WaitParam2
LogiCaseValue_tMatch value of LogiCaseint32_t / Float64 / std::stringUsed for branches such as CASE 1 , CASE 3.14 , and CASE "name"

Other Variant Arguments

AliasUsed ByCandidate TypesSelection Rule
SocketValue_tSocketSend / SocketRecvint32_t / std::stringPass an SR index when StrType::SR is selected; pass a string when StrType::STRING is selected
SetParamVal_tSetParam / WaitTimeint32_t / Float64Direct values can be integer or floating point; when ValueType::R is selected, the value is interpreted as an R-register index
LoadValue_tLoad / Unload / Execint32_t / Float64 / std::stringPass 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:

IntentKey ArgumentsOutput
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 ONIOType::DI, 1, OtherType::IO_STATUS, IOStatus::ONWAIT COND DI[1] = ON
Send a socket stringStrType::STRING, std::string{"ping"}SOCKET_SEND SK[index] "ping"
Execute by string program nameLoadType::STRING, std::string{"demo"}EXEC STRING "demo"

2.3.6 Common Pairing Rules

  • The left operand of Wait() does not support RegisterType::SR .
  • When WaitParam2 is OtherType , only OtherType::IO_STATUS is supported.
  • LogiSkipCondition() does not allow MH / MI on either side.
  • In AssignValue() , when param1 == AssignType::PR_ELEMENT , optIndex must be provided.
  • In AssignValue() , when param2 == AssignType::PR_ELEMENT , value is the PR index and optValue is the sub-element index.
  • In AssignValue() , when param2 == OtherType::IO_STATUS and value == IOStatus::PULSE , optValue is the pulse length.
  • In Wait() , when param2 == IOType , value must be the right-side IO port index.
  • In Wait() , when param2 == ValueType::R , value must be the R-register index.
  • In SocketSend() / SocketRecv() , StrType::SR accepts only integer indexes, and StrType::STRING accepts only strings.
  • In Load() / Unload() / Exec() , LoadType and LoadValue_t must match one-to-one. The SDK does not automatically convert values into program-name strings.

2.3.7 Output Example

cpp
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"