Sign in to follow this  
Followers 0
azoth

Help Need With _filelisttoarray

6 posts in this topic

Hi to all

In the example of _FileListArray, the sample explains this :

#Include <File.au3>

#Include <Array.au3>

$FileList= _FileListToArray(@DesktopDir)

If (Not IsArray($FileList)) and (@Error=1) Then

MsgBox (0,"","No Files\Folders Found.")

Exit

EndIf

That's ok.

But when i declare this after the test :

for $i=1 to $FileList[0]

If the folder is empty, AutoIt crash with this error :

==> Subscript used with non-Array variable.:

for $i=1 to $FileList[0]

for $i=1 to $FileList^ ERROR

Why IsArry don't do her job? why i have no MsgBox? :)

HELP ME PLEASE !!!

Share this post


Link to post
Share on other sites



try replacing this

If (Not IsArray($FileList)) and (@Error=1) Then

with this

If (Not IsArray($FileList)) Or (@Error=1) Then

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

It would also work to change the placement of the checks:

If (@Error=1) And (Not IsArray($FileList)) Then

The reason is because each function resets the value of @error, which means that the IsArray function sets @error to 0 (unless it fails, which isn't the case here). That's why checking for @error = 1 after the IsArray check didn't get where you wanted to, and why checking it beforehand will work.

Share this post


Link to post
Share on other sites

It would also work to change the placement of the checks:

If (@Error=1) And (Not IsArray($FileList)) Then

The reason is because each function resets the value of @error, which means that the IsArray function sets @error to 0 (unless it fails, which isn't the case here). That's why checking for @error = 1 after the IsArray check didn't get where you wanted to, and why checking it beforehand will work.

very good green... i didn't even notice that

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

Thank you very much for helping me !!!

greenmachine=>I understand your precious explain but, strangely,

change in placement don't working for me. :)

On the other hand, the 'OR' solution of Valuater IS working ... :(

Thanks a lot !!

Share this post


Link to post
Share on other sites

glad i could help...

i will have to check-out greens approach for myself ... soon

8)


NEWHeader1.png

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