Jump to content
Sign in to follow this  
JuggaloZeke

Newbie Trying to teach himself...

Recommended Posts

JuggaloZeke

While 1

   $hour = @HOUR
   $min = @MIN
   $sec = @SEC
   $ampm = "AM"

   If $hour < 12 Then
      $hour = $hour - 12
   EndIf

   If $hour < 12 Then
      $ampm = "PM"
   EndIf

   ToolTip($hour & ":" & $min & ":" & $sec & " " & $ampm)

   Sleep(1000)

WEnd

The code works, except the [if $hour < 12 Then $hour = $hour-12 EndIF] part and as far as I can tell it is all good. It will, however, work if I write it out as ... If $hour > 12... which makes no sense... unless I am just getting the greater/less than signs confused...

EDIT: After looking closely I realised I did have them mixed up :ph34r:

Well, now that that works I am very happy.

EDIT2: This is actually pretty cool, but I like it splashed better. :(

While 1

   $hour = @HOUR
   $min = @MIN
   $sec = @SEC
   $ampm = "AM"

   If $hour > 12 Then
      $ampm = "PM"
   EndIf

   If $hour > 12 Then
      $hour = $hour - 12
   EndIf

   SplashTextOn ( "Time", $hour & ":" & $min & ":" & $sec & " " & $ampm, 100, 20, -1, -1,  1)

   Sleep(1000)

WEnd
Edited by JuggaloZeke

Share this post


Link to post
Share on other sites
Matt @ MPCS

You may consider putting the 2 If statements together to lessen the number of lines to be interpreted. It would look like this:

While 1

   $hour = @HOUR
   $min = @MIN
   $sec = @SEC
   $ampm = "AM"

   If $hour > 12 Then
      $ampm = "PM"
      $hour = $hour - 12
   EndIf

   SplashTextOn ( "Time", $hour & ":" & $min & ":" & $sec & " " & $ampm, 100, 20, -1, -1,  1)

   Sleep(1000)

WEnd

It is run exactly the same, just with one less conditional. Looks like you are learning really well though, keep up the good work! :ph34r:

*** Matt @ MPCS

Share this post


Link to post
Share on other sites
JuggaloZeke

I didn't realize you could combine statements into the If's before, but it makes sense. Thanks for the tip!

Share this post


Link to post
Share on other sites
Matt @ MPCS

If you wanted to only execute a single command if the conditional is ture then you could have put it on a single line. For example:

If ($var = 1) Then $var = 2

But if you need to execute multiple lines based on the conditional then you would:

If ($var = 1) Then
   $var = 2
   MsgBox(0, "", "The variable contains: " & $var)
EndIf

See? If you need any more help let me know! :ph34r:

*** Matt @ MPCS

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.