Creating local reference variables

I am trying to create a local reference variable in my project but it will not allow me to do so. I get the message " Reference variables have to be declared local. Change file path or remove reference flag" . I am trying to use the ACCESS command to convert my ASCII characters into a string. We have it working on another project / computer but doesn’t seem to work on the computer we are working on. Any ideas would be appreciated.

Hello,

maybe you can provide more information like the errornumber, your used versions or some screenshots of the issue.

Generally speaking if the same code is working in another project you might want to check and compare the project settings of both of your projects.
Menubar → Project → Change Runtime Version → Build (Compiler, Defines, etc.)
Menubar → Project → Settings

BR Fabian

Could it be that the .var file is in a package and not in a task.
image

2 Likes

It seems to be something on my computer. It will not allow me to create a local, reference variable. Here are some screen shots of the error and the versions I am usin

The TE_Scanner_IFace.var is located outside the task so is in the package, which generates a global variable.

Hello,

Do you change the Declaration File path manualy?

Which AS-Version is this?

because if i cklick the “Local” Checkbox in AS4.12.5.95 SP, it will immediatly change the Path of the .Var-File to the local one.


Can you check if the Program will work if you declare your Variable in the .var File manualy.
Open Declaration File and set the Declaration.

Greetings
Michael

I changed the variable file to make it local to the program and it allows me to compile without any errors. Now I am looking for a solution to convert a block of 30 bytes to 1 string. The scan code is created by my barcode scanner in 30 bytes. I have them mapped to a string with 30 elements. When I run the ACCESS command I don’t see any data but there is data in the bytes.

If I run them individually. TE_Scanddata, TE_Scandata1 … and map them the each of the read_data, I get the whole string on the 4 one. The others seem to give bits of the string.

Can you post a picture from watch-Window with the Data-Values.
It might be that if there is one of the Values 0, which is the endmark of a String, your String-Pointer does not show all.

Read_Data[0…30] can also be a USINT-Array in this case you do not need the Conversion i think.

In addition the Watch window can not show 200 Characters, so i think you display it in an Visu? Just to be sure that its not only a Display issue in Watch.

Greetings
Michael

If you have an array of USINTs representing ascii characters you can do a memcpy to copy them into a string.