0

use of for fonction

Hello ninox!

I struggle with the for function (I think this is the one I need but maybe it could be where...)

Here is my script:

(sum('PV coque PRO à date') + sum(Options.'PV Option t')) * 'Quantité'

I would like to add a condition on 'PV Option t' something like:

(sum('PV coque PRO à date') + sum(Options.'PV Option t' where /for Options.Base= true)) * 'Quantité'

Any Idea about the way to write this script?

Thanks a lot!

4 replies

null
    • John_Halls
    • 3 days ago
    • Reported - view

    Hi

    for is used to loop through an array

    for a in select table do
       do something here using a...
    end
    

    where is used to scope the array returned with a select command

    for a in select table where condition is true do
       do something here using a...
    end
    

    What you need in your code is square brackets [], which takes a subset of an array, so your code would look something like

    (sum('PV coque PRO à date') + sum(Options[Options.Base].'PV Option t')) * 'Quantité'
    

    You don't need the = true bit

    Hope that helps

    John

      • frsalabert.1
      • 2 days ago
      • Reported - view

       Yes it helps! working fine! Many thanks!

    • John_Halls
    • 2 days ago
    • Reported - view

    So pleased. All the best.

    • Fred
    • 2 days ago
    • Reported - view

      if you are satisfied with John's help, please mark the post answered. thanks.