0

What's the for loop syntax?

Is it?

for <index> in range( <from>, <to> ) do

    <expression>;

    ....

end;

 

or does it return a value or set of values?

 

let <variable> := for <index> in range( <from>, <to> ) do

    <expression>;

    ....

    <result>|void

end;

 

Can you provide some examples please?

8 replies

null
    • Birger_H
    • 6 yrs ago
    • Reported - view

    it is:

    –––
    for i from 1 to 100 do
    ...
    end
    –––

    See here: https://ninoxdb.de/en/whatsnew

    Birger

    • Fulvio
    • 6 yrs ago
    • Reported - view

    Would you mind providing a worked example of this - I think this is what I need but it isn't working for me. 

    In my case I have a table entitled 'Administrative Episodes' which links to a table called Quotes, which in turn are composed of a collection of Quote Items. It's often necessary to produce a series of almost identical quotes (in terms of quote items) differing only in terms of the institution at which they are based. To do this is irritating at the moment - I have to create a new Quote, recall the same quote items as for the quote before, and change the institution, then repeat this for as many institutions as I need to quote for. What I would like is for the quote items from the previous quote to be passed onto the next one. 

    I am setting this up by creating triggers under 'quote items' which populates a hidden table at the top level, Admin Episodes, whenever a new item is added. This then auto-populates the quote items for subsequent Quotes. However it only works for the first or last item because this is all I am able to specify, unless I use the "for" function. I think the "for" function should allow the formula to loop through each item up at the Admin level and copy it. However I cannot get the syntax to work. Please could you explain this in more detail?

     

    Thanks, Fulvio

    • Paul
    • 6 yrs ago
    • Reported - view

    let s := ">>";
    for i from 1 to 10 do
    I still don't understand what's happening. If I enter:

    let s := ">>";
    for i from 1 to 10 do
        let s := s + "*";
    end;
    alert(s)

    it gets translated to:

    let s := ">>";
    for i from 1 to 10 do
        let s := s + "*";
        void
    end;
    alert(s)

    Why the void statement?

    The ouput should be ">>**********"

    It's actually ">>"

    That is the loop has no effect? Is the variable s local to the loop? What's going on?

    • Leonid_Semik
    • 6 yrs ago
    • Reported - view

    Hi Paul,

    as a code in a function field f(x):

    ---

    var s := ">>";
    for i from 1 to 10 do
    s := s + "*"
    end;
    s

    ----

     

    Leo

    • Paul
    • 5 yrs ago
    • Reported - view

    My problem was that the variable s defined within the loop via the let statement is local to the loop. So the alert statement is displaying the (different) value of s defined before the loop i.e. ">>"

    The fix is to write

        s:=s+"*"

    NOT

        let s:=s+"*"

    • Sean
    • 5 yrs ago
    • Reported - view

    Interesting and that appears to be correct. I thought you couldn’t declare a variable repeatedly in a loop (meaning define not assign), but it appears it is an issue of scope. Thanks for pointing that out!

    • Karen_Estrada
    • 5 yrs ago
    • Reported - view

    @Birger Hi, I thought you'd like to see this/these:

    - when I opened the link you posted at the beginning of this thread, "What's New....", the page doesn't appear as it should, however as you scroll down the page ... it does correct itself (header/nav/wrapper). 

    Here is a a link to the screenshot, which I'll keep there for a few days: https://www.dropbox.com/s/a392m5ob4fb1520/NinoxWebPg_3Jun19.png?dl=0 

    Also, back in April I had sent a screenshot of an issue re: (system) icons and inability to view the first row of them (Ninox Cloud only/Mac OS; Chrome). The issue doesn't exist in Safari Browser nor when using either iOS version (Ninox web/Cloud & iOS app).

    I had communicated this via email (did receive prompt responses), sent in additional screenshots, etc. but as of now, the issue still persists. Screenshot Link: https://www.dropbox.com/s/ryws893dpemnp4d/NinoxCloud_Estrada.png?dl=0 

    **Something new to add since then, - just the other day I was using Ninox Cloud (Mac) in 'split screen', and you could view the top row of icons!), when I exited split-screen, it went back to 'not visible'. 

    (I'm sorry, I know this thread is partially 'off-topic' but I wanted to bring this to your attention as well ... and I'm running out the door to get to work). Of course, please feel free to take down this post once you've viewed it :-) and contact me via email if you need further info! 

    Karen

    • Birger_H
    • 5 yrs ago
    • Reported - view

    Thanks :-)

    Birger

Content aside

  • 5 yrs agoLast active
  • 8Replies
  • 5920Views