J_Kay Posted August 20, 2006 Share Posted August 20, 2006 (edited) OK, here's the issue I'm having. I have 2 text files with strings of numbers in each. There are blank lines that are in the lists periodically, that need to stay. These numbers need to stay in order. I need Line 1 from one file, then Line 1 from the other file, then Line 2 from File 1....so on and so forth. See code below. The problem is that I get two errors when I try to Check the Syntax and I don't understand what is wrong. I have noted the errors I receive in the locations that they point to. Any help is greatly appreciated. Thanks! [autoit] $eve = FileOpen("C:\folder\folder\eve.txt", 0) $mid = FileOpen("C:\folder\folder\mid.txt", 0) $join = FileOpen("C:\folder\folder\join.txt", 1) $x = 87 $y = 87 While $y > 0 ; <----- REF: missing Wend. $mline = FileReadLine($mid, $x) If $mline = 0 Then $x = $x - 1 Else ; <---- ERROR: missing Wend. FileWriteLine($join, $mline) $x = $x - 1 EndIf $eline = FileReadLine($eve, $y) If $eline = 0 Then $y = $y - 1 Else FileWriteLine($join, $eline) $y = $y - 1 WEnd FileClose($eve) FileClose($join) FileClose($mid) Exit [\autoit][\code] Edited August 20, 2006 by J_Kay Link to comment Share on other sites More sharing options...
Valuater Posted August 21, 2006 Share Posted August 21, 2006 (edited) this is how i would do that Local $eve = FileOpen("C:\folder\folder\eve.txt", 0) Local $mid = FileOpen("C:\folder\folder\mid.txt", 0) Local $join = FileOpen("C:\folder\folder\join.txt", 1) For $x = 87 to 1 Step -1 $mline = FileReadLine($mid, $x) If @error = -1 then ExitLoop If $mline > "" Then FileWriteLine($join, $mline) $eline = FileReadLine($eve, $x) If @error = -1 then ExitLoop If $eline > "" Then FileWriteLine($join, $eline) Next 8) EDIT maybe this will remove the blank lines.. so you can remove it ( If $mline > "" ) also, you error was if/then... so if $x then $y or.............. $if $x then $y else $z endif notice if you are using "else" there can be nothing after the "then" 8) Edited August 21, 2006 by Valuater Link to comment Share on other sites More sharing options...
J_Kay Posted August 21, 2006 Author Share Posted August 21, 2006 Works like a charm. Thanks! I'd stared at it so much and couldn't figure out why I was getting errors, but then again, I've never used If statements in an loop before. Still a little new to this, but the time spent, is WAY less than doing this manually. [n00b question] Is it a good idea to use the Local in front of variables instead of just listing them without? What about Dim? Is there a difference?? [\n00b question] Link to comment Share on other sites More sharing options...
flyingboz Posted August 21, 2006 Share Posted August 21, 2006 [n00b question] Is it a good idea to use the Local in front of variables instead of just listing them without?Yes. Always defining your scope is a good idea. What about Dim? Is there a difference??Last I read, Dim is being deprecated. Don't use it. If you choose to use it, and you upgrade to a later version of autoit, your scripts may stop working. Reading the help file before you post... Not only will it make you look smarter, it will make you smarter. Link to comment Share on other sites More sharing options...
MHz Posted August 21, 2006 Share Posted August 21, 2006 Last I read, Dim is being deprecated. Don't use it. If you choose to use it, and you upgrade to a later version of autoit, your scripts may stop working.Dim is not being depreciated to my knowledge so the warning is known as false. 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