Post by timvh on Array to String
CODESYS Forge
talk
(Post)
The string_Util_Intern is not the library I referred to. With a CONCAT function (also with the string util library) a search is done for the NULL character. If you concatenate 20000 characters to one string, then the longer the string, the longer it takes to find this NULL character.
Last updated: 2024-07-24
Post by corriibme on JSON Utilities and SetArray
CODESYS Forge
talk
(Post)
Hello @florian, Could you please help with how to set an array value? I've been trying to use the with the setKeyWithArray method which creates the key with an empty array value. But I have been unable to set items in this array? objindex:= fb_JBuilder.SetKeyWithArray("Key6", diParentIndex := diRootIndex); objindex2:= fb_JBuilder.SetValue(value:= iValue2, diParentIndex:= objindexx); //iValue: array[0..n] of int; Best regards
Last updated: 2024-05-11
Post by critcho on WebVisu Numpad dialog - Dialogtitle not accepting string variable
CODESYS Forge
talk
(Post)
I have a WebVisu page which is re-used for multiple types of gas; it displays the alarm thresholds etc. for one gas at a time. I have an array of structures holding the set-points for each of the gasses. I'm trying to change the dialog title for the value input pop-up (VisuDialogs.Numpad). The Dialogtitle is set to Gas_Alarms.HighAlarmActivationLevelDialog, which is a string(50): When the gas type is changed (page first loaded, or prev/next buttons), METHOD Gas_Alarms.Update_Display_Variables is called, to update the strings used for the dialog titles so it shows GasName High Alarm Activation Level (EngineeringUnits), e.g. CO2 High Alarm Activation Level (PPM): HighAlarmActivationLevelDialog := Insert(' High Alarm Activation Level ()', EngineeringUnits, 30); HighAlarmActivationLevelDialog := Insert(HighAlarmActivationLevelDialog, GasName, 0); (That's not where the problem is, I'm just explaining why I'm using a variable dialogue title.) The variables used are definitely strings, but i'm always getting the error: "The type of the dialog title must be either STRING or WSTRING". I've tried moving HighAlarmActivationLevelDialog etc. to the GVL and also changing them to WSTRING, I even tried adding them to the structure array, but I always get the same error. Clearing the dialog title for that element removes the error - so I'm confident it's not a phantom error caused by something else. But I should be able to add these titles, can't just nuke them all to make it work. The MinVal and MaxVal for the Numpad are called from the array, e.g. GVL.Gas_Alarm_Configs[0].ScaledValueMIN, they are not getting an error. I am using array indexes 1 - 5 for the gasses, when I load the form or change gas, I copy the selected index to index 0 of the array, and values from Gas_Alarm_Configs[0].[ALL] are displayed on the page. When they hit save, I copy Gas_Alarm_Configs[0].[ALL] to Gas_Alarm_Configs[CurrentGasIndex].[ALL]. (ALL just means every element, I can't figure out how to display an asterix in this question... :) ) I've searched online for variable title dialog, but not found anything to help. Thanks for your help!
Last updated: 2025-05-29
Ethernet/IP Symbolic Access to I/O Channels pass the EIP Device FB instance to another FB IN_OUT
CODESYS Forge
talk
(Thread)
Ethernet/IP Symbolic Access to I/O Channels pass the EIP Device FB instance to another FB IN_OUT
Last updated: 2023-08-01
Post by e13740e on Parameterized Property syntax for array element processing
CODESYS Forge
talk
(Post)
Since parameterized (indexed) properties are not possible, I decided to use architectural approach "Indexing Property Adapter" to achieve the intended goal β avoiding code duplication for validated access to array elements. Essence: Create a Function Block Adapter (FB_PropertyAdapter) that encapsulates the logic for working with a single element of the target array (e.g., with one settings structure). Declare Properties inside the adapter block for accessing each individual field of the data structure. All validation logic is implemented within the Set accessors of these properties. Data Binding via VAR_IN_OUT: The adapter block receives a reference to a specific data element from the global array through its VAR_IN_OUT section, which ensures direct work with the original data without copying. Create an Array of Adapters: In the parent POU (e.g., FB_SettingsManager), an array of these adapter blocks is created β one for each element of the global array that needs to be managed. Initialize Bindings: In a FOR loop, each adapter instance from the array is given a reference to the corresponding data element. Result: This approach allows accessing the data via the index of the adapter array, and then through the property name, which simulates the behavior of an indexed property: MyAdapterArray[Index].MyProperty Thus, the validation and data access logic is written only once inside the adapter block and is then reused multiple times by creating instances of it in an array. This completely solves the problem of code duplication while providing a clean, scalable, and object-oriented architecture compatible with standard CODESYS features. Question closed.
Last updated: 2025-10-19
Post by bmatlove on Variable Length Array - Cannot mix variable and fixed length dimensions?
CODESYS Forge
talk
(Post)
Using Codesys 3.5.18.30 I am trying to work with an array of variable length in one dimension, but known in the other dimension. For example, using an array that represents a list of items, each with an attribute profile. I do not know how many items will be in the list, but I know that every item has 5 attributes, like size, weight, etc. Codesys does not seem to be able to accept this. I have referenced Data Type: ARRAY OF documentation page, which is not explicit if variable & fixed length array dimensions can be mixed. In the VAR_IN_OUT scope, I initially tried MY_ARRAY : ARRAY [*, *] OF REAL; which was no problem, of course. I then modified it to MY_ARRAY : ARRAY [*, 1..5] OF REAL; which throws C0006: ', or ]' expected instead of '..' among consequent downstream errors. I then used the Auto Declare -> Array Wizard, which accepted (asterisk)-(asterisk) and 1-5 for 2-dimensional lower and upper bounds. It output: MY_ARRAY: ARRAY[*..*, 1..6] OF INT; which throws the same error stream. What's the deal here? Is this possible?
Last updated: 2025-05-23
Post by rmaas on STRING conversions to DWORD
CODESYS Forge
talk
(Post)
Hi, The '' characters in Codesys are there only to indicate it is a STRING type. They are not actually added to the string, maybe you are adding them unintentionally in the concat function? You can send your data from Codesys to Hercules to verify... Another option is to send the data as an array of bytes instead of a string, with every byte representing 1 ASCII character. https://www.ascii-code.com/ This way you are 100% sure Codesys is not adding any unwanted characters.
Last updated: 2025-01-31
Post by e13740e on Parameterized Property syntax for array element processing
CODESYS Forge
talk
(Post)
Hello. I'm trying to create a Parameterized Property(CDS V3.5 SP21) to avoid copy-pasting code for processing array elements. I can't seem to get any result. Perhaps I am making a mistake with the syntax. None of the declaration options below are accepted by the compiler. If you know and use them (Parameterized Properties) in your work, please let me know. Thank you in advance. Option 1: PROPERTY <property_name> : <data_type> VAR_INPUT <index_name> : <index_type>; // One or more index parameters are declared here END_VAR</index_type></index_name></data_type></property_name> GET Code that uses <index_name> to return a value END_GET</index_name> SET Code that uses <index_name> and the implicit variable <property_name> to write a value END_SET</property_name></index_name> END_PROPERTY Option 2: PROPERTY <property_name> (<index_name> : <index_type>) : <data_type></data_type></index_type></index_name></property_name> GET Code that uses <index_name> to return a value END_GET</index_name> SET Code that uses <index_name> and the implicit variable <property_name> to write a value END_SET</property_name></index_name> END_PROPERTY
Last updated: 2025-10-09
Post by e13740e on Parameterized Property syntax for array element processing
CODESYS Forge
talk
(Post)
Hello. I'm trying to create a Parameterized Property(CDS V3.5 SP21) to avoid copy-pasting code for processing array elements. I can't seem to get any result. Perhaps I am making a mistake with the syntax. None of the declaration options below are accepted by the compiler. If you know and use them (Parameterized Properties) in your work, please let me know. Thank you in advance. Option 1: PROPERTY <property_name> : <data_type> VAR_INPUT // One or more index parameters are declared here <index_name> : <index_type>; END_VAR</index_type></index_name></data_type></property_name> // Accessor for reading GET // Code that uses <Index_Name> to return a value END_GET // Accessor for writing SET // Code that uses <Index_Name> and // the implicit variable <Property_Name> to write a value END_SET END_PROPERTY Option 2: PROPERTY <property_name> (<index_name> : <index_type>) : <data_type></data_type></index_type></index_name></property_name> // Accessor for reading GET // Code that uses <Index_Name> to return a value END_GET // Accessor for writing SET // Code that uses <Index_Name> and // the implicit variable <Property_Name> to write a value END_SET END_PROPERTY
Last updated: 2025-10-09
Post by ewi04 on Recipe Manager - RecipeManCommands, load & write wrong values, Bug?
CODESYS Forge
talk
(Post)
It seems that there is a limitation with the STRUCTs. Does anybody know, whatβs okay to save (add to the recipe) and whatβs not okay? Or is there another problem with my project? If I have only an array in the recipe definition everything works perfectly (see project).
Last updated: 2023-11-15
one variable signed to modbus tcp server device and modbus serial device
CODESYS Forge
talk
(Thread)
one variable signed to modbus tcp server device and modbus serial device
Last updated: 2025-07-17
how to get a list of the cross reference of one variable
CODESYS Forge
talk
(Thread)
how to get a list of the cross reference of one variable
Last updated: 2018-01-17
How to check whether one input is assigned a value?
CODESYS Forge
talk
(Thread)
How to check whether one input is assigned a value?
Last updated: 2008-01-15
Several py file share one external file to get some default value
CODESYS Forge
talk
(Thread)
Several py file share one external file to get some default value
Last updated: 2019-12-12
[libdoc][sphinx] How to execute libdoc for more than one library?
CODESYS Forge
talk
(Thread)
[libdoc][sphinx] How to execute libdoc for more than one library?
Last updated: 2020-06-26
Eliminate an expired demo licese to use a valid full one.
CODESYS Forge
talk
(Thread)
Eliminate an expired demo licese to use a valid full one.
Last updated: 2015-10-28
Test Manager - Having a user value persist from one execution to the next
CODESYS Forge
talk
(Thread)
Test Manager - Having a user value persist from one execution to the next
Last updated: 2023-05-08
How to read the status of one Modbus Slave in the codesys program
CODESYS Forge
talk
(Thread)
How to read the status of one Modbus Slave in the codesys program
Last updated: 2021-08-15
How to make my own library / edit an existing one?
CODESYS Forge
talk
(Thread)
How to make my own library / edit an existing one?
Last updated: 2010-11-24
How to remove other libraries and keep the only one I have created.
CODESYS Forge
talk
(Thread)
How to remove other libraries and keep the only one I have created.
Last updated: 2023-12-18
Post by apurv on Cannot pass array of constant size to a function as a reference
CODESYS Forge
talk
(Post)
okay but will this pass the array by copying it or it will be a reference to original array only.
Last updated: 2024-01-09
Post by tehthoams on Find Function: Object reference not set to an instance of an object.
CODESYS Forge
talk
(Post)
Hey, Sorry this isn't super helpful, but i had this problem once and was able to resolve it. I can't recall how I solved it and whether it was a problem with my codesys installation or the project itself. If it is the codesys installation, make sure all your required libraries and plugins are installed and available. compare with a colleagues installation if possible. I vaguely recall saving a copy of my project and deleting things one by one until the error went away...
Last updated: 2023-10-30
Post by tehthoams on Find Function: Object reference not set to an instance of an object.
CODESYS Forge
talk
(Post)
Hey, Sorry this isn't super helpful, but i had this problem once and was able to resolve it. I can't recall how I solved it and whether it was a problem with my codesys installation or the project itself. If it is the codesys installation, make sure all your required libraries and plugins are installed and available. compare with a colleagues installation if possible. I vaguely recall saving a copy of my project and deleting things one by one until the error went away...
Last updated: 2023-10-30
Post by nz-dave on Codesys 3.5.21 fails to copy file to USB
CODESYS Forge
talk
(Post)
So did you get it working?
Last updated: 2025-05-27
Post by corriibme on Setting array values with JSON Utilities SL
CODESYS Forge
talk
(Post)
I have been trying to set an array value to a JSON structure of this form: {"key": [1,2,3,4]} While I have been able to create the key and set its value to an empty array, I've not had any luck in putting any value in that array. objindex:= fb_JBuilder.SetKeyWithArray("Key6", diParentIndex := diRootIndex); objindex2:= fb_JBuilder.SetValue(value:= iValue2, diParentIndex:= objindex); iValue2: ARRAY[0..3] OF INT:= [1,2,3,4]; The two lines of code above produce {"key6": []} . The second line essentially has no effect.
Last updated: 2024-05-12
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.