JuggaloZeke Posted September 12, 2004 Share Posted September 12, 2004 (edited) 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) WEndThe 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 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 September 12, 2004 by JuggaloZeke Link to comment Share on other sites More sharing options...
Matt @ MPCS Posted September 12, 2004 Share Posted September 12, 2004 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! *** Matt @ MPCS Link to comment Share on other sites More sharing options...
JuggaloZeke Posted September 12, 2004 Author Share Posted September 12, 2004 I didn't realize you could combine statements into the If's before, but it makes sense. Thanks for the tip! Link to comment Share on other sites More sharing options...
Matt @ MPCS Posted September 12, 2004 Share Posted September 12, 2004 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! *** Matt @ MPCS Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now