Hundreds of features to explore
Games made in Construct
Your questions answered
Trusted by schools and universities worldwide
Free education resources to use in the classroom
Students do not need accounts with us
What we believe
We are in this together
World class complete documentation
Official and community submitted guides
Learn and share with other game developers
Upload and play games from the Construct community
Game development stories & opinions
This is the code I wrote.
The purpose of this code is to remove any unnecessary spaces at the end of a text.
But for some reason it keeps creating infinite loops and makes the whole project freeze.
Help needed
Develop games in your browser. Powerful, performant & highly capable.
First of all, there is a much easier way to remove spaces from the beginning or end of the string - use trim(text) expression.
Your loop never ends because you are not updating the TextInput text. You need to do this:
TextInput set text to left(......) Task set text to TextInput.text
And finally, I always add this condition to While loops, to prevent infinite loops:
loopindex<1000
So even if you created an infinite loop by accident, it will stop after 1000 iteration and will not freeze your browser.
Thank you very much for your elaborate explanation! Very helpful :)