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 Member Posts: 228
    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";
  • MarharytaMykytenkoMarharytaMykytenko Member Posts: 53
    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 Member Posts: 53
    Oh, thank you
    Code works in right way
    Thank you a lot))))))))))))
  • borowskiyborowskiy Member Posts: 1
    Thanks for the information!
Sign In or Register to comment.