Hi guys,
I was wondering if it was possible to read or write the texts in the tmx files to string variables? If it is, how would it interact with changing languages?
Hello JackLin,
You can use the ArTextSysGetText() function block to obtain the text from a known Namespace and TextID. An input to the function block is the Language you would like to obtain for that TextID.
ArTextSysGetText() - B&R Online Help (br-automation.com)
Remember that the encoding is different coming out of the text system (UTF-8), so you will need httpUtf8ToWString() from the AsHttp library to convert them to WSTRING.
Hey Austin, my Automation Studio doesn’t have these function blocks. I’m on version 5.24.1. Is there somewhere where I can download the library for these?
Hello JackLin:
I’m assuming the 5.24.1 is version of mapp Components, as AS is still on Version 4.XXX. Regarding the function block ArTextSysGetText(), is on the library ArTextSys
You don’t need to download the library, as it already in AS. you only need to add them to your project to use them. To do so: In the toolbox, click on B&R Library,
And the select the ArTextSys
With this, you have the library added to your project.
Hope it helps
Alright, I got the function blocks. How do I format Namespace and TextID though? Based on the formatting help file, this is my attempt but its not working.
What does the help file mean when it says Namespace is datatype: UDINT
(given as a pointer to STRING)??
Hi,
that means that the address of a string variable has to be used instead of the string variable itself.
An address (= position of the memory in RAM, where the data of the variable is stored / begins) in B&R System always has 4 byte, so it’s of the type UDINT.
// this is my string variable
myString := 'this is my string value';
// this is the pointer of type UDINT
myPointer := ADR(myString);
Ok I’m almost there. The last thing I don’t understand is, after I run artextsysgettext(), where does the utf-8 result go? (Ignore everything above GetText)
None of the 5 outputs in artextsysgettext() are the actual results, the only string-outputs are textSize and statusID. I don’t know what to put in pSrc in my httputf8towstring function. Here, I tried directly putting “GetTextI01” (which is the tag for my function) in pSrc, but its not working.
Speaking of httputf8towstring, when that function completes, where does that output go?
You have to provide also a result buffer for the text when calling ArTextSysGetText, using the elements .TextBufferSize and .TextBuffer of the function block interface.
Let’s assume your text to read has a maximum length of 128 byte, then you need a string[128] for result, so declare the string variable, for example “myResultString”, and add into your function block call also
TextBuffer := ADR(myResultString), TextBufferSize := SIZEOF(myResultString)
Best regards!
It finally worked, thanks Alexander! Surprisingly, I didn’t need httpUtf8ToWString() to do this, but its working so I won’t question it.