Jump to content

Store string as local or global tag


Recommended Posts

Dear All,


I created a struct for DT with 2 tags; first tag is an INT16 The second is a STRING (ASCII); in the STRING tag of DT I can store one of others two STRING tag that have a "fix" value...first like "IN" and second like "OUT"...if for these 2 string I assigned, as scope, LOCAL in the DT I have a strange symbol like a rectangle...if I change these two strings as GLOBAL it works....why? all string tags have the same lenght.


thanks in advance

Link to comment
Share on other sites



A rough explanation of the two types of memory in UniLogic:  The global tags are part of the "main memory" which is constant memory space reserved throughout the program.  The local tags are part of the "stack memory" which is allocated and deallocated as the program runs.   When a subroutine is called, it will allocated the necessary space for the local tags, and once the subroutine is finished and you return to the main routine, the space allocated for the local tags are then deallocated; besically it is erased and completely forgotten about once the routine ends. 


So if you wish to keep information in the local tags after a routine has finished, you must pass these values into global tag space. 


Are you saving the local memory into the DT within the subroutine?

Link to comment
Share on other sites

Hi S.pratt,


thanks for the answer.

Yes, I am saving local memory into the DT in the same subroutine.  

Then, if I have well understood, I have to consider the "start up value" like a "retain" option that it is not available for the local tag...it has sense

I had checked into help menu what is availabe or not for local tag and I found: 


Note that Local tags cannot:
- retain value
- be used in HMI applications
- be seen in On-Line mode


So I thought that, maybe, it could have a start up value because it is not highlighted as "cannot"...and when I have inserted the "start up value" I don't have had a warning message.

Link to comment
Share on other sites

Hi Saragani,


Attached an example that shows what I had done at the beginning (pic tag editor hello); when I tried to store the string tag into a DT tag, the value, that the DT grid has shown, was a simbol like a  "square"...the string tag was not called in other action.
Other question...I found out that if  I select "local" on the Tag editor I have two rows where I can insert the "power-up value" (see pics tag editor local and tag editor global)...this happens only for string tag and not for the others...which difference between the two position?





Link to comment
Share on other sites

The 2 power-up fields issue is a bug, and since this is the first time this issue is being reported, then it will only be fixed on UniLogic 1.17

Furethermore, I see that your Main function contains a Local tag (maybe it is only for this example), but practically, we don't allow Function-In/Out or local tags in the start-up function.


As for the original issue,

It seems that there is another bug, related to the initialization of local strings (The initial value of local strings doesn't work), but instead of using an Initial value, you can just use "Store String" (at the first rung, for example) in your function, where the input is the Const value you want to give to that string (for example #"Hello"), and the output is the local string.

This explains the squares you got. The local strings remained with whatever the memory contained.

This issue will also be fixed only on UniLogic 1.17



Thank you for your reports.

  • Upvote 1
Link to comment
Share on other sites

Hi Saragani,


thanks for your answer.
Yes I have created it for exaple.
To be honest I had tried to insert a fix value instead of a tag...but I wrote #hello instead of #"hello" and it doesn't work (sorry I am still be a newbie); this is the reason why I tried with a local tag.
When the new release will be available I will download immediately.
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...