Author Topic: Setting Long Arrays  (Read 9527 times)

Offline LBee11

  • PLUS+1 Developer
  • ***
  • Posts: 26
  • Karma: +1/-0
Setting Long Arrays
« 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 :)

Offline acmall

  • PLUS+1 Guru
  • *****
  • Posts: 201
  • Karma: +37/-1
Re: Setting Long Arrays
« Reply #1 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.


Offline ZanInno

  • PLUS+1 Developer
  • ***
  • Posts: 17
  • Karma: +3/-0
Re: Setting Long Arrays
« Reply #2 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.

Offline LBee11

  • PLUS+1 Developer
  • ***
  • Posts: 26
  • Karma: +1/-0
Re: Setting Long Arrays
« Reply #3 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?

Offline ZanInno

  • PLUS+1 Developer
  • ***
  • Posts: 17
  • Karma: +3/-0
Re: Setting Long Arrays
« Reply #4 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. 

Offline LBee11

  • PLUS+1 Developer
  • ***
  • Posts: 26
  • Karma: +1/-0
Re: Setting Long Arrays
« Reply #5 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]