# Newbie Trying to teach himself...

## Recommended Posts

```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

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 on other sites

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

##### Share on other sites

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

##### Share on other sites

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

## Create an account

Register a new account

• ### Recently Browsing   0 members

×

• Wiki

• Back

• #### Beta

• Git
• FAQ
• Our Picks
×
• Create New...