Create tags in script and reference tags for OnChange in same script

Howdy,
I’ve got a script that creates several tags, example below.

$L$ = ‘"’+“EX_TAG”+’";“MEM”;0’+’;1;0’+Chr$(13)+Chr$(10)
Putftp “/var_lst.txt”,$HEADER$+$A$+$B$+$C$+$D$+$E$+$F$+$G$+$H$+$I$+$J$+$K$+$L$,"adm:adm@127.0.0.1"
SETSYS SYS, “LOAD”
SETSYS TAG, “SAVE”
CFGSAVE

I then reference those tags later in the same script, example:

EX_TAG$ = “EX_TAG”
or
ONCHANGE “EX_TAG”, GOTO

but the tags are not recognized variables.

So I added the SETSYS SYS, “LOAD”, SETSYS TAG, “SAVE”, CFGSAVE lines to my script as it looked like they would get the system to refresh what tags are actually loaded in the config to be used further down but that isn’t working. What can I do here?

Hi Justin,

Are you able to add tags to the tag list in this way? I’d like to determine if the issue is with adding tags in the first place or with referencing them in the script. If so, can you attach a backup with support files so we can see your full script? I’ve had trouble getting it to work on my device.

Here is a script that definitely works to add tags to the Ewon. Rather than writing to the root, it first writes the var_lst file to /usr, then uses GETFTP to bring this file into the Ewon’s root.

// Create var_lst.txt
EoL$ = CHR$(13) + CHR$(10) // End of Line characters

// Header row
vl$ = '"Name";"Description";"ServerName";"TopicName";"Address";"Type"' + EoL$

// Define Tags
vl$ = vl$ + '"Boolean_Tag";"Internal MEM Tag (type 0)";"MEM";"";"Boolean_Tag";0' + EoL$
vl$ = vl$ + '"Floating_Point_Tag";"Internal MEM Tag (type 1)";"MEM";"";"Floating_Point_Tag";1' + EoL$
vl$ = vl$ + '"Integer_Tag";"Internal MEM Tag (type 2)";"MEM";"";"Integer_Tag";2' + EoL$
vl$ = vl$ + '"DWord_Tag";"Internal MEM Tag (type 3)";"MEM";"";"DWord_Tag";3' + EoL$
vl$ = vl$ + '"String_Tag";"Internal MEM Tag (type 6)";"MEM";"";"String_Tag";6' + EoL$
vl$ = vl$ + '"System_Up_Time";"Time in seconds that System has been running";"EWON";"SYS";"SYS_UP";3' + EoL$
vl$ = vl$ + '"Remotely_Connected_Users";"Number of remote users connected via Talk2M";"EWON";"SYS";"T2MConnectedUsers";2' + EoL$
vl$ = vl$ + '"Digital_Input_1";"Digital input #1 (Ewon power connector)";"EWON";"";"DI1";0' + EoL$
vl$ = vl$ + '"Digital_Input_2";"Digital input #2 (Ewon power connector)";"EWON";"";"DI2";0' + EoL$
vl$ = vl$ + '"Digital_Output_1";"Digital output #1 (Ewon power connector)";"EWON";"";"DO1";0' + EoL$

// Write var_lst.txt to USR folder on the Flexy
CLOSE 1
OPEN "var_lst.txt" FOR BINARY OUTPUT AS 1
PUT 1, vl$
CLOSE 1

// Use FTP to copy var_lst.txt from USR folder to the root folder of the Flexy
SETSYS COM, "Load"
LANIP$ = GETSYS COM, "EthIP"  // Get LAN IP Address
GETFTP "/usr/var_lst.txt", "/var_lst.txt", "adm:adm@" + LANIP$ + ":21, 1"  // The FTP server is the Flexy itself
PRINT "Tags Created..."
END

I have had some success at referencing the created tags after the end of the script by including a timer to allow the Ewon time to process the addition of the new tags and then refreshing the tag list page to ensure they show up within that time. However, I recommend posting on https://techforum.ewon.biz/ for more information on how the Ewon handles changes to its tag list, as the Ewon developers there will be more knowledgeable about the specifics.

GETFTP seems to have a character limit on what can be submitted. I get a “quote is too long” error.

Working on getting you the backup file

I need a dropbox location to send the files. My IT is blocking the files from going through.

Hello?

Hi Justin,

I apologize for the delay. We don’t have a place to upload files for the forum other than on the forum itself. If you want to submit a ticket through our support portal (https://support.hms-networks.com/), that is another avenue for uploading files.

That works, thanks.

Ticket# 78169

The issue, resolved in the ticket, was that the tags take a few seconds to become available and so a timer delay was needed to run the initial function after several seconds.

2 Likes