While / Do while (infinite) loops

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 ! :slight_smile:

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}}

The syntax seems all fine to me. @patrick will investigate why it don’t work with booleans

@Hyperbytes : Thank you ! Tried your solution but then the loop is never executed - which is strange…

@George : Thank you for your help. :slight_smile:

Strange, tried this and it works ok,

image

Outputs 0 showing loop executed adn terminated

image

Yes numbers work ok.
True/false don’t.

Now you have me confused Jeoff, your example uses numbers which i replicated

image

My message contained two scenarios.
One not working with boolean.

And another one working with numbers.
Look it up again :wink:

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

image

1 Like

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 :slight_smile:

So you have to reapply the action with the new name when we update it

1 Like

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.

2 Likes

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 ! :slight_smile:

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. :slight_smile:

So just to be sure I understand…
It means that numbers have to use the same kind of syntax {{10}} when setting a value ? :slight_smile:

Hello @George Will you add the switch case feature or is it in your roadmap ?

@George
Will the switch case feature be added? are there any news

1 Like

@s.alpaslan that’s currently not in the top-priority list.

Thank you for the feedback @Teodor !