Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: AGSPwnage on Fri 15/10/2010 23:32:58

Title: How to use 'DateTime' functions in GUIs (GUI Labels)
Post by: AGSPwnage on Fri 15/10/2010 23:32:58
How can I use the 'DateTime.Now' function to put a realtime Digital clock in a GUI label? Pls help... ??? ???
Title: Re: How to use 'DateTime' functions in GUIs (GUI Labels)
Post by: Matti on Sat 16/10/2010 00:04:39
Create a GUI label (named Clock here) and put this in the rep-exec:


DateTime *dt = DateTime.Now;
Clock.Text = String.Format("%02d:%02d:%02d", dt.Hour, dt.Minute, dt.Second);


I've never used the daytime but that should work.
Title: Re: How to use 'DateTime' functions in GUIs (GUI Labels)
Post by: AGSPwnage on Sat 16/10/2010 12:39:27
Thanks, I tried to put it in myself but it kept saying "Parse error" and "expected ';'
Title: Re: How to use 'DateTime' functions in GUIs (GUI Labels)
Post by: Matti on Sat 16/10/2010 13:09:02
Is that parser error directed to one of those two lines? I can't see a problem.

Could you show some more of your code? Maybe there's a mistake before or after the lines.
Title: Re: How to use 'DateTime' functions in GUIs (GUI Labels)
Post by: AGSPwnage on Sat 16/10/2010 13:20:09
No, I meant when I tried it on my own, I used;
Clock.Text = "%02d:%02d:%02d", dt.hour etc.
Title: Re: How to use 'DateTime' functions in GUIs (GUI Labels)
Post by: Sslaxx on Sat 16/10/2010 13:54:33
Quote from: AGSPwnage on Sat 16/10/2010 13:20:09
No, I meant when I tried it on my own, I used;
Clock.Text = "%02d:%02d:%02d", dt.hour etc.
Notice the String.format command.
Title: Re: How to use 'DateTime' functions in GUIs (GUI Labels)
Post by: Dualnames on Sat 16/10/2010 15:49:07
Quote from: AGSPwnage on Sat 16/10/2010 13:20:09
No, I meant when I tried it on my own, I used;
Clock.Text = "%02d:%02d:%02d", dt.hour etc.

Yes, you see you didn't copy Matti's line verbatum. Check yours with Matti's you'll spot the difference. ;)
Title: Re: How to use 'DateTime' functions in GUIs (GUI Labels)
Post by: Khris on Sat 16/10/2010 15:53:24
Hey, hahaha, he tried it on his own, and due to leaving out a negligible part of the code, he suddenly got a parsing error, hahaha! :D
Sorry, but this just made my day.

  "To bake the pizza, put it in the oven."
-10 minutes later-
  "Why is my pizza still cold and tastes raw? I tried it on my own and put it in the fridge."
Title: Re: How to use 'DateTime' functions in GUIs (GUI Labels)
Post by: AGSPwnage on Sat 16/10/2010 19:20:34
This Is what I done before I asked the AGSFrorums, I had forgotten about the forums...
Title: Re: How to use 'DateTime' functions in GUIs (GUI Labels)
Post by: Khris on Sat 16/10/2010 20:35:44
Sorry pal, I found it hilarious. Didn't mean to be rude.
Title: Re: How to use 'DateTime' functions in GUIs (GUI Labels)
Post by: AGSPwnage on Sat 16/10/2010 21:00:23
Np
Title: Re: How to use 'DateTime' functions in GUIs (GUI Labels)
Post by: monkey0506 on Sun 17/10/2010 03:33:38
Quote from: AGSPwnage on Sat 16/10/2010 19:20:34
This Is what I done before I asked the AGSFrorums, I had forgotten about the forums...

For some reason this quote just makes me think of Frmomo Baggminz (http://en.wikipedia.org/wiki/Frodo_Baggins).

But enough off-topic harassment for one day. :=
Title: Re: How to use 'DateTime' functions in GUIs (GUI Labels)
Post by: AGSPwnage on Sun 17/10/2010 11:11:55
Lol :D