0

I am using Twincat 3 (4024.10) and I tried the functions "GetTextByStringId" and "GetText" from the library SysLibTargetVisu but the compiler already gives me an error:

Error Unresolved reference: 'GETTEXTBYSTRINGID' 0

It seems that in Codesys 2 works: https://forge.codesys.com/forge/talk/CODESYS-V2/thread/8f2fc2e158/

Thanks in advance!

2 Answers2

1

I remember wasting my time on that too. Unfortunately it seems to be an old undocumented and unmantained library.

I resolved the issue in a couple of hours by writing an xml reader in Java that reads the ids and the texts from the textlist and pushes them over ads to the plc where they are stored in memory. The values can then be used as needed.

The other advantage from this approach is that you do not dipend on the plc hmi license.

Filippo Boido
  • 1,136
  • 7
  • 11
  • Let me confirm if I understood you correctly. You read an XML file into a KeyValue structure on a PC and send it to the PLC? – Guiorgy Oct 13 '20 at 11:59
  • 1
    The functions mentioned above fetch the text from a textlist. The textlist has an xml format, so you can use xml parser libraries to fetch those texts from outside the plc runtime.Next you write the results you fetched in the plc through the beckhoff ads interface in arrays or structs or an array of structs – Filippo Boido Oct 13 '20 at 13:57
  • This has the disadvantage of needing an outside system, but a clever hack non the less. However, I was under the impression that those kind of files would be stored internally, and inaccessible from the outside. Could you provide a few sources to read up on similar cases? – Guiorgy Oct 13 '20 at 14:37
  • 1
    If you create a textlist in your Twincat engineering system and then go to the project folder you can open it with your prefered xml editor.You can then put the file on the target system where your plc runtime and your xml reader is located.You could also have your app run on a server or somewhere else on the network depending on your architecture and perform remote ads calls to your plc runtime. – Filippo Boido Oct 13 '20 at 17:23
  • 1
    Regarding the argument around the external system, I don't see it as a disadvantage.The fact that we run a plc runtime beside a windows environment like in the case of the Twincat is exactly because we want to have access to the resources of the windows operating system.You can also start applications from your plc runtime with the NT_StartProcess function block.Let Userland applications help the plc in what they can do best (separation of concerns) and the plc take care of real time tasks. – Filippo Boido Oct 13 '20 at 17:34
0

I found a solution at the library VisuElems. It actually works. This is the function:

FUNCTION F_GetText : STRING
VAR_INPUT
    sTextList : STRING;
    sId : STRING;
END_VAR

sTextList := CONCAT('Port_851.',sTextList);
F_GetText := VisuElems.CmpDynamicText.DynamicTextGetText(
    pstTextList:= ADR(sTextList), 
    pstTextIndex:= ADR(sId)
    )^;

And at the program we call it like this:

sTest := F_GetText(sId := 'maschine', sTextList := 'TL_Visu');

You might want the default translation. Lets say the default translation is german and we have the constant:

DE: STRING(8) := 'default';

The function is:

sTextList := CONCAT('Port_851.',sTextList);

IF VisuElems.CURRENTLANGUAGE = DE THEN
    F_GetText := VisuElems.CmpDynamicText.DynamicTextGetDefaultText(
        pstTextList:= ADR(sTextList), 
        pstTextIndex:= ADR(sId)
        )^;
ELSE
    F_GetText := VisuElems.CmpDynamicText.DynamicTextGetText(
        pstTextList:= ADR(sTextList), 
        pstTextIndex:= ADR(sId)
        )^; 
END_IF

I got with this solution from this german webpage: https://www.sps-forum.de/archive/index.php/t-88760.html