Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Lap timing with Powerbuilder

97 views
Skip to first unread message

geoffwnz

unread,
Sep 22, 2008, 12:28:29 AM9/22/08
to
Maybe I'm going nuts, but I can't seem to figure out how to develop a
lap timer in PB.

Initial idea was to use two time instance variables. One to store the
start time, one to store the lap time.
Get the difference between the two and you have your lap time.
However, I can't see any simple way of comparing the times (down to
1/100th) as PB doesn't seem to cater for that sort of thing.
Requires a mess of splitting it into it's component bits (min, sec,
fraction) and subtracting each one.

The alternative is to set up a timer object and trigger that on a
recurring basis 1/100th of a second and increment a set of variables
for min, sec and fractions.
This tended to do it's own thing and ran slower than real time.

Would be nice if there was a simple-ish way to fire a timer that
counted from 0 and reset each lap.

Ideally for display purposes a static text that has the time running
would be useful too.

Thanks in advance.

Jeremy Lakeman

unread,
Sep 22, 2008, 7:57:42 AM9/22/08
to

time lt_start, lt_end
secondsafter(lt_start, lt_end)*1000 + long(string(lt_end,'fff')) -
long(string(lt_start,'fff'))

Terry Voth [TeamSybase]

unread,
Sep 22, 2008, 7:46:49 AM9/22/08
to
Somehow, I don't think PB's creators imagined a PC being worn around
the neck down by the pool. <g>

You could:

- write your own (this sounds "funnest" to me ... shades of Steve
Jobs' grammarian <g>... but maybe that's just me)

- steal something already written (e.g.
https://pfc.codexchange.sybase.com/source/browse/pfc/pfc10/pfcapsrv/pfc_n_cst_datetime.sru?revision=1.1&view=markup)

- create parallel values from the CPU() function, which can easily be
subtracted, but then you'd have to write something to make it human
readable, which may look something like:

function of_millisecondstotime (long al_Milliseconds) returns string

long ll_Milliseconds, ll_Seconds, ll_Minutes, ll_Hours, ll_Days
string ls_Output

ll_Milliseconds = Mod (al_Milliseconds, 1000)
ll_Seconds = (al_Milliseconds - ll_Milliseconds)/1000
IF ll_Seconds > 0 THEN
ll_Minutes = (ll_Seconds - Mod (ll_Seconds, 60))/60
IF ll_Minutes > 0 THEN
ll_Seconds = Mod (ll_Seconds, 60)
ll_Hours = (ll_Minutes - Mod (ll_Minutes, 60))/60
IF ll_Hours > 0 THEN
ll_Minutes = Mod (ll_Minutes, 60)
ll_Days = (ll_Hours - Mod (ll_Hours, 24)) / 24
ll_Hours = Mod (ll_Hours, 24)
END IF
END IF
END IF

IF ll_Days > 0 THEN ls_Output += String (ll_Days) + " day(s), "
IF (ll_Hours > 0) OR Len (ls_Output) > 0 THEN ls_Output += String
(ll_Hours) + ":"
IF (ll_Minutes > 0) OR Len (ls_Output) > 0 THEN ls_Output += String
(ll_Minutes, "00") + ":"
ls_Output += String (ll_Seconds, "00") + "." + String
(ll_Milliseconds, "000")

RETURN ls_Output


Good luck,

Terry and Sequel the techno-kitten

*********************************
Build your vocabulary while feeding the hungry
http://www.freerice.com
*********************************
Newsgroup User Manual
=====================
TeamSybase <> Sybase employee
Forums = Peer-to-peer
Forums <> Communication with Sybase
IsNull (AnswerTo (Posting)) can return TRUE
Forums.Moderated = TRUE, so behave or be deleted
*********************************

Sequel's Sandbox: http://www.techno-kitten.com
Home of PBL Peeper, a free PowerBuilder Developer's Toolkit.
Version 4.0.4 now available at the Sandbox
PB Futures updated June 25/2008
See the PB Troubleshooting & Migration Guides at the Sandbox
^ ^
o o
=*=

Roland Smith [TeamSybase]

unread,
Sep 22, 2008, 9:08:32 AM9/22/08
to
Download this Ping example from my website.

http://www.topwizprogramming.com/freecode_ping.html

It uses QueryPerformanceCounter Win API function to measure elapsed time
down to 6 decimal places.

"geoffwnz" <geoff....@customs.govt.nz> wrote in message
news:7b792824-9704-42d7...@a19g2000pra.googlegroups.com...

geoffwnz

unread,
Sep 22, 2008, 3:57:14 PM9/22/08
to
Thanks everyone. I'll have a rummage through the above suggestions
and see what I can make the best use of.

FYI, it's for motorsport lap timing, rather than down at the
pool. :-) Although with the state of some of the rugged PDA's these
days, that's not beyond possibility either.

Roland Smith [TeamSybase]

unread,
Sep 22, 2008, 4:38:28 PM9/22/08
to
If you decide to try a PDA, take a look at PocketBuilder. You could have a
SQL Anywhere database local to the device and then when you bring it back to
your office, upload the database transactions.

"geoffwnz" <geoff....@customs.govt.nz> wrote in message

news:72bb3a03-5ead-4365...@g17g2000prg.googlegroups.com...

geoffwnz

unread,
Sep 22, 2008, 5:18:20 PM9/22/08
to
Thanks. Figured that much. Currently looking to have a lap scoring
system on a laptop, so is ok in Powerbuilder.
Managed to get something useful out of your Ping example. I did
discover though, that it only works as expected on a single processor
pc. Multiple cores or processors seem to confuse the output somewhat.
Not a problem currently as the laptop in question is not exactly new,
but does make for interesting results in development on the dual core
pc.

On Sep 23, 8:38 am, "Roland Smith [TeamSybase]"


<rsmith_at_trusthss_dot_com> wrote:
> If you decide to try a PDA, take a look at PocketBuilder. You could have a
> SQL Anywhere database local to the device and then when you bring it back to
> your office, upload the database transactions.
>

> "geoffwnz" <geoff.war...@customs.govt.nz> wrote in message

0 new messages