Sign in to follow this  
Followers 0
dar100111

Trouble with Function in If then statement

5 posts in this topic

I've tested my variable many different ways and I think there's a syntax problem that I just don't know how to deal with.

How do you correctly start the _ie function in this statement?  Is there a trick.  My variables do equal each other and I've verified. 

Thanks in advance!

If $prefix = $currentbranch Then _ExcelWriteCell($oExcel, $consolwgt, $row, 2)

Share this post


Link to post
Share on other sites



I've tested my variable many different ways and I think there's a syntax problem that I just don't know how to deal with.

How do you correctly start the _ie function in this statement?  Is there a trick.  My variables do equal each other and I've verified. 

Thanks in advance!

If $prefix = $currentbranch Then _ExcelWriteCell($oExcel, $consolwgt, $row, 2)

Please post more of your code than this for quicker assistance.  What you have posted looks fine, but could be wrong depending on how the variables are populated above this line.

Share this post


Link to post
Share on other sites

Thanks Unbalanced.  Everything writes fine to my file except the If Then statements where $prefix = $currentbranch.  The function works fine on it's own so I'm thinking it's syntax.

If $value = 1 Then;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GET SYSTEM INFORMATION;;;;;;;;;;;;;;;;;;;;;;;;1
$oExcel = _ExcelBookOpen("F:EIDFWNATOracle NMCNMC DevelopmentNetwork AnalystReportsautoitfwdnbulkbook.xlsx")
$aArray = _ExcelReadSheetToArray($oExcel)
$counter = $aArray[0][0]
$currentbranch = $aArray[2][17]
$gci = "GCI"
Do
$eiref = $aArray[$row][1]
IF WinExists("EXPORT dfw") Then
 WinActivate("EXPORT dfw")
 ControlSend("EXPORT dfw","","","{PGUP}")
 ControlSend("EXPORT dfw","","","LOG  ")
 ControlSend("EXPORT dfw","","",$eiref)
 ControlSend("EXPORT dfw","","TScrollBox1","{F8}")
 ControlSend("EXPORT dfw","","TScrollBox1","{F8}")
 DO
 $prefix = StringTrimLeft($eiref, 3)
 $file = StringTrimRight(ControlGetText("EXPORT dfw", "", "[CLASS:TEIEdit; INSTANCE:76]"), 7)
 $org = ControlGetText("EXPORT dfw", "", "[CLASS:TEIEdit; INSTANCE:73]")
 $dest = ControlGetText("EXPORT dfw", "", "[CLASS:TEIEdit; INSTANCE:70]")
 $pcs = ControlGetText("EXPORT dfw", "", "[CLASS:TEIEdit; INSTANCE:7]")
 $wgt = ControlGetText("EXPORT dfw", "", "[CLASS:TEIEdit; INSTANCE:4]")
 $consolwgt = ControlGetText("EXPORT dfw", "", "[CLASS:TEIEdit; INSTANCE:3]")
 $descrip = ControlGetText("EXPORT dfw", "", "[CLASS:TEIEdit; INSTANCE:55]")
 Until $file = $eiref
 _ExcelWriteCell($oExcel, $wgt, $row, 2)
 If $prefix = $currentbranch Then _ExcelWriteCell($oExcel, $consolwgt, $row, 2)
 _ExcelWriteCell($oExcel, $pcs, $row, 3)
 _ExcelWriteCell($oExcel, $org, $row, 4)
 _ExcelWriteCell($oExcel, $dest, $row, 5)
 _ExcelWriteCell($oExcel, $descrip, $row, 6)
 If $prefix = $currentbranch Then _ExcelWriteCell($oExcel, "Freight All Kinds", $row, 6)
  Else
  MsgBox(0x10000,"Error","Open an EXPORT screen.")
  Exit
 EndIf
$row = $row + 1
Until $row = $counter + 1
MsgBox("","System Information Gathered", "Shipment Info from Export Complete!")
EndIf

Share this post


Link to post
Share on other sites

Add this in your script after one of the conditional statements and see if you get the right message box to pop up.

 

If $prefix = $currentbranch Then
    MsgBox($MB_SYSTEMMODAL, "Match", "They match")
Else
    MsgBox($MB_SYSTEMMODAL, "No Match", "They don't match")
EndIf

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

Hey Brewman. I should have done that inseat of a messagebox with my variable. There was a space on the end that I couldn't see. I'll do that next time. Thanks!

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  
Followers 0