C-AL problem...

voodoovoodoo Member Posts: 82
edited 2005-01-24 in Navision Attain
How can I get all records from some table, for example:

FOR i:=firstrecord to lastrecord DO BEGIN
price:=price * 80;
END;

This is just an example what I want to do, but I don't know how :(
misha fka voodoo

Comments

  • bostjanlbostjanl Member Posts: 107
    voodoo wrote:
    How can I get all records from some table, for example:

    FOR i:=firstrecord to lastrecord DO BEGIN
    price:=price * 80;
    END;

    This is just an example what I want to do, but I don't know how :(

    recTable.Find('-');
    REPEAT
    recTable.Price := recTable.Price * 80;
    recTable.MODIFY;
    UNTIL recTable.NEXT = 0;
  • bostjanlbostjanl Member Posts: 107
    bostjanl wrote:
    voodoo wrote:
    How can I get all records from some table, for example:

    FOR i:=firstrecord to lastrecord DO BEGIN
    price:=price * 80;
    END;

    This is just an example what I want to do, but I don't know how :(

    recTable.Find('-');
    REPEAT
    recTable.Price := recTable.Price * 80;
    recTable.MODIFY;
    UNTIL recTable.NEXT = 0;

    boolIsMore := recTable.FIND('-')
    WHILE boolIsMore DO BEGIN
    recTable.VALIDATE(Price, recTable.Price *80);
    recTable.MODIFY(TRUE);
    boolIsMore := recTable.NEXT > 0;
    END
  • voodoovoodoo Member Posts: 82
    Thnx

    It was very helpful for me ;)
    misha fka voodoo
  • voodoovoodoo Member Posts: 82
    I have one more question.....
    Is there any DevToolkit or something like that for NAV 3.60.....with intelisense etc.

    download link please.
    misha fka voodoo
  • DenSterDenSter Member Posts: 8,307
    or, a simple version:
    IF recTable.Find('-') THEN BEGIN
      // put pre-loop code here
      REPEAT
        recTable.Price := recTable.Price * 80;
        recTable.MODIFY;
      UNTIL recTable.NEXT = 0;
      // put post-loop code here
    END ELSE BEGIN
      // put code here for when the record variable is empty
    END;
    

    There is no intellisense in Navision. You can use the current developer toolkit for any Navision version. Just export the object in a text file and you can import them into a dev toolkit database.
  • voodoovoodoo Member Posts: 82
    I have a problem with a code that u sent to me.......
    Here is my Code:
    ItemTable is variable (datatype Record, subtype Item) in C/AL Globals
    IF ItemTable.FIND('-') THEN BEGIN 
      // put pre-loop code here 
      X := ItemTable.COUNT;
      REPEAT
        Cena := "Unit Price";
        CenaEUR := "Unit List Price";
        IF CenaEUR = 0 THEN
           EXIT;
           Cena := CenaEUR * 90;
        ItemTable."Unit Price" := Cena;
        ItemTable.MODIFY;
        ItemTable.NEXT;
      UNTIL ItemTable.NEXT = 0; 
      // put post-loop code here 
    END
    

    X variable has 12500 records but in repeat - until statement I have only one iteration(only first record)

    why?
    misha fka voodoo
  • DenSterDenSter Member Posts: 8,307
    voodoo wrote:
    why?
    It's because of your EXIT statement. This exits the current trigger, not the loop. I'd do something like this:
    // filtering these out is much more efficient than looping through the entire table
    ItemTable.SETFILTER("Unit List Price",'<>0'); 
    IF ItemTable.FIND('-') THEN BEGIN 
      // put pre-loop code here 
      X := ItemTable.COUNT;
      REPEAT
        ItemTable."Unit Price" := ItemTable."Unit List Price" * 90;
        ItemTable.MODIFY;
        //ItemTable.NEXT; no need for this, that is done by the UNTIL
      UNTIL ItemTable.NEXT = 0; 
      // put post-loop code here 
    END
    
  • voodoovoodoo Member Posts: 82
    Thnx Daniel,

    I'm a C# programmer, and I'm a newbie in Navision, because my questions are low level ;)
    misha fka voodoo
  • DenSterDenSter Member Posts: 8,307
    No problem, glad I can help :) I'd have very similar questions if I had to start with C#.
Sign In or Register to comment.