Normal Topic Time Display (Read 1421 times)
NHUser
Full Member
***
Offline



Posts: 320
Location: Amherst, NH
Joined: Aug 2nd, 2010
Time Display
Mar 29th, 2012 at 3:28pm
Print Post Print Post  
Is there any way to display the current time? 

I know that @Time captures the current time, but I would like to have a clock face or digital display that will continuously display the current time without any intervention required.

Ideally, I would like to display a clock face with moving minute and second hands.
  
Back to top
 
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: Time Display
Reply #1 - Mar 29th, 2012 at 9:01pm
Print Post Print Post  
Its doable. But, I have to ask why do it in Sesame when desktop clocks are pretty much dime-a-dozen?
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
NHUser
Full Member
***
Offline



Posts: 320
Location: Amherst, NH
Joined: Aug 2nd, 2010
Re: Time Display
Reply #2 - Mar 29th, 2012 at 9:42pm
Print Post Print Post  
I'm setting up an application for temporary employees to "punch in" by entering their employee numbers into a Sesame file.  I thought it would be neat to have the time displayed on the screen while in the file.  This is only a "would be nice" kind of thing.  If it's too complicated I'll just let it go.

  
Back to top
 
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: Time Display
Reply #3 - Mar 29th, 2012 at 10:15pm
Print Post Print Post  
If you don't need to draw a analog clock face, you could use RunEntryOnInterval to update a static text with the current time. If you want an actual clock face with moving hands, you would have to use the static drawing functions and a little bit of trig, as well as RunEntryOnInterval.

You may also be able to find a borderless analog clock program. Place it on top of the Sesame form and use a "keep-on-top" style program to hold it in place.

  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: Time Display
Reply #4 - Mar 30th, 2012 at 9:08pm
Print Post Print Post  
Here is the basic code you would need. Put it in the enter event for any element, not otherwise used. Add a static box element to the form and name it "face". The face element will be the drawing element for the code. Then add a button that kicks off the interval code:

Code
Select All
var time_str as string
var s_hour as string
var s_minute as string
var s_second as string
var hour as double
var min as double
var sec as double
var deg as double
var xx as double
var yy as double
var hour_in_minutes

time_str = @ServerTime()
s_hour = @mid(time_str, 1, 2)
s_minute = @mid(time_str, 4, 2)
s_second = @mid(time_str, 7, 2)
hour = @num(s_hour)
min = @num(s_minute)
sec = @num(s_second)

StaticDrawColor(face, 220, 220, 250)
StaticDrawCircle(face, 180, 180, 150)

deg = (6.28 / 60.0) * sec
xx = @cos(deg - 1.57) * 140.0
yy = @sin(deg - 1.57) * 140.0
StaticDrawColor(face, 100, 100, 100)
StaticDrawLine(face, 180, 180, 180 + xx, 180 + yy)

deg = (6.28 / 60.0) * min
xx = @cos(deg - 1.57) * 100.0
yy = @sin(deg - 1.57) * 100.0
StaticDrawColor(face, 50, 50, 50)
StaticDrawLine(face, 180, 180, 180 + xx, 180 + yy)

if(hour > 12)
{
	hour = hour - 12
}
deg = (6.28 / 12.0) * hour
xx = @cos(deg - 1.57) * 60.0
yy = @sin(deg - 1.57) * 60.0
StaticDrawColor(face, 0, 0, 0)
StaticDrawLine(face, 180, 180, 180 + xx, 180 + yy)

ForceRedraw()

RunEntryOnInterval(Hide, 1000.0)
 



There is a lot you could do to pretty this up: add numbers, make the hands different thicknesses, more color. Right now, it ticks - not sweeps, so the hour hand is always on the current hour, the minute is the current minute, etc.

The .dsr and .ddt for this example are attached in the clock.zip file attached to this post.
  

clock.zip ( 2 KB | 42 Downloads )

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
tcgeo
Full Member
***
Offline



Posts: 278
Location: Traverse City, Michigan
Joined: May 13th, 2008
Re: Time Display
Reply #5 - Mar 30th, 2012 at 9:21pm
Print Post Print Post  
Mark,

I just have to say, THAT'S COOL!

Have a great weekend,

Brandon
  
Back to top
IP Logged
 
Steve_in_Texas
Senior Member
*****
Offline


No personal text

Posts: 893
Location: San Antonio
Joined: Feb 21st, 2004
Re: Time Display
Reply #6 - Mar 31st, 2012 at 5:50am
Print Post Print Post  
That is BRILLIANT!!
  
Back to top
IP Logged
 
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: Time Display
Reply #7 - Mar 31st, 2012 at 6:35am
Print Post Print Post  
Excellent!! Sometimes you wonder if sesame can make and bring a cup of coffee for you!!  It can potentially do anything.

One word of warning!! With RunEntryOnInterval ( ) command Escape key stops working in the current version. Mark had detected the problem and corrected it to be implemented in the upcoming version. Mark, am I right?
  
Back to top
 
IP Logged
 
BOBSCOTT
Senior Member
Members
*****
Offline


That Darn Computer #$X#
{curse words}

Posts: 1195
Joined: Nov 22nd, 2002
Re: Time Display
Reply #8 - Apr 1st, 2012 at 6:37pm
Print Post Print Post  

Examples like this and code snipits are always great. Thanks
  

Team – Together Everyone Achieves More
Back to top
 
IP Logged