Skip to content
umangenius-logo
U Man Genius docs
  • Pages
    • Welcome
      • ninext-loupe
        Ninext documentation
        • ninox-logo
          Ninext APP
        • Installation
        • Update history
        • Uninstall
        • Popup ninext
          • Fields and Functions
          • Debug tracer
          • 🚧 Errors
          • Finder
        • 🚧 Edit field
        • Copy, paste, duplicate & delete
        • HTML helping functions
        • Native JS
          • Clipboard sample
        • Badges
        • View field event
        • Button event
      • ninox-logo
        Scripting tips & tricks
        • General Information
        • Var and Let
        • Functions
        • If Then else
        • icon picker
          For and while loops
        • select, where, from, to
        • Order By (or Order)
        • create, delete, and duplicate
        • JSON in Ninox
        • Arrays in Ninox
        • Undocumented functions in Ninox
        • Manipulating Record IDs in Ninox
        • Dynamic Choice & MultiChoice

For and while loops

Last edited 295 days ago by Jacques TUR.
A for loop can be used to execute code and/or return an array of values. The type of the returned array corresponds to the type of the last statement between do and end.

For Loop

Looping Throu

for i from 1 to 10 do
i;
end;

Looping Through an Array:

var myArray := [1, 3, 5, 7];
for i in myArray do
i;
end;

Looping Through Keys and Values of a JSON Object:

var config := {
sep: ",",
qut: """",
lf: "%0D%0A",
numberFormat: "point",
dateFormat: "locale",
header: true,
sepHeader: false,
encoding: "utf8"
};

for key, value in config do
key + " = " + value;
end;
arrow
See how to manipulate JSON variables in Ninox: .
it is possible to do the same with a record, but you need to use to transform a record (nid) into JSON:
var rec := (first(select Customer));

"Transforming a record into a JSON object"
var config := #{:any return rec}#;

for fieldName, value in config do
fieldName + " = " + value;
end;
This approach can be useful for exporting all fields of a table into formats like CSV.

While Loop

about
While loops are simple and do not return any value. They are used solely for performing iterative tasks and cannot be used to build arrays.

Example:

var a := 1;
while a < 10 do
a := a + 1;
end;
Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
CtrlP
) instead.