How to use 'DateTime' functions in GUIs (GUI Labels)

Started by AGSPwnage, Fri 15/10/2010 23:32:58

Previous topic - Next topic

AGSPwnage

How can I use the 'DateTime.Now' function to put a realtime Digital clock in a GUI label? Pls help... ??? ???

Matti

Create a GUI label (named Clock here) and put this in the rep-exec:

Code: ags

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.

AGSPwnage

Thanks, I tried to put it in myself but it kept saying "Parse error" and "expected ';'

Matti

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.

AGSPwnage

No, I meant when I tried it on my own, I used;
Clock.Text = "%02d:%02d:%02d", dt.hour etc.

Sslaxx

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.
Stuart "Sslaxx" Moore.

Dualnames

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. ;)
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

Khris

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."

AGSPwnage

#8
This Is what I done before I asked the AGSFrorums, I had forgotten about the forums...

Khris

Sorry pal, I found it hilarious. Didn't mean to be rude.


monkey0506

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.

But enough off-topic harassment for one day. :=


SMF spam blocked by CleanTalk