@Luca_Bartolomei
It is definitely possible to do what you are trying to do though you will need to use slightly more specific BASIC scripting to parse and extract the pertinent information.
Below are a few different ways you can do this. The options range from setting a single tag by name to setting multiple tags at once.
Setting a single tag with name and value:
In this example we are basically using what you had above. When you send a text message in the form of Tagname (delimiter) value, it will write that tags value. I have written this example to be dynamic in the sense that you can customize the delimiter being used to separate the values (you have an = sign but we can update that to be a -, : or other.
NOTE: This is a Flexy only script as it uses functions
FUNCTION writeTag($smsBody$)
delimiter$ = "=" // Assign your delimiter Eg: Name=Value or Name:Value
indexOfDelimiter% = INSTR 1, $smsBody$, delimiter$ // Find the index of your delimiter to split between name and value
tagName$ = $smsBody$(1 TO (indexOfDelimiter% - 1)) // Get the tag name
tagValue = VAL($smsBody$((indexOfDelimiter% + 1) TO LEN($smsBody$))) // Get the tag value
SETIO tagName$, tagValue // Assign the new value to the tag.
ENDFN
Usage with SMS:
INIT Section:
ONSMS "GOTO HSms"
HSms:
a% = GETSYS PRG, "SmsRead"
IF a% <> 0 THEN
message$ = GETSYS PRG, "smsmsg"
@writeTag(message$)
ENDIF
END
Updating Multiple Tags (Single Message):
Now, let’s say instead of sending 4 text messages to update 4 tags, you’d prefer to simply send several tags at once. In this scenario we can basically send a bulk SMS with multiple tags and then have the eWON parse and assign the tag values.
FUNCTION smsTagAssign($smsBody$)
$tagDelimiter$ = "," // Delimiter to specify separation of tag data
$delimiter$ = "=" // Delimiter to specify tag name vs value
$tagStr$ = "" // Placeholder tag
$tagDelimiterIndex% = INSTR 1, $smsBody$, $tagDelimiter$ // Get the first index of the tag delimiter to extract tag
// If the tag delimiter is not a zero, that means we have more than one tag remaining
// As the delimiter was found. If so, extract the next tag.
// If the value is a zero, we are at the last tag element.
IF $tagDelimiterIndex% <> 0 THEN
$tagStr$ = $smsBody$(1 TO ($tagDelimiterIndex% - 1))
ELSE
$tagStr$ = $smsBody$
ENDIF
$tagValDelimiter% = INSTR 2, $tagStr$, $delimiter$ // Index of the tag value and name separator
$tagName$ = $tagStr$(1 TO ($tagValDelimiter% - 1)) // Extract the tag name
$tagValue = VAL($tagStr$(($tagValDelimiter% + 1) TO LEN($tagStr$))) // Extract the tag value
SETIO $tagName$, $tagValue // Assign the value to the tag
// If the delimiter is anything other than a 0 it means we have more tags
// to process so recursively call this function until the end.
IF $tagDelimiterIndex% <> 0 THEN
@smsTagAssign($smsBody$(($tagDelimiterIndex% + 1) TO LEN($smsBody$)))
ENDIF
ENDFN
Usage with SMS:
INIT Section:
ONSMS "GOTO HSms"
HSms:
a% = GETSYS PRG, "SmsRead"
IF a% <> 0 THEN
message$ = GETSYS PRG, "smsmsg"
@smsTagAssign(message$)
ENDIF
END