0

How to "scan" a table?

If I want to loop through all records in a table, how do I do that? I don't see a way to create an independent script I can call. So, even within a button, it's not clear how to scan a table to visit each row.
Thx

2replies Oldest first
  • Oldest first
  • Newest first
  • Active threads
  • Popular
    • Fred
    • Fred
    • 1 mth ago
    • Reported - view

    You would use the for loop command.

    for loop1 in select Table1 do
        loop1.(field1 := 100);
        let x := first((select Table2)[field2 := loop1.field2]);
        loop1.(
                field3 := x.field3
                field4 := x.field4
               )
    end
    

    So the first line sets a variable for each record in the loop. Then the "in" tells Ninox where to loops. This can be a select or an array.

    Line 2 is an example of a simple action. Where you would set field1 in all records in Table1 equal to 100.

    Line 3 - 7 shows a more complicated action. First we find the first record in Table2 where the field2 matches field2 in the record of the current loop. Then we set field3 and field4 of the record in the current loop to the value in the loop to the value in x.

    Like 1
      • Mike
      • ninox.1
      • 1 mth ago
      • Reported - view

      Fred You're amazing Fred! Thanks!!!!

      Like
Like Follow
  • 1 mth agoLast active
  • 2Replies
  • 34Views
  • 2 Following