4/16/2025 9:14 AM | |
Joined: 3/22/2013 Last visit: 4/17/2025 Posts: 10 Rating:
|
Hello 0_Einstein. For the first time I'm working on trying to create a code to empty a string (or an array of strings) with null characters and with 0 length. I tried to use your code about the FC and for me it doesn't work. This part of code inside the FC: "BEGIN is different from this part of code: some_str10 := "ConstantsDB".Null_str10; some_str10 := ""; Inside the FC "in_str10" is an in/out parameter of the FC and what I look and simulate is that the parameter is updated only at the end of the FC so only the last instruction is executed and the string remain with the privious elements with 0 length. If you reverse the order of the code the string is fill with 10 elements null and the length is 10. Put the "same" code outside of the FC works because the first instruction is executed and completed (filling the string with null elements) and after the other is executed and completed (setting the length of the string to 0). Inside the FC is necessary to put a delay (or make 2 execution cycles) where on the first cycle the string if fill with null characters and on the second one is set to 0 length. For me the problem remain the same if the string is defined with a fixed number of characters or it is defined like a pointer (254 + 2 byte occupied). At the moment I didn't find any other solution different to this: 1) create an FC to fill the string with null characters (or making a S_MOVE of a string with all null elements) 2) create an FC to set the length of the string to 0 (or making a S_MOVE of '' So if I need to copy one string ("input string") to another ("output string") and reset the first one (like making a "tracking" of a code I am "forced" to do this: 1) fill the "output string" with null characters 2) copy the "input string" to "output string" (characters and length are correctly updated) 3) fill the "input string" with null characters 4) set the length of the "input string" to 0 For me this one isn't an "compact" solution to make a copy and empty a string that works in any case. Has anyone already found a more efficient solution than mine? If so please share it. Thanks. Franco ------------------------------------------------------------------------------------------ |
Last edited by: Moderator_Lan at: 04/24/2025 08:14:35New subject after splitting |
|
Follow us on