PLUS+1 User Forum

PLUS+1 Tools => PLUS+1 GUIDE => Topic started by: LBee11 on February 20, 2017, 01:03:02 PM

Title: Setting Long Arrays
Post by: LBee11 on February 20, 2017, 01:03:02 PM
Hi All,

I've been messing about with Arrays more and have run into a "less than desirable" issue. It's not a show stopper, but it's ugly and I'm wondering if there's a better way to do it.

I have a POU that looks after an instruction queue. It lets the user load an instruction index number and the POU will store it in a first in/first out fashion using an Array. The Array is 100 elements long. When I come to define this Array using the "Multi-Character" constant component, do I really have to define it like this:

Quote
(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)
Array[100]S16

It works, but it's ugly and defining 100 elements does not seem practical, especially when the manual states you can have 32767 elements in an Array??

Am I missing something here?

Thanks :)
Title: Re: Setting Long Arrays
Post by: acmall on February 20, 2017, 03:34:39 PM
If you define an array with 1 element and then use Copy of Array to copy it to an array with 100 elements it will fill it with zeros.

Title: Re: Setting Long Arrays
Post by: ZanInno on February 20, 2017, 10:31:44 PM
I use an excel sheet for managing and documenting the array default values.  It can be imported into Guide as a text file.
Title: Re: Setting Long Arrays
Post by: LBee11 on February 21, 2017, 08:16:38 AM
Thanks both for the responses, interested in the excel file approach. Is it possible to post a screenshot of how you set the excel sheet up?
Title: Re: Setting Long Arrays
Post by: ZanInno on February 23, 2017, 03:28:51 AM
You can set up the spreadsheet however you want - Use rows and columns to define the values.  When you export it, only export the numbers and use a comma delimited format. 
Title: Re: Setting Long Arrays
Post by: LBee11 on February 23, 2017, 12:46:07 PM
Thank you ZanInno,

I've made a little spreadsheet that spits out a txt file with the Array in it. Works much better than typing them all out![/size]