Jump to content

Nested Loops


Recommended Posts

I am having a problem trying to nest a While loop within another while loop.

I keep receiving a message Error: "Wend" state with no matching "While" statement.

I have checked all of my statements and they all have a begining and an end.

I was thinking it might be I am nesting While loop within another while loop.

Here is most of the code including where the Error is.

Any suggestions or help?

CODE

While $i > $num

$userInfo = StringSplit($userArray[$i], ";")

$userName = $userInfo[$ShortName]

$Drive = $userInfo[$Letter]

If $Drive = "F" Then

$SDrive = "\\server01\" & $Drive & "$\"

Else

$SDrive = "\\server02\" & $Drive & "$\"

EndIf

;SEARCH FOR FILES

$search=filefindfirstfile($SDrive & $userName & "\data\*.ntf")

While 1

$file3=filefindnextfile($search)

If @error = -1 Then ExitLoop

select

case $file3 = "bookmark.ntf"

;do nothing

case $file3 = "cache.ntf"

;do nothing

case $file3 = "pernames.ntf"

;do nothing

case $file3 = "headline.ntf"

;do nothing

case $file3 = "autosave.ntf"

;do nothing

case else

filedelete($file3)

end select

"ERROR" WEnd

fileclose($search)

$search2=filefindfirstfile($SDrive & $userName & "\data\nsd_all_W32I_*.log")

While 1

$file4=filefindnextfile($search2)

If @error = -1 Then ExitLoop

filedelete($file4)

WEnd

fileclose($search2)

FileCopy("\\server01\g$\data\bookmark.ntf", $Sdrive & $userName & "\data\", 1)

FileCopy("\\server01\g$\data\us.dic", $Sdrive & $userName & "\data\", 1)

$i = $i + 1

Wend

Thanks

Edited by Joe11
Link to comment
Share on other sites

  • Developers

Run Tidy and it tells you:

(44) : ### Tidy Error -> "wend" is closing previous "case"

Meaning you are missing a EndSelect before the Wend.

:)

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

[b]While 1[/b]
$file4=filefindnextfile($search2)
If @error = -1 Then ExitLoop

filedelete($file4)
[b]WEnd[/b]
fileclose($search2)

FileCopy("\\server01\g$\data\bookmark.ntf", $Sdrive & $userName & "\data\", 1)
FileCopy("\\server01\g$\data\us.dic", $Sdrive & $userName & "\data\", 1)

$i = $i + 1
[b]Wend[/b]

1) use quotes another time

2) the first Wend stops the While 1

better start the script, write there the code and then set the while 1 function....

Link to comment
Share on other sites

Run Tidy and it tells you:

(44) : ### Tidy Error -> "wend" is closing previous "case"

Meaning you are missing a EndSelect before the Wend.

:)

Thanks I had a space between End Select.

What is tidy and how do I run it?

Link to comment
Share on other sites

  • Developers

Thanks I had a space between End Select.

What is tidy and how do I run it?

its part of SciTE4AutoIt3 ...see my sig for the website ...

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...