I have a college which tried this some time ago and did not find an elegant way.
Depending on the usage of this String … VC4, MappView, ArLogger i could think about using the Textsystem to move the Data from the Code to some other source. In this way you can use a Windows Batch to create the Textsystemfile from the .var File entrys. It also enables some additional Language change options. The Batch-File can be added to the Compile of the AS via the Pre-Build Step in the Build Events.
But if you use it in many different Step-Cases it can also grow fast to an un-elegant way.
last but not least, you have to write the “currentStep”:
current_step := 'INVALID STEP';
FOR i := 0 TO SIZEOF(textEnum)/SIZEOF(textEnum[0])-1 DO
IF textEnum[i].enum_val = en_test THEN
current_step := textEnum[i].text;
EXIT;
END_IF
END_FOR
That way your array does not have to have the same order than your enum.
If the variable is also activated as on OPC UA variable, this information can be read out with OPC UA client function blocks. This EnumStrings can be reached by adding /0:EnumStrings to the browsepath of this enum variable. I have a sample package, but I have not put it yet on GitHub.
It looks like you got some good suggestions from other community members, and it has been a couple of weeks since the last activity on this post. Can you please mark the reply that helped you the most as the solution? Or if you still have open questions on this topic, can you please provide an update?
i don’t think mappview can handle browse paths.
You could use the numeric identifier to reach the array of strings, but you have to get this numeric identifier first.
This numeric identifier could problably change when a the project is changed.