October 30, 2025, 10:43:04 AM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


What am i doing wrong?,time$, i just need a running clock @ top, left

Started by hugh, June 01, 2008, 06:39:52 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

hugh


This is in main program after initialing all static/edit controls,etc

setcontrol w1,@static,time$,screenW-screenW+20,screenH-screenH+10,80,20,0,120:  ' this is not in a sub

' then this is in w1handler as case 120


case 120
setcontroltext w1,120,str$(time$)

what am i doing wrong?.
I presumed that would update time$ and keep the clock ticking!

any suggestions please


my aim  is to calculate the hh:mm from start[time$]   to end to [time$]
any help would be gratifying.

regards

Hugh









sapero

Use time$ without str$, not sure but probably the str$ has converted the returned string to string representing the address of time string :)
setcontroltext w1,120,time$()

hugh

thanks, sapero, i will try that about 11am, greenwich mean time, need match sticks to keep my damn eyes open.

It,s 02:35 here.

will reply either way, [if yes, then reply], if no, then still reply]

thanks.
regards, hugh




LarryMc

Hugh,
Sapero properly corrected that line of code but it's still not going to work based upon the code information you have provided.

First question: What is going to trigger case 120 to execute?

2nd Question: What are you really wanting to do?
                    Are you wanting the current time displayed(a clock)
                   Or do you want to display how for you are into the current bingo game time wise?

I'm working on an example to show you how to do it.

Larry
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

LarryMc

Hugh

Example with 3 display times

top one uses your original scheme- it only displays time when the app started - never changes after that

2nd one is just a running clock

3rd is an elasped time display.

When the START button is pressed the display is zero'd out and starts running
When the STOP button is pressed the display stops updating

There ought to be a answer in there somewhere for what you are wanting to do.

Larry

window w1
string ss$
int elasperun,starttime,stoptime,elapsetime

openwindow w1,0,0,600,350,@SIZE|@MINBOX|@MAXBOX,0,"timer demo",&w1handler
control w1,@static,time$,20,10,80,20,0,120 :'displays time application started only
control w1,@static,time$,20,40,80,20,0,140 :'displays time when application is running (clock)
control w1,@static,"00:00:00",20,70,80,20,0,160 :'displays elapsed time from game start

CONTROL w1,@button,"Start Game",200,10,100,20,0,98
CONTROL w1,@button,"Stop Game",200,40,100,20,0,99
'start a 1 second timer to display the windows
'seconds counter
starttimer w1,1000
elasperun=0

run=1


waituntil run=0

stoptimer w1
closewindow w1
end

sub w1handler
select @CLASS
case @IDCLOSEWINDOW
run=0
case @IDCONTROL
SELECT @CONTROLID
CASE 20
setcontroltext w1,120,time$() :'will never be executed because 120 never gets focus
CASE 98
starttime=timer
elasperun=1
elaspetime=0
CASE 99
elasperun=0
endselect
case @IDTIMER
setcontroltext w1,140,time$() :'updates displayed time every sec (a clock)
'this is for elspe timer
if elasperun=1
endtime=timer
elaspetime=endtime-starttime
ss$=right$("00"+ltrim$(str$(elaspetime % 60)),2)
elaspetime=elaspetime/60
ss$=right$("00"+ltrim$(str$(elaspetime % 60)),2)+":"+ss$
elaspetime=elaspetime/24
ss$=right$("00"+ltrim$(str$(elaspetime % 24)),2)+":"+ss$
setcontroltext w1,160,ss$ :'updates displayed time every sec (a timer)
endif

CASE @IDCREATE
CENTERWINDOW w1
endselect
return
endsub
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

hugh

thanks Larry,
Bingo is comming along just fine, i have put a -sub in to circle the called numbers, and erase the circles in the resetboard)
plus other bits and bats, ie running totals,amount to pay per line/house, 20% deduction=profit, write totals to file, etc.
I will upload it when i think it is complete.
Firstly i wanted to display the clock so as when playing the game, as time is important, per bingo session,
secondly to calculate end_time - start_time to work out hours,minutes

OPENWINDOW w1,0,0,sw,sh,@SIZE,0," Computerised Bingo ", &w1handler
control w1,@static,time$,sw-sw+170,sh-sh+5,60,20,0,600  ' i have placed this just below my [openwindow

this is my w1handler with your code added, i know its in the wrong place! i hope

'                     main  w1handler routine
'**********************************************************************
SUB w1handler()
   select @MESSAGE
     
      case @idcreate
             CENTERWINDOW w1
      case @IDCLOSEWINDOW
         CLOSEWINDOW w1


case @idcontrol
         select @controlid
            case 119         :'exit game
               CLOSEWINDOW w1
            case 120         :'next game
               resetboard()

            case 121         :'start     
               if mycount < 90 then  bingonumber()

            case 122
               setcontroltext w1,300,"book"  'playing book of 3 tickets
                calculate()     :             'Calculate Books payout
               'setcontroltext w1,210,str$(1)
               'setcontroltext w1,220,str$(1)

            case 123   
               setcontroltext w1,300,"flyer"  'playing flyer ticket
               setcontroltext w1,210,str$(0)
               setcontroltext w1,220,str$(0)
               calculate()      :             'calculate flyer ticket payout
               'gamenum=1
               'setcontroltext w1,210,str$(gamenum)
               'setcontroltext w1,220,str$(ticket)

            case 128
            
               if gamenum >99 then gamenum=1
                 linecall()
            case 129
            
               if gamenum > 99 then gamenum=1
                housecall()

         select @CLASS ' when i place this at the start of w1handler,the buttons dont work

                case @IDTIMER
             setcontroltext w1,600,time$()      :'updates displayed time every sec (a clock)   
                ' i must have the above in the wrong place, it does not work,going to tinkle with it
            case 600 '  just trying this,
                 setcontroltext w1,600,time$()  ' this dont work either, i know what the problem Is
                                                'i just have to get it in the correct place! hopefuly!!!
         endselect
         endselect
            endselect
   RETURN
ENDSUB

LarryMc

Try this:

SUB w1handler()
select @MESSAGE
case @idcreate
CENTERWINDOW w1
case @IDCLOSEWINDOW
CLOSEWINDOW w1
case @idcontrol
select @controlid
case 119         :'exit game
CLOSEWINDOW w1
case 120         :'next game
resetboard()
case 121         :'start     
if mycount < 90 then  bingonumber()
case 122
setcontroltext w1,300,"book"  'playing book of 3 tickets
calculate()     :             'Calculate Books payout
'setcontroltext w1,210,str$(1)
'setcontroltext w1,220,str$(1)
case 123   
setcontroltext w1,300,"flyer"  'playing flyer ticket
setcontroltext w1,210,str$(0)
setcontroltext w1,220,str$(0)
calculate()      :             'calculate flyer ticket payout
'gamenum=1
'setcontroltext w1,210,str$(gamenum)
'setcontroltext w1,220,str$(ticket)
case 128
if gamenum >99 then gamenum=1
linecall()
case 129
if gamenum > 99 then gamenum=1
housecall()
endselect
case @IDTIMER
setcontroltext w1,600,time$()      :'updates displayed time every sec (a clock)   
endselect
   RETURN
ENDSUB


select @message and select @class are the same thing.

Larry
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

hugh

javascript:void(0);
Wink

Thanks Larrry

It works now, i would have been toying with different combinations, wondering were to place @idtimer.
and to be quite honest, i thought that @idtimer was just for start, stop a timer, maybe i am right, but just didnt know how to use it
there is very little in the help file about it, and i am still going through the help file, and sample source.
hope to have bingo posted this week, im sure you will RIP it to bits, well is that not what posting source,is all about

Thanks again, and i hope the aurora target amount has been reached.

Best regards.

Hugh

LarryMc

Hugh,
I'm not about to RIP your code at all.

BTW, I did want to ask you about one line of code you posted above.

control w1,@static,time$,screenW-screenW+20,screenH-screenH+10,80,20,0,120

Doing the raw math, screenW-screenW will always =0 as will screenH-screenH

control w1,@static,time$,20,10,80,20,0,120
is much cleaner.

Larry
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

hugh

I understand what you mean,Larry, the problem i had was, when i first started to write the program, i found a major problem.
That is, when i tried it on my little, flatscreen tv/cum monitor, which only displays 800x600, and i could only see 3/4 of the screen.
but i will get round to dealing with that though, it is when controls are to the right of the screen that the problem happens.
i know screenW-screenW=0, that was to ensure that, " I KNEW WERE EVERYTHING WAS GOING ON THE SCREEN"
both left,right,top, and bottom
Oh, and by the way, I thought i had set the tv/monitor wrong during setup, as i had just bought it to program in the kitchen.

Well i now have the clock and timer running, i dont want to upload the source yet as i have a few little tweaks to do yet.

thanks for your help, Oh and also to Sapero.

tea time here now, food food glorious food, i could eat a horse, missus says i am, im getting corned beef stew.
speak soon
regards.
Hugh