Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simple "while"-loop loops forever #22

Open
htgoebel opened this issue Feb 21, 2015 · 2 comments
Open

Simple "while"-loop loops forever #22

htgoebel opened this issue Feb 21, 2015 · 2 comments

Comments

@htgoebel
Copy link

Hi,

thanks for this great tool!

I try implementing a simple "while"-loop like this:

setvar("i", "0");
setvar("num-apks", 10);
if cmp(getvar("i"), "<", getvar("num-apks")) == 1 then
   #gotolabel("my_app__loop1");
   appendvar("text", getvar("i") + "\n");
   setvar("i", cal(getvar("i"), "+", "1"));
   if cmp(getvar("i"), "<", getvar("num-apks")) then
      appendvar("text", "cmp\n");
   endif;
   if cmp(getvar("i"), "<", 5) then
      appendvar("text", "cmp(5)\n");
      goto("my_app__loop1");
   endif;
endif;
# ... display var "text"

If the gotolabel is commented out (as above), both if-statements hit and "text" contains "cmp cmp(5)" as expected. (The goto is ignored because the label is missing, which is okay for me in this case.)

No if I activate the gotolabel, I'd assume the loop to stop after 5 iterations. But the script simply loops forever.

I even look at the source of AROMA installer, but could not easily spot any problem.

Any help?

@htgoebel
Copy link
Author

Here is a simpler and complete example:

fontresload( "0", "ttf/Roboto-Regular.ttf;ttf/DroidSansFallback.ttf;", "12" );
fontresload( "1", "ttf/Roboto-Regular.ttf;ttf/DroidSansFallback.ttf;", "14" );

textbox("Welcome", "You are welcome", "", "");

setvar("i", "0");

gotolabel("my_app__loop1");
if cmp(getvar("i"), "<", "5") then
    textbox("Value of i - first", "", "", getvar("i"));
    setvar("i", cal(getvar("i"), "+", "1"));
    textbox("Value of i - second", "", "", getvar("i"));
    goto("my_app__loop1");
endif;

This shows, that the value if "i" will be reset to zero when looping.

@htgoebel
Copy link
Author

Just for the records: I tried storing the variable value into a file and read it form there in the next loop-iteration. While reading and writing the value works, doing this in a loop does not. Even in this test the value of i got reset to zero.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant