Switch case will add ?
@Teodor Could you please tell me what would be the proper syntax for a boolean expression as a condition in my while loop ? Thank you very much !
I tried this but it went into an infinite loop and the script timed out.
The same with an integer seems to work fine though (loop is stopped right away).
Have you tried {{hasMoreHistory !=0}}
@Hyperbytes : Thank you ! Tried your solution but then the loop is never executed - which is strange…
@George : Thank you for your help.
Strange, tried this and it works ok,
Outputs 0 showing loop executed adn terminated
Yes numbers work ok.
True/false don’t.
Now you have me confused Jeoff, your example uses numbers which i replicated
My message contained two scenarios.
One not working with boolean.
And another one working with numbers.
Look it up again
Yes, and the point i make is that the repeater DOES accept boolean expressions, it is actually the set value stage which seems to be the issue, not understanding true/ false
This can be evidenced by this code which works by ensuring the set value stage is actually boolean, the set value seems to evaluate true/false as strings
We will probably rename the new “while” action to be called whileLoop or something similar because the while name was a reserved keyword in php and that is why it was working only in php 7 and giving problems in php 5.6
Hope you don’t mind
So you have to reapply the action with the new name when we update it
Booleans and numbers work fine, but you have to use expressions. So you need to use {{false}}
and {{true}}
as values, when using true
it will become a string. Same goes for numbers, when just typing 10
as value it will become a string, when you then add 1 to it it will become 101
because "10" + 1 = "101"
as it will concat as string and does not return 11
as most would expect.
In could tell that the issue was around values being interpreted as strings, i think that is the first time since starting to use Wappler, what seems a lifetime ago, i have seen officially how to define true and false correctly (rather than a hack using 1-==1 or 1 == 0) so big thanks for that patrick
Good point @Hyperbytes. Which reminds me… I’ve been meaning to make a feature request in relation to this - about having more info displayed in such case. I’ll do it now.
No worries and thank you for the update @George !
As a sidenote, using the keyword “JSON” inside my server connect action broke it.
(The visual editor wouldn’t reload the action.)
I understood later than this keyword is used as a delimiter when parsing the server connect action.
Do you know if there are any other keywords we shouldn’t use ?
Awesome, thank you.
So just to be sure I understand…
It means that numbers have to use the same kind of syntax {{10}} when setting a value ?