Jump to content
BatMan22

Why doesn't my if statement work?

Recommended Posts

BatMan22

Why doesn't my first if statement below work? The rest work great. Can you not use "&" in a if statement? Is there a work around for that? 

Global $ColumnC[5]
Global $ColumnB[5]

Global $testcodeIC1="300.1"
Global $testcodeIC2="218.6"
Global $testcodeIC3="poop"



$ColumnC[0] = "300.1"
$ColumnC[1] = "300.0"
$ColumnC[2] = "poop"
$ColumnC[3] = "zomgnewtestcode"
$ColumnC[4] = "300.1"
$ColumnB[0] = "Sample1"
$ColumnB[2] = "Sample2"
$ColumnB[3] = "Sample3"
$ColumnB[4] = "Sample4"
$ColumnB[4] = "Sample5"

For $i = 0 To UBound($ColumnC) - 1 ;should write zomgnewtestcode to the unknown file, eventually this will prompt me to assign it to IC1, 2, or 3. But for now I just want to debug why the IF statement isn't working.
    If $ColumnC[$i] <> $testcodeIC1 & $ColumnC[$i] <> $testcodeIC2 & $ColumnC[$i] <> $testcodeIC3 Then
        FileWrite(@ScriptDir & "\ICUNKNOWN.txt", $ColumnB[$i] & " " & $ColumnC[$i] & @CRLF)
    EndIf
Next

For $i = 0 To UBound($ColumnC) - 1
    If $ColumnC[$i] = $testcodeIC1 Then
        FileWrite(@ScriptDir & "\IC1.txt", $ColumnB[$i] & " " & $ColumnC[$i] & @CRLF)
    EndIf
Next

For $i = 0 To UBound($ColumnC) - 1
    If $ColumnC[$i] = $testcodeIC2 Then
        FileWrite(@ScriptDir & "\IC2.txt", $ColumnB[$i] & " " & $ColumnC[$i] & @CRLF)
    EndIf
Next


For $i = 0 To UBound($ColumnC) - 1
    If $ColumnC[$i] = $testcodeIC3 Then
        FileWrite(@ScriptDir & "\IC3.txt", $ColumnB[$i] & " " & $ColumnC[$i] & @CRLF)
    EndIf
Next

 

Edited by BatMan22

Share this post


Link to post
Share on other sites
BatMan22

Ummm to answer my own question.. apparently you can use AND but not "&" ? Even though you can use & everywhere else? I'm sooooo confused... 

Share this post


Link to post
Share on other sites
water

& is a string concatenator according to the help file.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

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

×