For Loop Counter converted to String

Can you please provide a snippet of code to use a for loop counter variable to generate a dynamic tag name something like:

A$ = “chr_”

L$ = “”

FOR I = 1 TO 10

L$ = L$ + A$+STR(I)+”@”

NEXT I

@anontucwfekq

Jeff,
The code you pasted above actually is quite close to what you would need to do.

a$ = "chr_"

FOR i% = 0 TO 10 
    t$ = a$ + STR$ i%

    REM Create a new tag in the eWON
    SETSYS TAG, "LOAD", "TemplateTag"
    SETSYS TAG, "NAME", t$
    SETSYS TAG, "Address", "Tag Address"
    SETSYS TAG, "SAVE"
    CFGSAVE
NEXT i%


Basically what the above code does is it loops through 10 times and will incrementally create a tag named: chr_1, chr_2, chr_3 …

Once it creates the tag name it will then create the tag in the eWON. The only pre-req here however is that you will want to have a “template” tag created first. This allows your new tag to simply copy the other information (IOServer, alarms, etc) to the newly created tag. You can however set all of those fields manually as well.

Take a look at page 126 of the below linked programming reference guide to see all tag fields.




Programming Reference Guide: Download