Declare a Multidimensional Array

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
Shadow3641
Junior Coder
Posts: 26
Joined: Thu Nov 17, 2016 2:45 pm

Declare a Multidimensional Array

Post by Shadow3641 » Tue Mar 28, 2017 1:16 pm

Sorry for a noob question but i can't find this anywhere. I know you can create a multidimensional array by importing something from an excel sheet but is there a way of declaring one in the program.

Code: Select all

ArrayDim>List,13_13
Let>List_1_1=%a%
Let>List_1_2=%shortText%
Let>List_1_3=%quantity%
Let>List_1_4=%unit%
Let>List_2_1=%b%
Let>List_2_2=%shortText1%
Let>List_2_3=%quantity1%
Let>List_2_4=%unit1%
Aso is there an easy way of assigning points other then having multiple lines if "Let>"?

zabros2020
Pro Scripter
Posts: 70
Joined: Sun May 03, 2009 11:49 pm
Location: AU

Re: Declare a Multidimensional Array

Post by zabros2020 » Tue Mar 28, 2017 2:01 pm

Hi, You could do something like this:

Code: Select all


'define array size
let>cols=4
Let>rows=2
Let>r=0
'assingn each array element
Repeat>r
  Add>r,1
  Let>c=0
  Repeat>c
    Add>c,1
    Let>List_%r%_%c%={""}
  Until>c=cols
Until>r=rows

'assign values
Let>List_1_1=%a%
Let>List_1_2=%shortText%
Let>List_1_3=%quantity%
Let>List_1_4=%unit%
Let>List_2_1=%b%
Let>List_2_2=%shortText1%
Let>List_2_3=%quantity1%
Let>List_2_4=%unit1%

'get array values
Let>tmp=
Let>r=0
Repeat>r
  Add>r,1
  Let>c=0
  Repeat>c
    Add>c,1
    Concat>%tmp%,List_%r%_%c%
    ConCat>%tmp%,%CRLF%
  Until>c=cols
Until>r=rows

MessageModal>%tmp%
Loving MS's Capabilities!!!

Shadow3641
Junior Coder
Posts: 26
Joined: Thu Nov 17, 2016 2:45 pm

Re: Declare a Multidimensional Array

Post by Shadow3641 » Tue Mar 28, 2017 8:56 pm

Its a lot of code to write out but it works like a charm thanks for the help

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts