Sign in to follow this  
Followers 0
eyegeegeewhy

0032 vs 32

6 posts in this topic

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.

Share this post


Link to post
Share on other sites

#2 ·  Posted (edited)

Are they all 4 digit numbers?

EDIT: Dammit Smoke. You knew where I was going with that one.

Edited by weaponx

Share this post


Link to post
Share on other sites

$Book = 1
$BookReLoaded = StringFormat("%04d", $Book)
MsgBox(0,0,$BookReLoaded)


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

i glanced at the StringFormat page in the help file but it made my head hurt so I stopped. Thanks for pointing in the right direction I will give it a read again.

Cheers again for the v quick responce

Share this post


Link to post
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

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