Newbie - Question on Arrays

JamieBrown
JamieBrown Member Posts: 107
Hi,

I'll try and explain this as simply as possible.

I've created a sales report that uses the following array:

StartDates[1] := TODAY;
StartDates[2] := CALCDATE('-CW',TODAY);
StartDates[3] := CALCDATE('-CM',TODAY);
FOR Counter := 1 TO 3 DO BEGIN
Store.SETRANGE("Date Filter",StartDates[Counter],TODAY);

and call them via: NetBrandValue[1] etc (as you know)

(As you can see, I use it to display real-time Day, Week and Month sales)

This works fine for a single branch i.e.
Store.SETRANGE("No.",StoreSystemManagement.CurrentStore);

However, I would like to be able to display these figures on a report for all branches (we have 24)

Could I setup another array for these so I would have 2 dimensions on a single variable? Is that possible?

storenumber[a] := 001;
i.e. NetBrandValue[1][a]

I hope this makes sense.

Any suggestions or ideas would be greatly received!

thanks in advance.

Comments

  • David_Cox
    David_Cox Member Posts: 509
    in the array dimensions just put 3;20 for a 3 by 20 array

    MyValue[1,1] := 123;
    MyValue[2,1] := 124;
    MyValue[3,1] := 125;
    ~to
    MyValue[1,20] := 123;
    MyValue[2,20] := 124;
    MyValue[3,20] := 125;
    Analyst Developer with over 17 years Navision, Contract Status - Busy
    Mobile: +44(0)7854 842801
    Email: david.cox@adeptris.com
    Twitter: https://twitter.com/Adeptris
    Website: http://www.adeptris.com
  • JamieBrown
    JamieBrown Member Posts: 107
    David,

    When I try to compile this I get the following Navision error message:

    := cannot be performed on arrays.

    Choose a single array value using an expression such as:

    MyArray[...]


    any ideas?

    thanks
  • Luc_VanDyck
    Luc_VanDyck Member, Moderator, Administrator Posts: 3,633
    Have you changed the Dimensions-property of your array variable?
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
  • JamieBrown
    JamieBrown Member Posts: 107
    yes, as soon as I change the variable dimensions I get that error.
  • DenSter
    DenSter Member Posts: 8,307
    That is because somewhere in your code there is an assignment statement without the index number of your array. Once you change a variable to be an array, you have to specify the index every time you assign a value. Search your code for the variable name and you should find it.
  • JamieBrown
    JamieBrown Member Posts: 107
    Thanks for your help, I'll run through the code.