Finding the address of a variable from the symbol name as a string.

CapinWinky

Level-1
Beiträge
2
Reaktionspunkte
0
Zuviel Werbung?
-> Hier kostenlos registrieren
I'm using KEBA (KeyStudio FlexCore 4.1.2 = Codesys 3.x) and I would like to take a string containing the name of a variable (symbol name) and somehow get the address and size of the variable. As an example, in B&R (not Codesys) I do this with the `PV_xgetadr()` function from the `SYS_Lib` library.

I have found `__System.VAR_INFO` and the` __VARINFO ()` function, which is very close to what I want, but it cannot take the symbol name as a string. Perhaps there is a conversion function that returns a symbol from a string of a symbol name?

My use case is looping through generic code with several arrays of non-generically named UDTs. For instance, I have temperature control code that loops through tuning and PID control with all the loops on a machine using a pointer that accesses several differently named loop control structures. I might have JawTemp [2], PlenumTemp, and SteamHeat [4] and I would just pass the generic control code an array of just the strings "JawTemp", "PlenumTem", and "SteamHeat" and it would figure out how many theirs were and their addresses and loop through all 7 of them.

I would like to port my B&R code over to Keba, but this crucial bit is missing. For now I have to long-hand a bit of code to create an array of the 7 addresses, but sometimes I'm working with hundreds of zones with dozens of different group names with different numbers of elements in the groups, so I'd like to get it working.
 
Zurück
Oben