STR / NUM / CMD


The STR, NUM, CMD commands are very similar to each other, including having the same storage space. The number inside curly brackets indicates the index. This marks the position of STR/NUM/CMD. It can be configured in the Setup/Other menu how many of them can exist, min:30, max:500, default:50. RAM is limited, so use it wisely.

Assignment, Query

STR[?]
Last index.

STR[0]=Lion
STR[0] gets the value. It is stored in RAM and is lost upon reboot.
STR[0]@
Value of STR[0] is sent to STDOUT. Can be configured in the Setup/communication menu to specify who receives it.
STR[0]@@
Value of STR[0] is sent to STDOUT, followed by @ to separate the index. Useful for JavaScript .split("@") command to identify the recipient of the received value.
STR[0]@12@
Value of STR[0] is sent to STDOUT, followed by the number between the two @ symbols. Valid range: 0-99.
STR[1]@=Cat
STR[1] gets the value, which is immediately sent to STDOUT.

NUM[2]=12
NUM[2]=-23.4
NUM[2]=18.81
NUM[2]=1.618033
Integer, decimal numbers.

NUM[2]=RND(100)
Random number, range 0-99.

NUM[2]@
Original value, maximum two decimals.
NUM0[2]@
Integer value, rounded.
NUM1[2]@
Decimal, rounded to one decimal place.
NUM2[2]@
Decimal, rounded to two decimal places.

STR[3]=Temperature: 24°C
STR[3]@
NUM[3]@
NUM[3]=20.2
STR[3]@
NUM[3]@
NUM[3]!=18
STR[3]@
NUM[3]@
The above commands demonstrate the interchangeability of STR and NUM.

NUM[4]=5|
STR[5]=Peach:3pcs

NUM[6]@=NUM[4]
NUM[6]@=STR[5]
STR[7]@=NUM[4]
STR[7]@=STR[5]
STR and NUM can take each other's values.
STR[7]@=NUM(4)
STR[7] will be the value of the STR corresponding to NUM[4].

Modifying Values

STR[10]=Text
STR[10]@<Before_
Adds "Before_" characters to the beginning of STR[10].
STR[10]@>_After
Adds "_After" characters to the end of STR[10].

STR[10]@(A,8,*)
STR[10] will be 8 characters long, with * characters at the end.
STR[10]@(B,8,*)
STR[10] will be 8 characters long, with * characters at the beginning.
STR[10]@(E,8,*)
STR[10] will be 8 characters long, with * characters at both the beginning and end.

STR[11]=ABCDEFGHIJKLMN|
STR[12]=QWE-MOUSE-RTZ

STR[11]@(L,5)
The first 5 characters of STR[11] will be the value of STR[11] (LEFT).
STR[11]@(R,5)
The last 5 characters of STR[11] will be the value of STR[11] (RIGHT).
STR[11]@(M,2,4)
From the 2nd character of STR[11] onwards, STR[11] will be 4 characters. (MID)
STR[11]@(S,2,4)
Characters from 2 to 4 of STR[11] will be the value of STR[11] (SubString).
STR[11]@(C,BCD)
If BCD is found in STR[11], it is removed (Cut).
STR[11]@(C,BCD<>12345)
If BCD is found in STR[11], it is replaced with 12345 (Change).
STR[11]@=STR[12](M,4,5)
STR[11] gets the value MOUSE.
STR[12]@(M,4,5)=CAT
STR[12] replaces MOUSE with CAT.
NUM[12]@=STR[11](LEN)
NUM[12] gets the length of STR[11].

NUM[0]=2|
NUM[13]=10

NUM[13]@+8
NUM[13]@+NUM[0]
NUM[14]@=NUM[13]+4
NUM[14]@=NUM[13]+NUM[0]
Addition.
NUM[13]@-3
NUM[13]@-NUM[0]
NUM[14]@=NUM[13]-5
NUM[14]@=NUM[13]-NUM[0]
Subtraction.
NUM[13]@*4.5
NUM[13]@*NUM[0]
NUM[14]@=NUM[13]*6
NUM[14]@=NUM[13]*NUM[0]
Multiplication.
NUM[13]@/3
NUM[13]@/NUM[0]
NUM[14]@=NUM[13]/5
NUM[14]@=NUM[13]/NUM[0]
Division.

Using Multiple Indices Simultaneously

STR[14]=Orange|
STR[15]=Banana|
STR[16]=Kiwi

STR[14-16]@
STR[16-14]@
NUM[17]=82|
NUM[18]=12.9|
NUM[19]=3.14

NUM[17-19]@
NUM0[17-19]@
NUM1[17-19]@
NUM2[19-17]@
Values separated by the ~ character are sent to STDOUT. In JavaScript, the .split('~') command creates an array.

STR[1-8]@=Location[]-Data
The [] characters are replaced by the STR index.

STR[10-19]*
The STR[10] - STR[19] slots are reserved for the STR[*] command.
STR[*]@=RND(100)
The string entered by the command will be placed in the STR[10] slot, with the old data scrolling up.
STR[10-19]@

STR[20-29]+
The STR[20] - STR[29] slots are reserved for the STR[+] command, starting index: 20.
STR[+]@=Color[]:red
STR[+]@=Color[]:yellow
STR[+]@=Color[]:green
The STR[+] command automatically increments the index.
STR[F-C]@
Sends strings stored with the STR[+] command to STDOUT. F is the first index, C is the current.
STR[C-F]@
Sends strings stored with the STR[+] command to STDOUT in reverse order.
STR[N]@
Sends the number of strings stored with the STR[+] command to STDOUT.
STR[+]CE:STR[F-C]@;STR[+]#(rn)plus.txt
When the STR[+] index reaches 29, it executes the commands set here, then clears the STR[20] - STR[29] slots, resetting the index to 20.
STR[20-29]@

NUM[0] - NUM[9]

NUM[0]VL=-10
Lower limit of NUM[0]. Cannot be less than this. Default: -9999
NUM[0]VH=30
Upper limit of NUM[0]. Cannot be greater than this. Default: 9999

NUM[0]VL@
NUM[0]VH@
Reads the min/max value of NUM[0].

NUM[0]@=VL
NUM[0]@=VH
Value of NUM[0] min/max.

NUM[0]%@
Value between lower and upper limit as a percentage.

NUM[0]CL:LED(OFF)
When NUM[0] reaches the lower limit, executes the LED(OFF) command automatically.
NUM[0]CH:LED(ON)
When NUM[0] reaches the upper limit, executes the LED(ON) command automatically.
NUM[0]CC:LED(FLASH)
When the value of NUM[0] changes, executes the LED(FLASH) command automatically.

NUM[0]TB=Temperature:
NUM[0]TA=°C
NUM[0]@
Adds strings before and after the value.
NUM[0]@=21 results in: "Temperature:21°C"

NUM[0]RS
Clears settings (VL, VH, CL, CH, CC, TA, TB).

STRNUM.txt

Setup / Other menu options allow saving. In System mode, it saves to internal memory; in FS mode, it saves to STRNUM.txt file, which can be managed and edited in the Browser window. This is loaded during boot by the OS. FLASH memory can be written ~100000x!!!
STR[0]$
Saves the value of STR[0].
STR[0-9]$
Saves the values of STR[0] - STR[9].
STR[10-19]$*
STR[*] automatically saves the variables.
STR[20-29]$+
STR[+] automatically saves the variables and the current index.

Saving Values to File

STR[0]=mydata|
STR[1]=data.txt

STR[0]#save.txt
Saves the value of STR[0] to save.txt file. Overwrites a file with the same name. Extension must be .txt or .dat only! Can be downloaded from the File Manager window.
STR[0]#STR[1]
Saves the value of STR[0]. Filename: content of STR[1].
STR[0]#(r)save.txt(Linux new line '\r')
STR[0]#(n)save.txt(iOS new line '\n')
STR[0]#(rn)save.txt(Windows new line '\r\n')
STR[0]#(br)save.txt(HTML new line '<br>')
Appends the value of STR[0] to the end of save.txt file. Creates the file if it doesn't exist.
STR[10-19]#save.txt
Saves the values of STR[10] - STR[19] to save.txt file.
STR[*]#save.txt
Saves the values of STR[*] to save.txt file.
STR[+]#save.txt
Saves the values of STR[F] - STR[C] to save.txt file.

STR[0]@=#save.txt
Value of STR[0] becomes the content of save.txt.

Deleting Values

STR[0]!
Deletes the string from RAM.
STR[0]$!
Deletes the string from RAM and STRNUM.txt.
STR[!]
Deletes STR[0] - STR[255] from RAM and STRNUM.txt, resets STR[+] index.
STR[+]!
Deletes strings saved with STR[+] command from RAM and STRNUM.txt, resets STR[+] index.
STR[!#]save.txt
Deletes the save.txt file. Extension must be .txt or .dat!
STR[0-E]@

Date, Time, Other

STR[0]@=%DATE
Date.
STR[0]@=%TIME
Time.
STR[0]@=%TIMES
Time with seconds.
STR[0]@=%Y
Year.
STR[0]@=%YS
Last two digits of year.
STR[0]@=%M
Month.
STR[0]@=%0M
Month with leading zero if less than 10.
STR[0]@=%MS
Month short string, e.g., Oct
STR[0]@=%ML
Month long string, e.g., October
STR[0]@=%W
Day of the week. 1-Sunday, 2-Monday, ...
STR[0]@=%WS
Day of the week short string, e.g., Sun
STR[0]@=%WL
Day of the week long string, e.g., Sunday
STR[0]@=%D
STR[0]@=%0D
Day.
STR[0]@=%h
STR[0]@=%0h
Hour.
STR[0]@=%m
STR[0]@=%0m
Minute.
STR[0]@=%s
STR[0]@=%0s
Second.
STR[0]@=DATE: %Y. %ML %D. %WL TIME: %h:%0m:%0s

TIME[index]
TIME[0]F
TIME[0]+30m
STR[0]@=%TIME[0]W
STR[0]@=%TIME[0]Y
STR[0]@=%TIME[0]M
STR[0]@=%TIME[0]0M
STR[0]@=%TIME[0]MS
STR[0]@=%TIME[0]ML
STR[0]@=%TIME[0]D
STR[0]@=%TIME[0]0D
STR[0]@=%TIME[0]h
STR[0]@=%TIME[0]0h
STR[0]@=%TIME[0]m
STR[0]@=%TIME[0]0m
STR[0]@=%TIME[0]s
STR[0]@=%TIME[0]0s
STR[0]@=%TIME[0]AD
STR[0]@=%TIME[0]Ah
STR[0]@=%TIME[0]Am
STR[0]@=%TIME[0]As
TIME[index] examples.
STR[0]@=ALARM: %TIME[0]Y. %TIME[0]ML %TIME[0]D. %TIME[0]0h:%TIME[0]0m:%TIME[0]0s
Set time.
STR[0]@=REMAINING: %TIME[0]RYyear %TIME[0]RMmonth %TIME[0]RDday %TIME[0]Rhhour %TIME[0]R0mminute %TIME[0]R0ssecond
Remaining time.
STR[0]@=ELAPSED: %TIME[0]EYyear %TIME[0]EMmonth %TIME[0]EDday %TIME[0]Ehhour %TIME[0]Emminute %TIME[0]Essecond
Time elapsed since start.
STR[0]@=REMAINING: %TIME[0]RAm minute
Remaining time in minutes.

STR[0]@=%SUNR
STR[0]@=%SUNRm
STR[0]@=%SUNR0m
STR[0]@=%SUNRh
STR[0]@=%SUNR0h
Sunrise.
STR[0]@=%SUNS
STR[0]@=%SUNSm
STR[0]@=%SUNS0m
STR[0]@=%SUNSh
STR[0]@=%SUNS0h
Sunset.

STR[0]@=%SSID
AP/STA SSID.
STR[0]@=%IP
Module IP address.
STR[0]@=%DEVID
Module DEVID number.
STR[0]@=%DEVIDS
Last 4 characters of DEVID.
STR[0]@=%VISIT
Number of AccessPoint connections.
TIMER[0](10s,10s)
STR[0]@=%TIMER[0]T
STR[0]@=%TIMER[0]S
TIMER value, state.
STR[0]@=%A0
Value of A0 analog input.
STR[0]@=%TEHU[0]
Syntax is the same as TEHU command.
STR[0]@=%FREQ(HZ)
Syntax is the same as FREQ command.
STR[0]@=%NFC
Last read string stored in active sector of NFC TAG.
STR[0]@=%NUID
Last read NFC TAG UID number.
STR[0]@=%RFID
Last read RFID TAG name.
STR[0]@=%RUID
Last read RFID TAG UID number.
STR[0]@=%STPW[0]2
Syntax is the same as STPW command.
STR[0]@=%TCPSIP
IP address of last connected client to TCP server.
STR[0]@=%EXTIO[0]
Current state of EXTIO[0].
STR[0]@=%EXTIN[0]
Last changed input(s) of EXTIO[0].
STR[0]@=%DIMM[0]
Current state of DIMM[0].
STR[0]@=%ACHZ
Frequency on Dimmer SYNC input.
STR[0]@=%PROX
Proximity value from APDS9960 sensor.
STR[0]@=%LIGHT
Light value from APDS9960 sensor, syntax same as LIGHT command.
STR[0]@=%MAIL
Last sent Email status.
STR[1]@=%NUM[0]
Content of NUM[0].
STR[1]@=%STR[0]
Content of STR[0].


Communication

The value of the string is the last message incoming to the specified communication channel. After issuing the command, the message is deleted. Commands interpreted by the interpreter do not appear.
STR[0]@=STDIN
STR[0]'s value is the last message received on STDIN.
STR[0]@=HTMLIN
STR[0]'s value is the last message received on the HTML channel.
STR[0]@=WSIN
STR[0]'s value is the last message received on the WS channel.
STR[0]@=USBIN
STR[0]'s value is the last message received on the USB channel.
STR[0]@=UDPIN
STR[0]'s value is the last message received on the UDP channel.
STR[0]@=TCPIN
STR[0]'s value is the last message received on the TCP client.
STR[0]@=TCPSIN
STR[0]'s value is the last message received on the TCP server.
STR[0]@=SERIN
STR[0]'s value is the last message received on the SER channel.
STR[0]@=POSTIN
STR[0]'s value is the response received for the last POST command.
STR[0]@=NOWIN
STR[0]'s value is the last message received on the NOW channel.

CMD

CMD[0]:LED(ON);STD@ON
CMD[1]=LED(OFF);STD@OFF
STR[2]=LED(FLASHI)
Stores commands to the specified index.

CMD[0]
CMD[1]
CMD[2]
Executes stored commands.

CMD[2]:!
Deletes the command. Applies to all commands marked in green.

NVR

NVR[0]=data
STR[0]@=NVR[0]
NVR[0] is non-volatile memory value of STR[0].



Examples

Logs GPIO[D5] state changes to a file.
GPIO[5]INP|
GPIO[5]CL:STR[0]=%h:%0m:%0s - D5 LOW;STR[0]#(br)gpio.txt;LED(FLASH)|
GPIO[5]CH:STR[0]=%h:%0m:%0s - D5 HIGH;STR[0]#(br)gpio.txt;LED(FLASH)

<html> <body> <H1>GPIO[D5] LOGGER</H1><br> <button type="button" onclick="read();">Refresh</button><br> <button type="button" onclick="sendWS('STR[!#]gpio.txt');read();">Delete GPIO.txt</button> <br> <H2 id="data"></H2> <script type="text/javascript" src="tools.js"></script> <script> startWS(0); function onOpen() { read(); } function read() { document.getElementById('data').innerHTML = getFile("gpio.txt"); } </script> </body> </html>
Opens a webpage visitor counter.
NUM[0]TB=Visitors:
<html> <body> <H1>Page visitor counter</H1><br> <H2 id="counter"></H2> <button type="button" onclick="sendWS('STR[10-19]@')">Details</button> <br><br> <span id="times"></span> <script type="text/javascript" src="tools.js"></script> <script> startWS(0); function onOpen() { sendWS('STR[*]=%h:%0m:%0s|NUM[0]@+1'); } function onMessage(msg) { if (msg.substring(0,8) === "Visitors") { document.getElementById("counter").innerHTML = msg; return; } var array = msg.split("~"); var details = ""; for (var i=0; i<10; i++) {details += array[i] + "<br>";} document.getElementById("times").innerHTML = details; } </script> </body> </html>