NAFC Test Engine

Help Page

Script Table Columns

Variable Swaps

Pattern Description Example
<Step Name> Replaced with the Returned value of that step, variable swaps apply to Step Name, Comm Label, Min and Max Limits <Compose DIO14>:?
[Step Name] Replaced with the Result (pass/fail/aborted) of that step ifpass,[Calc step],Jump OK,Jump fail
{profile.property} Replaced with the corresponding value from the Comm Label without exposing it to the UI --use for device passwords EX: Comm Label: UUT:{protocol:serial,port:/dev/ttyACM0,baud:115200,pw:Efos123,commandTerminator:CR,autoFind:{command:sn,expect:[sn]}}
Command: sn:{{profile.pw}}
replaces {{profile.pw}} with Efos123 before dispatching, so the device receives sn:Efos123. Use any property name the same way (e.g., {{profile.user}}, {{profile.token}}). If the property is missing, it substitutes an empty string.

Cascaded Commands

Pattern Description Example
a|b|c Runs sequentially; returns all results joined by “|” cmdA | cmdB | cmdC
a/b/c Runs sequentially; returns only last result cmdA / cmdB / cmdC
_index_ Within a cascaded command, swaps in the result at that index set_sn,SN123 | addAfter,_0_,:OK

Command Quick Reference

Examples show typical usage; underscores/spaces are interchangeable where noted. Commands are case-insensitive.

Command(s) Example Notes
if if,1,=,1,StepOK,StepFail Conditional jump
ifpass ifpass,[SomeStep],GoNext,HandleFail Jump if arg contains “pass”
math / mathint math,5,+,3 mathint truncates
get get,model / get,Hello Returns meta varaible (model, script, operator, job, sn, technician,testid ,workcell,workorder) or literal of arg[0]
delayms / delays / delaym / delayh delayms,200 ms / seconds / minutes / hours
replace / replaceall replace,OK,GOOD,OK123 Replaces first match / ReplaceAll replaces all matches
find find,abc,bc Returns index
len / upper / lower / trim upper,hello String helpers
split split,a|b|c,|,1 Returns indexed part
substring substring,Hello,1,3 Start,length
addbefore / addafter addafter,VAL,:OK Concatenate
echo echo,Hello world Return text
padleft / padright padleft,123,0,5 Pad to width
remove / removeall removeall,abcabc,ab Remove substring(s)
round / int / long round,3.14,1 Numeric helpers
hex2string / hex2float hex2float,41200000 Conversions
float2hex / float2hexle float2hex,3.5 Hex helpers (Big endian default/le = Little endian)
double2hex / double2hexle double2hex,3.5 Float64 (le = little endian)
bin2hex / bin2long bin2hex,1111 Binary helpers
long2bin / long2hex long2hex,15 Binary/hex helpers
hex2long hex2long,F Hex helpers
getdate / gettimestamp / getcurrenttimemillis gettimestamp Date/time
setlinedelay setlinedelay,50 Line delay ms
getsn / setsn setsn,SN123 Serial number
getworkcell / setworkcell setworkcell,CellA Workcell
getworkorder / setworkorder setworkorder,WO42 Work order
settestid / gettestid settestid,TEST42 Test ID
getoverallstatus / overallstatus / overallresult getoverallstatus Overall result
get_meta_sn get_meta_sn Serial from form/meta
jump / call / return jump,Step2 Control flow by step name; call/return support nested flows.
endscript EndScript Lock overall status; remaining steps can run for reporting/logging.
stripleading / striptrailing stripleading,HelloWorld,5 Substring helpers
cmd / cmd-prompt cmd,uname,-a Run shell command
runprog runprog,notepad.exe Launch program
openfile / openapp openfile,C:\\temp\\readme.txt Open file/app
messagealert messagealert,Check wiring,/InstructionImages/Inst1.jpg,OK,Cancel Alert (optional image)
Note: Message alert returns are not evaluated, use an ifpass to evalute the result of a mesage prompt.
messageinstructions messageinstructions,Follow wiring,/InstructionImages/Inst1.jpg,OK,Cancel Instructions (optional image)
Note: Message instruction returns are not evaluated, use an ifpass to evalute the result of a mesage prompt.
messageprompt messageprompt,Enter tech,butto1Text,Button2Text Prompt for user input
Note: Message prompt returns are not evaluated, use an ifpass to evalute the result of a mesage prompt.
report / reportsave / reportprint report,log,save,true,[Overall] Generate report
ClearDevice ClearDevice,label Remove a device from cache, next use will require full json properties, this will force a new autofind
AutoFindDevice AutoFindDevice,label Clears cached device and forces auto-find on next use for that label.
Comm Label {"label":"Pico","protocol":"serial","baud":19200,"commandTerminator":"CR","autoFind":{"command":"id","expect":"Pico"}}, The first use of a device must have all its properties defined:
{"label":"Pico","protocol":"serial","baud":19200,"commandTerminator":"CR","autoFind":{"command":"id","expect":"Pico"}}, subsequent uses can refer to it by label only.

To send a no response device command, prefix the command with fire: (fire:DIO:0:1) will send the command and not wait for any response

Math Operators (for math / mathint)

Operator Example Meaning
+ math,5,+,3 Add
- math,5,-,3 Subtract
* or x math,5,*,3 Multiply
/ math,6,/,3 Divide
>, >=, <, <=, =, != math,5,>,3 Comparisons
^ math,2,^,8 Power
sqrt math,sqrt,9 Square root
abs math,abs,-5 Absolute value
min / max math,min,5,3 Min/Max
% math,7,%,4 Remainder
<< / >> math,4,<<,1 Bit shifts
& / | math,6,&,3 Bitwise and/or
&& / || math,true,&&,false Logical and/or

Tip: Separators (step names starting with --- or empty commLabel) are skipped for execution.
Tip: Script commands are delimited by , (comma) and may contain spaces before or after delimiters.

Operation

Maintenance & Editing

Devices & Comm Labels

Program Structure (Execution Flow)