Sign in to follow this  
Followers 0
skaboy71

Help Please ?

6 posts in this topic

#1 ·  Posted (edited)

I am trying to nest while statements but I keep getting an error...I have 2 While's and 2 WEnd's ..... What am I doing wrong ???

$rname = @MON&"-"&@MDAY&"-"&@YEAR&"_rep.txt"

$report = FileOpen  ( "C:\dreports\"&$rname, 1 )

$log = FileOpen ( "C:\logs\PMI-NTS-BDC02_app.txt", 0 )
If $log = -1 Then
    MsgBox(0, "Error", "Unable to open file.")
    Exit
EndIf

While 1
    $line = FileReadLine($log)
    If @error = -1 Then ExitLoop
    $done = 0
    $linepts = StringSplit($line, " ")
     While 1
     $compline = FileReadLine($report)
     If @error = -1 Then ExitLoop
     $clinepts = StringSplit($compline, "   ")
     If $linepts[1] == $clinepts[1] AND $linepts[9] == $clinepts[9] Then
     $done = 1
     EndIf
     WEnd
    If $done = 0 Then
    FileWriteLine($report,$line)    
WEnd

FileClose($file)

Posted Image

Edited by skaboy71

I'd rather laugh with the sinners than cry with the saints..... The sinners are much more fun....Only the good die young. -- Billy Joel

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

you are missing an endif

$rname = @MON&"-"&@MDAY&"-"&@YEAR&"_rep.txt"

$report = FileOpen( "C:\dreports\"&$rname, 1 )

$log = FileOpen( "C:\logs\PMI-NTS-BDC02_app.txt", 0 )

If $log = -1 Then

   MsgBox(0, "Error", "Unable to open file.")

   Exit

EndIf

While 1

   $line = FileReadLine($log)

   If @error = -1 Then ExitLoop

   $done = 0

   $linepts = StringSplit($line, " ")

   While 1

      $compline = FileReadLine($report)

      If @error = -1 Then ExitLoop

      $clinepts = StringSplit($compline, " ")

      If $linepts[1]== $clinepts[1] AND $linepts[9] == $clinepts[9] Then

         $done = 1

      EndIf

   WEnd

   If $done = 0 Then

      FileWriteLine($report,$line)

   EndIF

WEnd

  

FileClose($file)

Edited by JdeB

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Dohhhhh !!!! Thanks !!

I feeel Duuuuuumb :-)


I'd rather laugh with the sinners than cry with the saints..... The sinners are much more fun....Only the good die young. -- Billy Joel

Share this post


Link to post
Share on other sites

for that one you could also just use

If $done = 0 Then FileWriteLine($report,$line)
Then no EndIf is required It cuts down the line count by 1

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

no.. its just a matter of making it visable by formatting your source.... ( a bit of promo here for the Tidy script :whistle: )

this was the output after formatting it:

$rname = @MON&"-"&@MDAY&"-"&@YEAR&"_rep.txt"

$report = FileOpen( "C:\dreports\"&$rname, 1 )

$log = FileOpen( "C:\logs\PMI-NTS-BDC02_app.txt", 0 )
If $log = -1 Then
   MsgBox(0, "Error", "Unable to open file.")
   Exit
EndIf

While 1
   $line = FileReadLine($log)
   If @error = -1 Then ExitLoop
   $done = 0
   $linepts = StringSplit($line, " ")
   While 1
      $compline = FileReadLine($report)
      If @error = -1 Then ExitLoop
      $clinepts = StringSplit($compline, " ")
      If $linepts[1] == $clinepts[1] And $linepts[9] == $clinepts[9] Then
         $done = 1
      EndIf
   Wend
   If $done = 0 Then
      FileWriteLine($report,$line)
   Wend
   
   FileClose($file)
Edited by JdeB

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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