Source language: Translate to:

Loop counting backward

General questions about NeoBook

Moderator: Neosoft Support

Loop counting backward

Postby carlos torres » Wed Feb 01, 2017 10:40 am

Dear forum members

TIA

How can I design a loop counting backward?
I'll appreciate anyhelp

regards
carlost
User avatar
carlos torres
 
Posts: 289
Joined: Mon May 02, 2005 8:14 am
Location: Pamplona, Colombia

Re: Loop counting backward

Postby mishem » Wed Feb 01, 2017 11:54 am

Code: Select all
SetVar "[n]" "-10"

Loop "[n]" "0" "[i]"
 SetVar "[n]" "[n]+1"
 SetVar "[List]" "[List][n][#13]"
 AlertBox "" "[List]"
EndLoop
Last edited by mishem on Wed Feb 01, 2017 12:02 pm, edited 1 time in total.
mishem
 
Posts: 575
Joined: Mon Oct 08, 2012 1:51 pm

Re: Loop counting backward

Postby mishem » Wed Feb 01, 2017 12:02 pm

OR

Code: Select all
SetVar "[n]" "10"

Loop "-[n]" "0" "[i]"
  If "[i]" "<" "0"
     StrDel "[i]" "1" "1" "[num]"
    Else
     SetVar "[num]" "[i]"
  EndIf
 SetVar "[List]" "[List][num][#13]"
 AlertBox "" "[List]"
EndLoop
mishem
 
Posts: 575
Joined: Mon Oct 08, 2012 1:51 pm

Re: Loop counting backward

Postby Gaev » Wed Feb 01, 2017 3:27 pm

carlost:

Try this ...
Code: Select all
SetVar "[countFrom]" "10"
SetVar "[countTo]" "0"

Loop "[countFrom]" "[countTo]" "[currentValue]"
     AlertBox "currentValue" "[currentValue]"
EndLoop
User avatar
Gaev
 
Posts: 3728
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Re: Loop counting backward

Postby mishem » Wed Feb 01, 2017 6:31 pm

It turns out everything a lot easier.
One hundred years live - and learn a century. :)
mishem
 
Posts: 575
Joined: Mon Oct 08, 2012 1:51 pm

Re: Loop counting backward

Postby virger » Thu Feb 02, 2017 6:40 am

Code: Select all
Tray #1
setvar "[flg]" "0"
while "[flg]" "=" "0"
    .....
endwhile

Tray #2
setvar "[end]" "1234"
setvar "[n]" "1"
setvar "[flg]" "0"
while "[flg]" "=" "0"
    math '[n]+1" "" "[n]"
    .-.-.-.-.-.-.-.-
    if "[n]" "=" "[end]"
        exitwhile
    endif
.....
endwhile

Try#3
loop "0" "1" "[c]"
    ....
    setvar "[c]" "0"
endloop
COSTA RICA
PURA VIDA
User avatar
virger
 
Posts: 518
Joined: Mon Sep 18, 2006 12:21 pm
Location: Costa Rica, America Central

Re: Loop counting backward

Postby carlos torres » Mon Feb 06, 2017 7:57 am

Thanks to every body for your quick answer.

mishem, gaev & virger

I was so thick-headed to code it.

regards
carlost
User avatar
carlos torres
 
Posts: 289
Joined: Mon May 02, 2005 8:14 am
Location: Pamplona, Colombia

Re: Loop counting backward

Postby StarterPack » Mon Feb 06, 2017 11:19 pm

Insert this code in a Timer (In Timer Settings "Stop timer after one execution" must be uncheck)
In TextEntry ( [Countdown] ) you can put any number, but in this case i add 10

Math "[Countdown]-1" "" "[Countdown]"
If "[Countdown]" "=" "0"
AlertBox "" "Countdown Finished!"
TimerStop "Timer1"
SetVar "[Countdown]" "10"
Else
EndIf

Now add a button (Start Timer), or in page properties to start Timer
TimerStart "Timer1" "1000"

You can "PAUSE" the timer by adding another button (Pause)
TimerStop "Timer1"


or


You can add a Simple Text object and in General you add {Countdown]
and in page properties you can add this code

SetVar "Countdown" "10"
TimerStart "Timer1" "1000"
StarterPack
 
Posts: 115
Joined: Fri Feb 19, 2016 6:55 am


Return to General NeoBook Discussions

Who is online

Users browsing this forum: No registered users and 1 guest

cron