0

Questions about loop code...

let aa := this;
let mois := ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
let sommes := [];
for i from 1 to 12 do
    let somme := sum((select inventory)[format(time, "MM") = i and format(time, "YY") = format(aa.deta, "YY")].Code);
    sommes := array(sommes, sommes)
end;
let listItems := "";
for i from 0 to 12 do
    listItems := listItems +
        "
        <li class='list-group-item d-flex justify-content-between align-items-start'>
            <div class='ms-2 me-auto fw-bold'>" +
        item(mois, i) +
        "</div>
            <span class='badge bg-primary rounded-pill'>" +
        item(sommes, i) +
        " </span>
        </li>"
end;
html("<body>
" +
listItems +
"
  </body>")

Hello everyone, I need to match the time with the total of the codes for the month. It should be the problem with the sixth line of code. Please help, thank you.

2 replies

null
    • Alain_Fontaine
    • 5 mths ago
    • Reported - view

    Maybe a good time to use the fact that "for" loops can automagically build arrays:

     let sommes := for i from 1 to 12 do
            sum((select inventory)[format(time, "MM") = i and format(time, "YY") = format(aa.deta, "YY")].Code)
        end;
     

      • gold_cat
      • 5 mths ago
      • Reported - view

       Thank you for Alain's help! The program ran successfully. I have an additional question: in this example, is it possible to display rows where code > 0 in bold and rows where code < 0 in normal font? Can this be achieved in HTML or CSS?

Content aside

  • Status Answered
  • 5 mths agoLast active
  • 2Replies
  • 34Views
  • 2 Following