Options

Return an array index.

MauddibMauddib Member Posts: 269
I have just begun in Navision programming and want to try and acheive something. I have two arrays with dimensions from [1][1] to [3][25].

One is text one is decimal. The text one I prepopulate from one table.

What I need to do is be able to return the index of a string in the text array and add in a number to the same index position on the decimal array. So if my table returns the values:

GUM 13.13

I can find that myarray has 'GUM' in position [2][12] and so I can add 13.13 to myOtherArray[2][12].

How is this done?

GMcB

Comments

  • Options
    Marije_BrummelMarije_Brummel Member, Moderators Design Patterns Posts: 4,262
    Hi,

    I am not saying your solution is wrong, but is it not easier to create a temporary table?

    You can have the 2 integers as primary key.

    You can easily filter in the table and find you 'GUM' value.

    And a temp. table does not have to be in your license :D so you can create as much as you want.

    Hope this helps.
  • Options
    MauddibMauddib Member Posts: 269
    I would if i knew how :-p But I dont. Never worked with temp tables.
  • Options
    Marije_BrummelMarije_Brummel Member, Moderators Design Patterns Posts: 4,262
    Step by Step:

    1. Create the desired table in the object designer
    2. Define the table as variable in the globals or locals (whatever is desired)
    3. Select properties on the variable en mark the temporary as yes.
    4. Insert modify and delete as much as you want. The table exists only runtime.
    5. If you leave the code, the object is destroyed automaticaly

    Succes.
  • Options
    MauddibMauddib Member Posts: 269
    Oh ok got ya, that I know how to do. I presumed you meant there was a way of creating a table at runtime which is only in memory.
  • Options
    Marije_BrummelMarije_Brummel Member, Moderators Design Patterns Posts: 4,262
    Ok. I hope it helped anyway.

    Otherwise you can create a for/do loop and compare your array
    for i := 1 to 3 do
      for j := 1 to 25 do
        if value = array1[i][j] then
         array2[i][j] := othervalue
    
    

    Or someting like that.
  • Options
    kinekine Member Posts: 12,562
    And a temp. table does not have to be in your license :D so you can create as much as you want.

    Yes, but how you will create this table, if you do not have it in license??? ;-)
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Options
    MauddibMauddib Member Posts: 269
    thanks a lot for all that. I had hoped a returnindex might be in navision already but this will do. I know its in most of the other languages ive programmed in.
  • Options
    Marije_BrummelMarije_Brummel Member, Moderators Design Patterns Posts: 4,262
    Mauddib wrote:
    I had hoped a returnindex might be in navision already but this will do. I know its in most of the other languages ive programmed in.

    Navision C/AL is designed as customisation tool, not realy as a programming language I think :D
Sign In or Register to comment.