Jump to content
Sign in to follow this  
Vadersapien

Problem with "If <expression> And <expression> Then" statement

Recommended Posts

Vadersapien

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

Share this post


Link to post
Share on other sites
Mison

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 by Mison

Hi ;)

Share this post


Link to post
Share on other sites
Vadersapien

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.

Share this post


Link to post
Share on other sites
Mison

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 ;)

Share this post


Link to post
Share on other sites
Vadersapien

No it's doing the correct thing if it equals 12...

I'm trying to convert normal time to military time...

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

Share this post


Link to post
Share on other sites
Vadersapien

A simple < instead of an =...why didn't I think of that! :)

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

Share this post


Link to post
Share on other sites
Vadersapien

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.

Share this post


Link to post
Share on other sites
Richard Robertson

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.

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.