Post by jzhvymetal77 on IecVarAccessLibrary.IBaseTreeNode methon
CODESYS Forge
talk
(Post)
I had this code working in a previous version of CoDeSys to read variables from a GVL that were added to the Symbol configuration. The problem now is that when I get the _IBaseTreeNode_Parent, it returns a valid interface, but none of the methods or properties work. If you monitor the _IBaseTreeNode in the watch window, it does show the correct child count. However, it fails at step 30, where the child count incorrectly returns zero. In the image, you can see that the watch window displays the correct value that the property should return. Attached is the full project code. FUNCTION_BLOCK Symbols_TO_STR VAR_INPUT i_sPath : STRING(255); i_diIndexChild : DINT; i_diIndexComponent : DINT; END_VAR VAR_OUTPUT q_diChildCount : DINT; q_diComponentCount : DINT; q_sName : STRING(255); q_sValue : STRING(255); q_sType : STRING(80); q_sErrorResult : STRING(80); END_VAR VAR uiStepCopy : UINT; uiStep : UINT; uiStepProcessCopy : UINT; uiStepProcess : UINT; _IBase : IecVarAccessLibrary.IBase; _pIIecVarAccess5 : POINTER TO IecVarAccessLibrary.IIecVarAccess5; _IIecVarAccess5 : IecVarAccessLibrary.IIecVarAccess5; _RTS_IEC_RESULT : IecVarAccessLibrary.RTS_IEC_RESULT; _udiResult : UDINT; _VariableInformationStruct : IecVarAccessLibrary.VariableInformationStruct; _IBaseTreeNode_Parent : IecVarAccessLibrary.IBaseTreeNode; _IBaseTreeNode_Child : IecVarAccessLibrary.IBaseTreeNode; _ITypeDesc_Child : IecVarAccessLibrary.ITypeDesc; _TypeDescAsUnion_Child : IecVarAccessLibrary.TypeDescAsUnion; _arIBaseTreeNode_Child : ARRAY[0..20] OF IecVarAccessLibrary.IBaseTreeNode; _TypeClass_Child : IecVarAccessLibrary.IBaseLibrary.TypeClass; _psSymbolName_Child : POINTER TO STRING; _sSymbolName_Child : STRING(255); _IBaseTreeNode_Component : REFERENCE TO IecVarAccessLibrary.IBaseTreeNode; _TypeClass_Component : IecVarAccessLibrary.IBaseLibrary.TypeClass; _ByteAddress_Component : __XWORD; _ByteOffset_Component : __XWORD; _sArrayIndexName_Component : STRING(20); _diArrayIndexCalc_Component : DINT; _diArrayIndexValue_Component: DINT; _psSymbolName_Component : POINTER TO STRING; _sSymbolName_Component : STRING(255); END_VAR uiStepCopy:=uiStep; uiStepProcessCopy:=uiStepProcess; CASE uiStep OF 10: // GET IBASE FROM CURRENT APP _IBase:= IecVarAccessLibrary.IecVarAccGetFirstInterface2(0); IF _IBase<>0 THEN uiStep:=20; ELSE q_sErrorResult:=CONCAT(UINT_TO_STRING(uiStep), ': IecVarAccGetFirstInterface2'); uiStep:=9000; END_IF 20: //QueryInterface IIecVarAccess5 from IBASE _pIIecVarAccess5 := _IBase.QueryInterface(IecVarAccessLibrary.ITFID_IIecVarAccess5, ADR(_RTS_IEC_RESULT)); IF _pIIecVarAccess5<>0 AND _RTS_IEC_RESULT=0 THEN _IIecVarAccess5 := _pIIecVarAccess5^; uiStep:=30; ELSE q_sErrorResult:=CONCAT(UINT_TO_STRING(uiStep), ': QueryInterface_IIecVarAccess5'); uiStep:=9000; END_IF 30: // Get IBaseTreeNode_Parent _IBaseTreeNode_Parent := _IIecVarAccess5.VarAccGetNode3(ADR(i_sPath), ADR(_VariableInformationStruct), ADR(_RTS_IEC_RESULT)); IF _IBaseTreeNode_Parent<>0 AND _RTS_IEC_RESULT=0 THEN q_diChildCount:=_IBaseTreeNode_Parent.ChildCount; uiStep:=40; ELSE q_sErrorResult:=CONCAT(UINT_TO_STRING(uiStep), ': IBaseTreeNode_Parent'); uiStep:=9000; END_IF 40: // Get IBaseTreeNod_Child IF(q_diChildCount-1>=i_diIndexChild AND i_diIndexChild >=0) THEN _IBaseTreeNode_Child := _IBaseTreeNode_Parent.GetChild(i_diIndexChild); IF _IBaseTreeNode_Child<>0 THEN uiStep:=50; ELSE q_sErrorResult:=CONCAT(UINT_TO_STRING(uiStep), ': IBaseTreeNode_Parent'); uiStep:=9000; END_IF ELSE q_sErrorResult:=CONCAT(UINT_TO_STRING(uiStep), ': i_diIndexChild OutBounds'); uiStep:=9000; END_IF
Last updated: 2025-08-20
Post by timo on String nach erlaubten/unerlaubten Zeichen durchsuchen
CODESYS Forge
talk
(Post)
Hallo, Ich bastele gerade an einer möglichst einfachen Möglichkeit mit der ich prüfen kann ob ein String Sonderzeichen enthält. Mein Ansatz ist ein ST FB mit einer Case Schrittkette. Ich vergleiche jedes Zeichen des Strings mit allen Zeichen eines vorher definierten Strings erlaubter Zeichen, der A-Z, a-z und 0-9 enthält und ggf angepasst werden kann, wenn ich weitere Zeichen erlaube. Leider wird meine j Zählervariable nicht richtig ausgeführt. Hat da jemand eine Idee? Oder gibt es eine einfachere Lösung/einen fertigen FB den ich mir anschauen kann? FUNCTION_BLOCK Sonderzeichen_Check VAR_INPUT inputString : STRING; // Zu prüfender String startCheck : BOOL; // Startsignal END_VAR VAR_OUTPUT ok : BOOL; // TRUE, wenn keine ungültigen Zeichen END_VAR VAR i : INT := 1; // Input-String Zähler j : INT := 1; // erlaubte Zeichen Zähler allowedChars: STRING := 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; // Erlaubte Zeichen currentChar : STRING[1]; // Aktuelles Zeichen step : INT := 0; // Schritt END_VAR CASE step OF 0: // Warten auf Start IF startCheck THEN step := 10; END_IF 10: // Initialisierungen i := 1; j := 1; ok := TRUE; // Standard: ok step := 20; 20: // Durchgehen des Eingangs-Strings IF i <= LEN(inputString) THEN currentChar := MID(inputString, i, 1); // Aktuelles Zeichen step := 30; ELSE step := 70; // Alle Zeichen ok END_IF 30: // Durchgehen der erlaubten Zeichen IF j <= LEN(allowedChars) THEN step := 40; // Zu Schritt 40 ELSE step := 60; // Ungültiges Zeichen END_IF 40: // Vergleich IF currentChar = MID(allowedChars, j, 1) THEN i := i + 1; // Nächstes Zeichen im Input step := 20; ELSE j := j + 1; // Nächstes erlaubtes Zeichen step := 30; END_IF 60: // Ungültiges Zeichen ok := FALSE; // Setze auf FALSE step := 0; 70: // Alle Zeichen ok step := 0; END_CASE
Last updated: 2025-01-20
Post by kurtk on SysProcess Execute Command unable to run commands with special characters
CODESYS Forge
talk
(Post)
Thank you for this additional information. Could you please provide the references to the official documentation where you found this information ? I got as far as: Then insert this: [SysProcess] BasePriority=Realtime Command=AllowAll devoid of references of where the CodesysContol.cfg file was located or of the need to run codesys as root I incrementally located bits of information with perplexity searches but remained mired at error 25 ERR_NO_ACCESS I am curious whether root access is MANDATORY to run SysProcessExecuteCommand (- and/or any other SysProcess functions) or if a more access-constrained User=quasiroot could suffice without the security concerns ? Apparently codesys runs fine without User=root for almost everything... That raises the question: What IS the default codesys user ? I notice in the prototypes: VAR sCommand : STRING := '/usr/bin/whoami'; sOutput : STRING(255); refCommand : REFERENCE TO STRING; refOutput : REFERENCE TO STRING; resultCmd : UDINT; END_VAR whenever I attempt to build this Codesys v3.5 SP2 whines that "cannot convert type REFERENCE TO STRING to STRING" don't remember the exact message... Apparently this happens whenever a fixed-length string is involved. if I get rid of (255) and just set the string := ' '; that is sufficient to make the compiler happy. Is this a recently enforced constraint ? Why does this compile for you and not for me ? There are references to functions / utilities which are used/needed to massage the string references - but I see no specific details... I also notice you specify: Make sure the lib SysProcessImplementation, SysTypes, and CmpErrors is on the project. I don't comprehend why all of the dependent libraries are not automatically referenced, added ? I don't recall seeing anywhere but here that SysProcessImplementation must be included... It just seems odd that the default is to exclude essential libraries, or require alchemical conjuring to assemble all the ingredients for gnat soup ;-) Thanks a lot... I'm still a codesys newby getting my wheels on - or sometimes just partially on
Last updated: 2025-09-12
Post by captaincookie on increase default string length in queue
CODESYS Forge
talk
(Post)
Hello, I'm using Codesys V3.5 SP18 Patch 4. In the ElementCollectionExample Project from Codesys, I test the SimpleQueueExample in a Control Win V3 x64 environment. I try to add a string of 95 characters length to a queue. The default length of strings is defined as 80 characters. In the initialization of a string variable, it is possible to increase the length by the definition of e.g. STRING(1000). But when I write the string defined like this to the queue, only 80 characters are written to it and the rest is missing. I think the default length is still set in the queue definition, so it is necessary to change this, isn't it? Is there any option to increase the default length of strings in the queue? Attached you can find the used project. Thanks in advance. If any information are missing or my description unclear please let me know.
Last updated: 2023-10-05
Post by andrebrandt on FB string and naming
CODESYS Forge
talk
(Post)
Hi Tim. Not quite correct. What i'd like, is when you place the FB in prog, i choose a block NTC10k, and name this RT401. What i'm trying to do, is to get the name RT401 automaticly into the FB, so i can put this into the string i pass in a struct. So in var in POU, i saw this a place i could do this, RT401: NTC10k(Tag:='RT401'), but i can't get this to work. I shurly must have had something like this in FB: FUNCTION_BLOCK NTC10k String TAG But it's here where I'm stuck...
Last updated: 2024-09-30
Post by struccc on HTML5 Controls - string(>80) values
CODESYS Forge
talk
(Post)
Dear all, does anyone have experience with HTML5 controls recently? CODESYS 3.5.20.30 / Visualization 4.6.0.0 I'd like to create a simple lightweight text editor, with proper multiline handling, cut & paste, scrolling, etc. And it seems to work fine, just have problems with strings longer than 80 bytes.... Declaring a variable sText1 : STRING(8000) and referencing it in the HTML5 Controls corresponding value property works perfectly one way: the code receive the data as a string (See log1)... (Note TypeID 1000...) Also sending back the data (seems to work (See log2) except it doesn't change the value of the bound variable. Probably the issue is with using SendSimpleValue method... Naturally, I could do a workaround, but maybe there is a more standard way to implement this... Please let me know if you have any suggestions.
Last updated: 2024-10-23
Post by shawn-plc on Return value from a tag given a string literal
CODESYS Forge
talk
(Post)
Good afternoon everyone, I am looking for a way to return a value given a string tag path. I put together a pseudo-example to illustrate my use-case and was wondering if anyone in this forum can help. The function fnValueFromTagPath is the function I am looking to either create or use from existing library. I would greatly appreciate it. Please see the attachment for additional detail. -Shawn
Last updated: 2024-08-13
Post by andrebrandt on FB string and naming
CODESYS Forge
talk
(Post)
Hi all. I have a FB written in ST. FUNCTION_BLOCK NTC10k VAR_INPUT Syst:STRING; In:REAL; END_VAR VAR_OUTPUT Out:REAL; OTag:STRING; Out_St:Struct_NTC10K; END_VAR VAR Tag:STRING; InstanceName: STRING; Structure:Struct_NTC10K; END_VAR What i'm trying to do, is to pass data to structure. In structure i want to add a tag with systemnumber and sensorname. '320.001-RT401' In pou i use this RT401: NTC10k;, and tried this RT401: NTC10k(Tag:='RT401'); Anyone done this?
Last updated: 2024-09-26
Post by vstrom on Recipe definition, how to have the Name string in current language?
CODESYS Forge
talk
(Post)
I'd like to know if it is possible to have the "Name" field, in the recipe definition, language dependent. Something like to have the possibility to put there a string ID that will be add to the GlobalTextList. In this way it can be translated and when showed in a Visualization screen its value depend on the current language. Thanks.
Last updated: 2024-10-04
Post by andrebrandt on BACnet dynamic create bacnet object
CODESYS Forge
talk
(Post)
Hi. I want to create a FB with bacnet objects. FUNCTION_BLOCK PT1000 VAR_INPUT System: STRING; In: REAL; Name:STRING; END_VAR VAR_OUTPUT Out: REAL; Out_St: Struct_PT1000; END_VAR VAR {attribute 'instance-path'} {attribute 'noinit'} Tag: STRING; Instance:DINT; //AnalogInn : WagoSysBACnet.FbAnalogInput_large(1); This works. Objectname is AnalogInn. identifier is 1 END_VAR I want to name object based on FB PT1000. In FB P1000, I want to write eUnits, Name and so on. How can i do this???
Last updated: 2025-01-15
Post by timvh on I want to show the current recipe name in the visualization screen
CODESYS Forge
talk
(Post)
Maybe the easiest solution for you is to add one STRING variable to your recipe and enter the name of the recipe in variable value. This is little bit double the work (naming the recipe and entering the value of the STRING variable), but in that case you always have the current value of the variable which you can read from the application and show in the visualization.
Last updated: 2025-09-04
Post by jzhvymetal77 on Special Chars in Visualizationfor QR code string
CODESYS Forge
talk
(Post)
In Visualization, is there any way to make special characters in a string display properly in a Text object? I wrote a function block to create QR codes at runtime. My code uses “$DB,” which in ASCII should render as a solid block. The code works, but to display it in Visualization I had to create multiple rectangles with visibility bound to a BOOL array. That works, but since each BOOL must be exposed as a separate variable, it consumes most of the available monitoring resources. See Attached image.
Last updated: 2025-09-29
Post by jzhvymetal77 on Special Chars in Visualizationfor QR code string
CODESYS Forge
talk
(Post)
In Visualization, is there any way to make special characters in a string display properly in a Text object? I wrote a function block to create QR codes at runtime. My code uses “$DB,” which in ASCII should render as a solid block. The code works, but to display it in Visualization I had to create multiple rectangles with visibility bound to a BOOL array. That works, but since each BOOL must be exposed as a separate variable, it consumes most of the available monitoring resources. See Attached image.
Last updated: 2025-09-29
Post by sedoerr on Check For Open Dialogs On Client
CODESYS Forge
talk
(Post)
FUNCTION CheckDialogOpen : BOOL VAR_INPUT sDialogName : STRING; END_VAR VAR pstClientData : POINTER TO VisuElems.VisuStructClientData; itfDialogManager : VisuElems.IDialogManager; itfMyDialog : VisuElems.IVisualisationDialog; END_VAR VisuElems.g_ClientManager.BeginIteration(); WHILE (pstClientData := VisuElems.VisuElemBase.g_ClientManager.GetNextClient()) <> 0 DO itfDialogManager := VisuElems.g_VisuManager.GetDialogManager(); itfMyDialog := itfDialogManager.GetDialog(sDialogName); CheckDialogOpen := VisuDialogs.VisuDlgUtil_IsDialogOpen(itfMyDialog,pstClientData,itfDialogManager); IF CheckDialogOpen THEN EXIT; END_IF END_WHILE
Last updated: 2023-09-26
Post by captaincookie on increase default string length in queue
CODESYS Forge
talk
(Post)
I solved it by creating a new element of IElement according to the ElementExample (MyElement) in the ElementCollectionsExamples project. The variables in this element can then be defined in any properties as needed.
Last updated: 2023-10-11
Post by timvh on Help with DynamicTextGetTextW
CODESYS Forge
talk
(Post)
First of all you need to enable "Use unicodestrings" in the Visualization Manager. This function returns a pointer to a WSTRING (not STRING). To get this wstring value, do something like this: VAR myWstringVariable : WSTRING(255); END_VAR myWstringVariable := myResult^; // this is dereferencing the pointer to the WSTRING.
Last updated: 2024-09-03
Post by opineiro on How to manage variable types larger than 64 bits - Ethernet/IP
CODESYS Forge
talk
(Post)
Thanks, that's what I thought initially. The point is that I can't select a String type variable. See the attached image
Last updated: 2024-09-23
Post by rmaas on CSV file and string manipulation.
CODESYS Forge
talk
(Post)
the $N stands for newline and $R stands for line break. maybe these combinations are considered as 1 character/position? Not sure, just a thought... see also: https://content.helpme-codesys.com/en/CODESYS%20Development%20System/_cds_operands_constant_string.html#:~:text=A%20string%20constant%20is%20a,belong%20to%20this%20character%20set.
Last updated: 2024-09-27
Post by nano on FB string and naming
CODESYS Forge
talk
(Post)
inside the fb, use the reflection-attribute and get the instancename includibg whole path.when im right, the applicationname will also reflected, if yes. you have to trim it. https://content.helpme-codesys.com/en/CODESYS%20Development%20System/_cds_pragma_attribute_instance_path.html
Last updated: 2024-10-02
Post by ph0010421 on Converting each character to a string into ASCII
CODESYS Forge
talk
(Post)
So the printer wants an ASCII conversion of the hex equivalent of ASCII characters?? They don't make it easy for us
Last updated: 2024-11-11
Post by thn-power on Opaque NodeId in the OPC UA server
CODESYS Forge
talk
(Post)
I'm wondering the same. Using the old symbol configurator opc ua server gave the node id using a string. Must be a way to specify this at build time?
Last updated: 2024-12-16
Post by timo on String nach erlaubten/unerlaubten Zeichen durchsuchen
CODESYS Forge
talk
(Post)
Vielen Dank. Das ist natürlich etwas eleganter zu prüfen ob ein ASCII Wert von meinen Zeichen abweicht. Der INT Zähler ist bei dir in der Deklaration anders benannt als im Code, aber das Konzept in meinem Code integriert funktioniert scheinbar.
Last updated: 2025-01-21
Post by jzhvymetal77 on Special Chars in Visualizationfor QR code string
CODESYS Forge
talk
(Post)
Ok I'm closer as I switch using WSTRING but in Visualization it does not respect LINE BREAKS. Instead it shows $n. See attached image.
Last updated: 2025-09-29
Post by paro on OPCUA array max length?
CODESYS Forge
talk
(Post)
I think the amount of data is already relatively high and maybe it has something to do with that? Maybe also the CPU load of your device? an array with string(5000)? and have you tested with how many array elements it still works?
Last updated: 2024-02-17
Post by dhumphries on Not able to see input data coming from eip adapter on codesys
CODESYS Forge
talk
(Post)
The green icon with an ! next to the device is concerning. Is the data type correct for the input, you are using a byte input but the description says string. Is there anything useful in the status tab?
Last updated: 2024-03-06
To search for an exact phrase, put it in quotes. Example: "getting started docs"
To exclude a word or phrase, put a dash in front of it. Example: docs -help
To search on specific fields, use these field names instead of a general text search. You can group with AND or OR.