Source language: Translate to:

looping command

Questions about using NeoBook's scripting language

Moderator: Neosoft Support

looping command

Postby stevec » Tue Jan 16, 2007 3:00 pm

Is there a way to have an action command loop.

I have the code done for the memory, but would like it to
clear the variable and re-run the action command in a loop
to refresh the data.

Is this possible?

Thanks;
Steve Christensen
Steve Christensen
stevec
 
Posts: 223
Joined: Fri Apr 15, 2005 7:33 am
Location: Boise, Idaho

Postby Sam Cox » Tue Jan 16, 2007 4:30 pm

Hi Steve,

I think you're talking about this code or something similar:
Code: Select all
rtMemoryTotal
SetVar "[MemTot]" "[rtResult2]"
Delay "500"
rtMemoryFree
SetVar "[MemFree]" "[rtResult2][MemFree]"
Math "[MemTot]-[MemFree]" "0" "[AvMem]"

Let's start by rewriting it as a subroutine in BOOK PROPERTIES > ACTIONS > SUBROUTINES:
Code: Select all
:Memory
rtMemoryTotal
SetVar "[MemTot]" "[rtResult2]"
Delay "500"
rtMemoryFree
SetVar "[MemFree]" "[rtResult2][MemFree]"
Math "[MemTot]-[MemFree]" "0" "[AvMem]"
Return

Now you can invoke this subroutine and refresh the [AvMem] value by pressing a button. In the button, put this code:
Code: Select all
Gosub "Memory"

If you want to refresh [AvMem] automatically, you can use a Neobook Timer object. In the Timer Interval action, put this code:
Code: Select all
Gosub "Memory"

If the timer object is Timer1, start it running with this code:
Code: Select all
TimerStart "Timer1" "1000"

where the "1000" is the timer interval in milliseconds—1000 milliseconds equals 1 second.

Hope this helps:
-- Sam
User avatar
Sam Cox
 
Posts: 768
Joined: Fri Apr 01, 2005 7:30 am
Location: Loveland CO USA

Thanks

Postby stevec » Tue Jan 16, 2007 5:43 pm

Thanks, VERY COOL. :lol: :lol: :lol: :P :P :P

Steve Christensen
Steve Christensen
stevec
 
Posts: 223
Joined: Fri Apr 15, 2005 7:33 am
Location: Boise, Idaho

It worked

Postby stevec » Tue Jan 16, 2007 6:26 pm

This code worked.

:Memory
ClearVariables "[MemFree],[MemTot],[Mem5],[Mem6],[Mem7]"
rtMemoryTotal
SetVar "[MemTot]" "[rtResult2]"
rtMemoryFree
SetVar "[MemFree]" "[rtResult2][MemFree]"
Math "[MemTot]/10" "0" "[Mem5]"
Math "[MemFree]/10" "0" "[Mem6]"
Math "[Mem5]-[Mem6]" "0" "[Mem7]"
Delay "2000"
tmCoolProgBarCreate "R1"
tmCoolProgBarType "R1" "1"
tmCoolProgBarLook "R1" "1"
tmCoolProgBarBGColor "R1" "0" "128" "255"
tmCoolProgBarBlockSpaceSize "R1" "5" "1"
tmCoolProgBarShowInactive "R1" "1"
tmCoolProgBarSetValue "R1" "[Mem7]"
tmCoolProgBarMax "R1" "100"
tmCoolProgBarStartcolor "R1" "0" "255" "0"
tmCoolProgBarFinalcolor "R1" "255" "0" "0"
SetVar "[Mem7]" "0"
GotoLine "2"

I was able to have the progress bar refresh!!!!!!! :lol: :lol: :lol:

Many thanks;
Steve Christensen
Steve Christensen
stevec
 
Posts: 223
Joined: Fri Apr 15, 2005 7:33 am
Location: Boise, Idaho


Return to NeoBook Action Commands

Who is online

Users browsing this forum: No registered users and 2 guests