10-27-2021 04:07 AM
So another question:
I have an array of integers, which is like 50 elements long. I only want to pick out element 9,10 and 25. It could be I in the future would like to pickout 9,10,21,25,34 and some other elements.
So the way I did this is with "Index Array", and then pickout the required elements of the array. Fine enough. However, I need to cast them to a string, where I am then using the "Format into String".
I wanted to make a for loop, which should run as many times there is elements, that I have picked, i.e. three times in this example, and then inside the for loop have one "Format into string", which then takes the first element, convert that into a string and then append that to a new array.
However I was not able to do that. I tried shift registers but it just not quite went good 🙂
So basically, is there a way to do this better with a for loop? Because, the code now is not very scalable and if I e.g. wants like 10 elements, this would be a nightmare to write like above. Therefore a for loop implementation is what I am looking for basically. The basic questions is then:
1) How do I start with an 1-d array, with only 1 element, and then in the next iteration of the for loop, I append the next element into the old 1d array, so that it grows to 2 elements, and so forth. I.e. the string array should look like this:
i = 0 --> string array = [string1]
i = 1 --> string array = [string1, string2]
i = 2 --> string array = [string1, string2, string 3]
...
i = n --> string array = [string1, string2, ... , string-n]
10-27-2021 07:35 AM
Please attach your code, not just a picture. Also, please do save relevant default data in the "Input Registers" control.
10-27-2021 08:50 AM
You can loop the array of elements you want to pick through the for loop so it will check your array and output desired value. Then it'll build the array of string to which you can concatenate date and time as you have shown.
is this what you're looking for?
10-27-2021 08:52 AM
Ajskrim beat me too it...
10-31-2021 04:14 PM
What is the name of the last block with the number "999"?
10-31-2021 05:35 PM
"number to decimal string"
11-01-2021 08:00 AM
@ChristianLiinHansen wrote:1) How do I start with an 1-d array, with only 1 element, and then in the next iteration of the for loop, I append the next element into the old 1d array, so that it grows to 2 elements, and so forth. I.e. the string array should look like this:
i = 0 --> string array = [string1]
i = 1 --> string array = [string1, string2]
i = 2 --> string array = [string1, string2, string 3]...
i = n --> string array = [string1, string2, ... , string-n]
11-01-2021 11:25 AM
Well, you don't really need all these intermediary results, right? Do the following to get the final output directly:
NOTE: You even get a linefeed at the end so each appended string gets a new line in the file. You can use "trim whiltespace" if you don't want that.
11-01-2021 01:34 PM
@altenbach wrote:
Well, you don't really need all these intermediary results, right? Do the following to get the final output directly:
I don't
I don't see much use in it either, but it was explicitly requested in the OP...
11-01-2021 02:41 PM
Yes, I was replying to the OP. 😄