Jump to content
HTRN

Function in for / Next

Recommended Posts

Posted (edited)

I have a script that I want to convert to using variables so that I only have to have 1 iteration of the script and just use an array to process the next item in the array.What I am running into is an error within the function, "error:missing Next"  and I can't quite figure out where I am missing the boat.

Here is the code.  Some may recognize their incorporated suggestions 😎    Also,  how do I paste code in the forum so it shows up as it looks in SciTE 

Global $T[3] = ["A","B","C"]
Global $x

For $x = 0 to 2

Func _EXISTS($sFile = "C:\Users\XXXX\Downloads\$T[$x].csv", $iTimeout = 5000) ; $iTimeout in milliseconds
    Local $hTimer = TimerInit() ; start counting time
    While TimerDiff($hTimer) < $iTimeout
        If FileExists($sFile) Then Return True ; check if the file exists
        Sleep(100) ; do not hog the CPU
    WEnd ; if you reached this point, it means the file does not exist after timeout
    Return False
EndFunc   

If _EXISTS() = "True" Then
SplashTextOn("Display","It's There", 200,200,200,200)
sleep(2000)
splashoff

else 

SplashTextOn("Display","It's Missing", 200,200,200,200)
sleep(2000)
splashoff

next

exit

 

 

Edited by HTRN

Share this post


Link to post
Share on other sites
Posted (edited)

Something like this: untested

Global $T[3] = ["A","B","C"]
Global $x

For $x = 0 to UBound($T) - 1
    If  _EXISTS("C:\Users\XXXX\Downloads\" & $T[$x] & ".csv", 5000) = True Then
        SplashTextOn("Display","It's There", 200,200,200,200)
        sleep(2000)
        splashoff()
    else
        SplashTextOn("Display","It's Missing", 200,200,200,200)
        sleep(2000)
        splashoff()
    EndIf
next

Func _EXISTS($sFile = "C:\Users\XXXX\Downloads\$T[$x].csv", $iTimeout = 5000) ; $iTimeout in milliseconds
    Local $hTimer = TimerInit() ; start counting time
    While TimerDiff($hTimer) < $iTimeout
        If FileExists($sFile) Then Return True ; check if the file exists
        Sleep(100) ; do not hog the CPU
    WEnd ; if you reached this point, it means the file does not exist after timeout
    Return False
EndFunc

 

Edited by Subz
Forgot EndIf

Share this post


Link to post
Share on other sites

Thank you for the info and I actually got it to work in theory. Haven't tried it in my full blown script just yet,


BUT!! In typical fashion,  I have once again changed my mind about how I want part of  this script to run.  I will be posting a new question..

 

 

 

 

  

Share this post


Link to post
Share on other sites
10 hours ago, HTRN said:

Also,  how do I paste code in the forum so it shows up as it looks in SciTE 

 

When you're writing your post, there should be a bar above with Bold, underline, etc. There should be a "<>" icon for code. Paste your code in the window that pops up.

Share this post


Link to post
Share on other sites

so cutting and pasting from SciTE acutally captures the coding from the screen.   TY.    

 

;THANK YOU VERY MUCH!!

 

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

×
×
  • Create New...