Vadersapien Posted November 17, 2009 Share Posted November 17, 2009 (edited) I have the following code which is working incorrectly: If $Custom_Time_Value[4] = 'PM' And Not $Custom_Time_Value[1] = '12' Then $Custom_Hour = $Custom_Time_Value[1] + '12' Else $Custom_Hour = $Custom_Time_Value[1] EndIf Even though $Custom_Time_Value[1] does not equal 12...any idea why? Edited November 17, 2009 by Vadersapien Try Pacfox, my Firefox theme.Try Power Eject, my windows gadget that allows you to eject most drives.Using AutoIt 3.3.4.0, Windows 7 Premium, Intel Core 2 Quad CPU @ 2.66ghz, 4gb RAM, Nvidia GeForce 9500GT Graphics Card & Samsung 22" Monitor. Link to comment Share on other sites More sharing options...
Mison Posted November 17, 2009 Share Posted November 17, 2009 (edited) line 1; If $Custom_Time_Value[4] = 'PM' And Not^ Error type:bad logic... Question... what if $Custom_Time_Value[1] equal to 12?? Does it return the desired results?? Edited November 17, 2009 by Mison Hi ;) Link to comment Share on other sites More sharing options...
Vadersapien Posted November 17, 2009 Author Share Posted November 17, 2009 If it's equal to 12 it executes the code under "Else" Try Pacfox, my Firefox theme.Try Power Eject, my windows gadget that allows you to eject most drives.Using AutoIt 3.3.4.0, Windows 7 Premium, Intel Core 2 Quad CPU @ 2.66ghz, 4gb RAM, Nvidia GeForce 9500GT Graphics Card & Samsung 22" Monitor. Link to comment Share on other sites More sharing options...
Mison Posted November 17, 2009 Share Posted November 17, 2009 If it's equal to 12 it executes the code under "Else"While it's supposed to do otherwise? It's in your logical comparison.. remove NOT operator in line 1. Hi ;) Link to comment Share on other sites More sharing options...
Vadersapien Posted November 17, 2009 Author Share Posted November 17, 2009 (edited) No it's doing the correct thing if it equals 12... I'm trying to convert normal time to military time... Edited November 17, 2009 by Vadersapien Try Pacfox, my Firefox theme.Try Power Eject, my windows gadget that allows you to eject most drives.Using AutoIt 3.3.4.0, Windows 7 Premium, Intel Core 2 Quad CPU @ 2.66ghz, 4gb RAM, Nvidia GeForce 9500GT Graphics Card & Samsung 22" Monitor. Link to comment Share on other sites More sharing options...
Mison Posted November 17, 2009 Share Posted November 17, 2009 Then I guessed it right. This is my code for a task similar to yours: $pm = 1 ; it's noon here... If $pm And @HOUR < 12 Then MsgBox(0,"","Military time: "&@HOUR+12) Else MsgBox(0,"","Military time: "&@HOUR) EndIf Hi ;) Link to comment Share on other sites More sharing options...
Vadersapien Posted November 17, 2009 Author Share Posted November 17, 2009 (edited) A simple < instead of an =...why didn't I think of that! Edited November 17, 2009 by Vadersapien Try Pacfox, my Firefox theme.Try Power Eject, my windows gadget that allows you to eject most drives.Using AutoIt 3.3.4.0, Windows 7 Premium, Intel Core 2 Quad CPU @ 2.66ghz, 4gb RAM, Nvidia GeForce 9500GT Graphics Card & Samsung 22" Monitor. Link to comment Share on other sites More sharing options...
Vadersapien Posted November 17, 2009 Author Share Posted November 17, 2009 What about midnight(0:00)? Try Pacfox, my Firefox theme.Try Power Eject, my windows gadget that allows you to eject most drives.Using AutoIt 3.3.4.0, Windows 7 Premium, Intel Core 2 Quad CPU @ 2.66ghz, 4gb RAM, Nvidia GeForce 9500GT Graphics Card & Samsung 22" Monitor. Link to comment Share on other sites More sharing options...
Mison Posted November 17, 2009 Share Posted November 17, 2009 pm [false] And @hour < 12 [true] = false Hi ;) Link to comment Share on other sites More sharing options...
Richard Robertson Posted November 17, 2009 Share Posted November 17, 2009 The reason it wasn't working was because it was performing the Not on the value directly to the right of it. It compared (Not $Custom_Time_Value[1]) = '12'. You should just use <> for not equal. 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