Source language: Translate to:

help make count up timer

General questions about NeoBook

Moderator: Neosoft Support

help make count up timer

Postby yanzco » Fri Dec 12, 2014 8:39 am

can anyone help me make a count up timer?

like if enabled.. it count ups until a button pressed to stop and record count time to a variable..

i will be making a page with like 30 count up timers in it..
would it be possible?

i tried to use a flash count up timer.. (00hr.15min.30sec.9) but for some reason.. the flash is lagging / delayed in the counting..
it works okay thou in mozilla.. but in neobook, it lags, and get left behind by my desktop clock..
yanzco
 
Posts: 175
Joined: Sun Jul 20, 2014 4:07 am

Re: help make count up timer

Postby dpayer » Fri Dec 12, 2014 10:11 am

yanzco wrote:can anyone help me make a count up timer?



Create a new pub 640x480

Copy the code below into the clipboard. Paste into your new pub. Run. Does this do what you want?

Code: Select all
{NeoBook 5 Objects}
NeoBookVer=5.80
ObjectType=8
Name=Text1
X=364
Y=48
W=170
H=43
Anchor=0
Font=Arial
FontSize=10
FontStyle=0
FontCharset=1
TextColor=0
Text={\rtf1\ansi\deff0\deftab254{\fonttbl{\f0\fnil\fcharset1 Arial;}}{\pard{\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f0\fs36\cf0 [counter1]}}}
HMargin=0
VMargin=0
LineColor=0
LineWidth=1
LineStyle=0
FillColor=16777215
FillPattern=0
TabOrder=2
ObjectType=3
Name=PushButton1
X=553
Y=50
W=72
H=41
Anchor=0
Text=Stop
Align=2
ImageStyle=0
XPTheme=Yes
ObjAction=TimerStop "Timer1"
LineColor=0
LineWidth=1
LineStyle=0
FillColor=16777215
FillPattern=0
Font=Arial
FontSize=10
FontStyle=0
FontCharset=1
TextColor=0
TabOrder=3
ObjectType=15
Name=Timer1
X=646
Y=47
W=32
H=32
Anchor=0
AutoStart=No
Interval=1000
ObjAction=SetVar "[counter1]" "[counter1]+1"
ObjectType=8
Name=Text2
X=364
Y=108
W=170
H=43
Anchor=0
Font=Arial
FontSize=10
FontStyle=0
FontCharset=1
TextColor=0
Text={\rtf1\ansi\deff0\deftab254{\fonttbl{\f0\fnil\fcharset1 Arial;}}{\pard{\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f0\fs36\cf0 [counter2]}}}
HMargin=0
VMargin=0
LineColor=0
LineWidth=1
LineStyle=0
FillColor=16777215
FillPattern=0
TabOrder=5
ObjectType=3
Name=PushButton2
X=553
Y=110
W=72
H=41
Anchor=0
Text=Stop
Align=2
ImageStyle=0
XPTheme=Yes
ObjAction=TimerStop "Timer2"
LineColor=0
LineWidth=1
LineStyle=0
FillColor=16777215
FillPattern=0
Font=Arial
FontSize=10
FontStyle=0
FontCharset=1
TextColor=0
TabOrder=6
ObjectType=15
Name=Timer2
X=650
Y=109
W=32
H=32
Anchor=0
AutoStart=No
Interval=1000
ObjAction=SetVar "[counter2]" "[counter2]+1"
ObjectType=8
Name=Text3
X=364
Y=168
W=170
H=43
Anchor=0
Font=Arial
FontSize=10
FontStyle=0
FontCharset=1
TextColor=0
Text={\rtf1\ansi\deff0\deftab254{\fonttbl{\f0\fnil\fcharset1 Arial;}}{\pard{\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f0\fs36\cf0 [counter3]}}}
HMargin=0
VMargin=0
LineColor=0
LineWidth=1
LineStyle=0
FillColor=16777215
FillPattern=0
TabOrder=8
ObjectType=3
Name=PushButton3
X=553
Y=170
W=72
H=41
Anchor=0
Text=Stop
Align=2
ImageStyle=0
XPTheme=Yes
ObjAction=TimerStop "Timer3"
LineColor=0
LineWidth=1
LineStyle=0
FillColor=16777215
FillPattern=0
Font=Arial
FontSize=10
FontStyle=0
FontCharset=1
TextColor=0
TabOrder=9
ObjectType=15
Name=Timer3
X=650
Y=169
W=32
H=32
Anchor=0
AutoStart=No
Interval=1000
ObjAction=SetVar "[counter3]" "[counter3]+1"
ObjectType=8
Name=Text4
X=364
Y=235
W=170
H=43
Anchor=0
Font=Arial
FontSize=10
FontStyle=0
FontCharset=1
TextColor=0
Text={\rtf1\ansi\deff0\deftab254{\fonttbl{\f0\fnil\fcharset1 Arial;}}{\pard{\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f0\fs36\cf0 [counter4]}}}
HMargin=0
VMargin=0
LineColor=0
LineWidth=1
LineStyle=0
FillColor=16777215
FillPattern=0
TabOrder=11
ObjectType=3
Name=PushButton4
X=553
Y=237
W=72
H=41
Anchor=0
Text=Stop
Align=2
ImageStyle=0
XPTheme=Yes
ObjAction=TimerStop "Timer4"
LineColor=0
LineWidth=1
LineStyle=0
FillColor=16777215
FillPattern=0
Font=Arial
FontSize=10
FontStyle=0
FontCharset=1
TextColor=0
TabOrder=12
ObjectType=15
Name=Timer4
X=650
Y=236
W=32
H=32
Anchor=0
AutoStart=No
Interval=1000
ObjAction=SetVar "[counter4]" "[counter4]+1"
ObjectType=8
Name=Text5
X=364
Y=299
W=170
H=43
Anchor=0
Font=Arial
FontSize=10
FontStyle=0
FontCharset=1
TextColor=0
Text={\rtf1\ansi\deff0\deftab254{\fonttbl{\f0\fnil\fcharset1 Arial;}}{\pard{\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f0\fs36\cf0 [counter5]}}}
HMargin=0
VMargin=0
LineColor=0
LineWidth=1
LineStyle=0
FillColor=16777215
FillPattern=0
TabOrder=14
ObjectType=3
Name=PushButton5
X=553
Y=301
W=72
H=41
Anchor=0
Text=Stop
Align=2
ImageStyle=0
XPTheme=Yes
ObjAction=TimerStop "Timer5"
LineColor=0
LineWidth=1
LineStyle=0
FillColor=16777215
FillPattern=0
Font=Arial
FontSize=10
FontStyle=0
FontCharset=1
TextColor=0
TabOrder=15
ObjectType=15
Name=Timer5
X=656
Y=300
W=32
H=32
Anchor=0
AutoStart=No
Interval=1000
ObjAction=SetVar "[counter5]" "[counter5]+1"
ObjectType=8
Name=Text6
X=364
Y=355
W=170
H=43
Anchor=0
Font=Arial
FontSize=10
FontStyle=0
FontCharset=1
TextColor=0
Text={\rtf1\ansi\deff0\deftab254{\fonttbl{\f0\fnil\fcharset1 Arial;}}{\pard{\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f0\fs36\cf0 [counter6]}}}
HMargin=0
VMargin=0
LineColor=0
LineWidth=1
LineStyle=0
FillColor=16777215
FillPattern=0
TabOrder=17
ObjectType=3
Name=PushButton6
X=553
Y=357
W=72
H=41
Anchor=0
Text=Stop
Align=2
ImageStyle=0
XPTheme=Yes
ObjAction=TimerStop "Timer6"
LineColor=0
LineWidth=1
LineStyle=0
FillColor=16777215
FillPattern=0
Font=Arial
FontSize=10
FontStyle=0
FontCharset=1
TextColor=0
TabOrder=18
ObjectType=15
Name=Timer6
X=656
Y=356
W=32
H=32
Anchor=0
AutoStart=No
Interval=1000
ObjAction=SetVar "[counter6]" "[counter6]+1"
ObjectType=8
Name=Text7
X=364
Y=414
W=170
H=43
Anchor=0
Font=Arial
FontSize=10
FontStyle=0
FontCharset=1
TextColor=0
Text={\rtf1\ansi\deff0\deftab254{\fonttbl{\f0\fnil\fcharset1 Arial;}}{\pard{\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f0\fs36\cf0 [counter7]}}}
HMargin=0
VMargin=0
LineColor=0
LineWidth=1
LineStyle=0
FillColor=16777215
FillPattern=0
TabOrder=20
ObjectType=3
Name=PushButton7
X=553
Y=416
W=72
H=41
Anchor=0
Text=Stop
Align=2
ImageStyle=0
XPTheme=Yes
ObjAction=TimerStop "Timer7"
LineColor=0
LineWidth=1
LineStyle=0
FillColor=16777215
FillPattern=0
Font=Arial
FontSize=10
FontStyle=0
FontCharset=1
TextColor=0
TabOrder=21
ObjectType=15
Name=Timer7
X=655
Y=415
W=32
H=32
Anchor=0
AutoStart=No
Interval=1000
ObjAction=SetVar "[counter7]" "[counter7]+1"
ObjectType=3
Name=PushButton8
X=39
Y=9
W=266
H=86
Anchor=0
Text=Clear / Restart
Align=2
ImageStyle=0
XPTheme=Yes
ObjAction=Loop "1" "7" "[LOOPCTR]"¶SetVar "[counter[LOOPCTR]]" "0"¶TimerStart "Timer[LOOPCTR]" "1000"¶Endloop
LineColor=0
LineWidth=1
LineStyle=0
FillColor=16777215
FillPattern=0
Font=Arial
FontSize=10
FontStyle=0
FontCharset=1
TextColor=0
TabOrder=23
David Payer
Des Moines, Iowa
USA
User avatar
dpayer
 
Posts: 1380
Joined: Mon Apr 11, 2005 5:55 am
Location: Iowa - USA

Re: help make count up timer

Postby yanzco » Fri Dec 12, 2014 10:21 am

thanks dpayer!

a bit close to what i wanted it to be..
each timer is independent, can be stopped -> set var.. started on a click of a button..

im trying to make it work with javascript.. but im new to javascript, so im having hard time with the / stop / reset timer part..

Code: Select all
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>javacsript count up</title>
<script language="javascript">
var sec = 0;
function pad ( val ) { return val > 9 ? val : "0" + val; }
setInterval( function(){
    document.getElementById("seconds").innerHTML=pad(++sec%60) +" sec";
    document.getElementById("minutes").innerHTML=pad(parseInt(sec/60,10)) +" min";
}, 1000);
 
</script>
</head>

<div id="minutes">0</div>
<div id="seconds">0</div>
yanzco
 
Posts: 175
Joined: Sun Jul 20, 2014 4:07 am

Re: help make count up timer

Postby dpayer » Fri Dec 12, 2014 11:10 am

Oh... I thought you were making a Neobook app.

You need to post your code then.

D
David Payer
Des Moines, Iowa
USA
User avatar
dpayer
 
Posts: 1380
Joined: Mon Apr 11, 2005 5:55 am
Location: Iowa - USA

Re: help make count up timer

Postby yanzco » Fri Dec 12, 2014 11:19 am

i am now..
since i cant get variables in javascript to neobook..
yanzco
 
Posts: 175
Joined: Sun Jul 20, 2014 4:07 am

Re: help make count up timer

Postby dpayer » Fri Dec 12, 2014 11:52 am

yanzco wrote:i am now..
since i cant get variables in JavaScript to neobook..


Check out the NB help file for some useful information on getting/setting variables in JS and VBS from Neobook:

==========================================
nbGetVar

Purpose:
This method returns a string containing the contents of a NeoBook variable.

Syntax:
value = window.external.nbGetVar( variable name )

variable name

The name of the NeoBook variable to retrieve. The variable name should be surrounded by square brackets.

value

The contents of the NeoBook variable in string format.

Example:
The following HTML JScript copies the contents of NeoBook's [FirstName] and [LastName] variables to two Text Boxes called "FirstName" and "LastName":




<script language="JScript">

function GetVars() {

mainform.FirstName.value = window.external.nbGetVar( '[FirstName]' );

mainform.LastName.value = window.external.nbGetVar( '[LastName]' );

}

</script>





nbExecAction

Purpose:
Use this method to execute NeoBook actions.

Syntax:
window.external.nbExecAction( action script )

action script

The NeoBook action to execute. Multiple actions may specified by separating them with a carriage return.

Example:
This example executes NeoBook's AlertBox action:




<script language="JScript">

function DoExec() {

window.external.nbExecAction( 'AlertBox "Hello" "Hello from the Web Browser!"' );

}

</script>





Note: These features require the user's Internet Security/Active Scripting option to be enabled.
David Payer
Des Moines, Iowa
USA
User avatar
dpayer
 
Posts: 1380
Joined: Mon Apr 11, 2005 5:55 am
Location: Iowa - USA


Return to General NeoBook Discussions

Who is online

Users browsing this forum: No registered users and 5 guests