get all values of field in table for writing in the variable of array

May be somebody knows how to get all values (there are 10) of field in table to writing they in var of array: Int [10]?

Answers

  • ShaiHuludShaiHulud Posts: 95Member
    edited 2020-01-17
    If I understand correctly, then you have a table with a field (let's call it "Value"), and you have 10 records in that table, right? In that case, this code should do it:
    NoOfValues := 0;
    if MyTable.FindSet then begin
      repeat
        NoOfValues += 1;
        MyArray[NoOfValues] := MyTable.Value;
      until MyTable.Next = 0 or NoOfValues = 10;
    end;
    

    Here:
    NoOfValues : Integer;
    MyArray : Integer[10];
    MyTable : Record "My Table";
    Arturas Kulsinskas
    NaviLogic
  • MarharytaMykytenkoMarharytaMykytenko Posts: 26Member
    ShaiHulud wrote: »
    If I understand correctly, then you have a table with a field (let's call it "Value"), and you have 10 records in that table, right? In that case, this code should do it:
    NoOfValues := 0;
    if MyTable.FindSet then begin
      repeat
        NoOfValues += 1;
        MyArray[NoOfValues] := MyTable.Value;
      until MyTable.Next = 0 or NoOfValues = 10;
    end;
    

    Here:
    NoOfValues : Integer;
    MyArray : Integer[10];
    MyTable : Record "My Table";

    Thanks a lot for your answer
    But whether the variable MyTable in relations with field in table?
  • MarharytaMykytenkoMarharytaMykytenko Posts: 26Member
    Oh, thank you
    Code works in right way
    Thank you a lot))))))))))))
Sign In or Register to comment.