Jump to content

0032 vs 32


Recommended Posts

Im trying to add a function to my script that checks for missing files each file is called something like XXXXXX_XXXXXXXX_0001

then XXXXXX_XXXXXXXX_0002, XXXXXX_XXXXXXXX_0003 XXXXXX_XXXXXXXX_0004 and so on and so on.

The GUI on my app sets the first and last number, so what I have so far is

Func LIST_MISSING_FILES()
For $i = $START_PAGE To $END_PAGE
    If FileExists("C:\temp\sample_data\"&$BOOK&"_classified_"&$i) Then
    $somethingpointless=1
Else
    MsgBox(4096,"", $BOOK&"_classified_"&$i& " does not exist")
EndIf
Next
EndFunc

The problem is even if in the GUI you set the $START_PAGE to be 0001 $i becomes just 1 and the file exists fail

I hope this makes sense to someone.

Link to comment
Share on other sites

Maybe you could do something like this:

Func LIST_MISSING_FILES()
    For $i = $START_PAGE To $END_PAGE
        If FileExists("C:\temp\sample_data\"&$BOOK&"_classified_000"&$i) Then
            $somethingpointless=1
        Else
            MsgBox(4096,"", $BOOK&"_classified_"&$i& " does not exist")
        EndIf
    Next
EndFunc

But it will only work up to 9. The trick is to make the "000X" a string, not a number.

-edit-

Beaten by Smoke with a cooler and more efficient method.

Edited by Nahuel
Link to comment
Share on other sites

SmOke_N give you the solution :

Func LIST_MISSING_FILES()
For $i = $START_PAGE To $END_PAGE
    $Page = StringFormat("%04d", $i)
    If FileExists("C:\temp\sample_data\"&$BOOK&"_classified_"&$Page) Then
    $somethingpointless=1
Else
    MsgBox(4096,"", $BOOK&"_classified_"&$Page& " does not exist")
EndIf
Next
EndFunc

Best Regards.Thierry

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...