Source language: Translate to:

Timer pause

General questions about NeoBook

Moderator: Neosoft Support

Timer pause

Postby martinp » Tue Jun 09, 2015 12:00 pm

Does anyone know if its possible to pause a timer control?

In other words, a button is clicked and it starts the timer......if another button is pressed it pauses the timer.....the timer does not continue until another button is pressed.

Can anyone advise??
martinp
 
Posts: 50
Joined: Fri May 20, 2005 6:18 am

Re: Timer pause

Postby HPW » Tue Jun 09, 2015 12:15 pm

From the doc:
TimerStop

Purpose: Manually deactivate an active Timer object.

Category: Objects

Syntax: TimerStop "object name"

object Name The name of an existing Timer object.

Example: TimerStop "Timer1"



Regards
Hans-Peter
User avatar
HPW
 
Posts: 2510
Joined: Fri Apr 01, 2005 11:24 pm
Location: Germany

Re: Timer pause

Postby stevec » Wed Jun 10, 2015 7:23 am

I tried using multiple timers

I created a pub with the following

1 timer
three text entry
four buttons
1 Subroutine

Start button
TimerStart "Timer1" "1000"

Pause button
TimerStop "Timer1"
.SaveVariables "[Timer1]"
SetVar "[Timer2]" "[Timer1]"

Restart Button
TimerStart "Timer1" "1000"
GoSub "update"

Stop Button
TimerStop "Timer1"

Subroutine: Update
:update
Math "[Timer1]+[Timer2]" "0" "[Timer3]"
GotoLine "2"

CODE*******************************


NBW Publication Source File
(C)1993-2007 NeoSoft Corp.
Title=Untitled NeoBook Publication
Language=US
NeoBookVer=5.54
ScreenColors=16777216
ScreenWidth=640
ScreenHeight=480
BkndColor=0
ScreenAutoSize=Yes
LinkColor=16711680
WindowStyle=0
WindowOrder=0
WindowPos=0
WindowProps=31
BiDiMode=0
UseUpdateTimer=Yes
ReturnTime=60
SubroutineAction=:update¶Math "[Timer1]+[Timer2]" "0" "[Timer3]"¶GotoLine "2"
ShapeTransColor=536870912
CompileType=0
MediaType=0
FilesIncluded=1
FontsIncluded=2
CopyExternalFiles=No
SetupMedia=3
SetupInstDir=C:\MyProgram
SetupTitle=Setup
SetupColors=16711680|0|65535
Variables=[Timer1]¶[Timer2]¶[Timer3]¶
VersionMajor=1
VersionMinor=0
VersionRelease=0
VersionBuild=0
CustomFontName=Arial
CustomFontSize=9
CustomFontStyle=0
CustomCharset=1
CacheSize=30
ExtractOp=132
L_OK=OK
L_CANCEL=Cancel
L_YES=Yes
L_NO=No
L_CLOSE=Close
L_ERRORTITLE=Error
L_FINDTITLE=Find
L_FINDPROMPT=Find &What
L_FINDFIRST=&Find First
L_FINDNEXT=Find &Next
L_FINDERROR=Search text not found.
L_PWORDTITLE=Password required
L_PWORDMSG=Before continuing, you must first|enter the correct password.
L_PWORDPROMPT=&Password:
L_PWORDERROR=That's not the right password!
L_MEDIAERROR=In order to play this type of file you must install|the appropriate multimedia hardware and/or|software.
L_INTERNETERROR=Unable to locate Internet Browser software.
L_ABORTFUNCTION=Do you want to cancel this function?
L_EXTRACTERROR=This file could not be extracted and cannot be played.
L_INSTDIRPROMPT=Please enter the drive and directory where you would like this program to be installed. To accept the default drive and directory, simply press Enter.
L_INSTFOLDERPROMPT=Do you wish to create a program folder?
L_INSTRUNPROMPT=Do you want to run
L_INSTDISKPROMPT=Please insert disk #
L_INSTDISKERROR=That's not the correct disk, try again.
L_INSTGENERROR=The installation has terminated.
L_INSTEXITPROMPT=Do you really want to cancel the installation?
L_INSTWINTITLE=Setup
L_INSTPROGTITLE=Extracting Files...
L_SENDEMAIL=Sending Mail...
L_MAILSERVER=Please enter the name of your outgoing email server:
L_COPY=Copy to Clipboard
L_SELECTALL=Select All
L_DONWLOADFILE=Downloading: %s
L_PLEASEWAIT=Please wait...
TrayMenuBegin
MenuName=TrayOpen
MenuText=Open
MenuState=3
MenuKey=0
MenuAction=SetVar "[WindowState]" "Normal"
MenuName=TrayExit
MenuText=Exit
MenuState=3
MenuKey=0
MenuAction=Exit "" ""
MenuEnd
MasterPage
NewPage=New Page
PageStyle=0
PageColor=16777215
PageGradient1=16711680
PageGradient2=255
PageGradientDir=1
WallpaperStyle=0
ObjectType=15
Name=Timer1
X=61
Y=158
W=32
H=32
Anchor=0
AutoStart=No
Interval=1000
VarName=[Timer1]
ObjectType=3
Name=PushButton1
X=53
Y=212
W=97
H=41
Anchor=0
Text=Start
Align=2
ImageStyle=0
ObjAction=TimerStart "Timer1" "1000"
LineColor=0
LineWidth=1
LineStyle=0
FillColor=12632256
FillPattern=0
Font=Arial
FontSize=10
FontStyle=0
FontCharset=1
TextColor=0
TabOrder=6
ObjectType=9
Name=TextEntry1
X=131
Y=143
W=66
H=47
Anchor=0
VarName=[Timer1]
EditNumber=Yes
EditLen=0
LineColor=0
LineWidth=1
LineStyle=0
FillColor=12632256
FillPattern=0
Font=Arial
FontSize=10
FontStyle=0
FontCharset=1
TextColor=0
TabOrder=5
ObjectType=3
Name=PushButton2
X=161
Y=212
W=97
H=41
Anchor=0
Text=Pause
Align=2
ImageStyle=0
ObjAction=TimerStop "Timer1"¶.SaveVariables "[Timer1]"¶SetVar "[Timer2]" "[Timer1]"
LineColor=0
LineWidth=1
LineStyle=0
FillColor=12632256
FillPattern=0
Font=Arial
FontSize=10
FontStyle=0
FontCharset=1
TextColor=0
TabOrder=4
ObjectType=3
Name=PushButton3
X=272
Y=209
W=97
H=43
Anchor=0
Text=ReStart
Align=2
ImageStyle=0
ObjAction=TimerStart "Timer1" "1000"¶GoSub "update"
LineColor=0
LineWidth=1
LineStyle=0
FillColor=12632256
FillPattern=0
Font=Arial
FontSize=10
FontStyle=0
FontCharset=1
TextColor=0
TabOrder=3
ObjectType=9
Name=TextEntry2
X=213
Y=143
W=65
H=47
Anchor=0
VarName=[Timer1]
EditNumber=Yes
EditLen=0
LineColor=0
LineWidth=1
LineStyle=0
FillColor=12632256
FillPattern=0
Font=Arial
FontSize=10
FontStyle=0
FontCharset=1
TextColor=0
TabOrder=8
ObjectType=9
Name=TextEntry3
X=296
Y=143
W=60
H=47
Anchor=0
VarName=[Timer3]
EditNumber=Yes
EditLen=0
LineColor=0
LineWidth=1
LineStyle=0
FillColor=12632256
FillPattern=0
Font=Arial
FontSize=10
FontStyle=0
FontCharset=1
TextColor=0
TabOrder=7
ObjectType=3
Name=PushButton4
X=382
Y=209
W=97
H=43
Anchor=0
Text=Stop
Align=2
ImageStyle=0
ObjAction=TimerStop "Timer1"
LineColor=0
LineWidth=1
LineStyle=0
FillColor=12632256
FillPattern=0
Font=Arial
FontSize=10
FontStyle=0
FontCharset=1
TextColor=0
TabOrder=2
Steve Christensen
stevec
 
Posts: 223
Joined: Fri Apr 15, 2005 7:33 am
Location: Boise, Idaho

Re: Timer pause

Postby Gaev » Wed Jun 10, 2015 9:13 am

martinp:

Does anyone know if its possible to pause a timer control?

In other words, a button is clicked and it starts the timer......if another button is pressed it pauses the timer.....the timer does not continue until another button is pressed.

Not sure what your definition of "pause the timer control is" ... but assuming that you want the Timer to "count up some number" at every TimerInterval ...

1) Setup the initial value of this counter ...
Code: Select all
SetVar "[TimerCounter]" "0"


2) Setup the interval for the Timer ...
Code: Select all
SetVar "[myTimerInterval]" "1000"


3) Setup the initial value of the Timer Status ...
Code: Select all
Setvar "[TimerStatus]" "Pause"


4) Sart the Timer ...
Code: Select all
TimerStart "Timer1" "[myTimerInterval]"


5) In the TimerInterval code section for the timer object ...
Code: Select all
If "[TimerStatus]" "=" "Pause"
   Return
Else
   SetVar "[TimerCounter]" "1 + [TimerCounter]"
   Return
EndIf


6) For your first Button ...
Code: Select all
SetVar "[TimerStatus]" "Play"


7) For your second Button ...
Code: Select all
SetVar "[TimerStatus]" "Pause"


8 ) Display the value of [TimerCounter] in a text widget.

9) And you will need a button that does ...
Code: Select all
TimerStop "Timer1"
User avatar
Gaev
 
Posts: 3716
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada


Return to General NeoBook Discussions

Who is online

Users browsing this forum: No registered users and 2 guests