Jump to content
Darien

"For...In" not working with _FileReadToArray

Recommended Posts

Darien

Hello,

 

When executing the script below (file "Excecoes_Desktop.txt" attached), the "For ... In" loop does not execute. I wonder why?

 

#include <File.au3>

Dim $matriz_excecoes_predefinidas [1]
_FileReadToArray ( "C:\Excecoes_Desktop.txt" , $matriz_excecoes_predefinidas , 0 , Chr(9) )

_ArrayDisplay ($matriz_excecoes_predefinidas)

For $excecao_predefinida In $matriz_excecoes_predefinidas

    MsgBox(0,"",$excecao_predefinida)

Next

Excecoes_Desktop.txt

Share this post


Link to post
Share on other sites
Jos

The _ArrayDisplay() also doesn't do anything ...right?

I think you wan to change this line:

_FileReadToArray ( "Excecoes_Desktop.txt" , $matriz_excecoes_predefinidas)

Jos


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

Share this post


Link to post
Share on other sites
Darien

For me the _ArrayDisplay() works. You should not have copied the file "Excecoes_Desktop.txt" to C:

Edited by Darien

Share this post


Link to post
Share on other sites
Jos

Agree...  but try anyway what I suggested.  With those parameters, the array changes from single to multiple columns which causes the issue in the For ..In loop.

Jos 


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

Share this post


Link to post
Share on other sites
Darien

I did, I had to remove the CHR (9):

 

#include <File.au3>

Dim             $matriz_excecoes_predefinidas [1]
_FileReadToArray ( "C:\Excecoes_Desktop.txt" , $matriz_excecoes_predefinidas , 0 )

_ArrayDisplay ($matriz_excecoes_predefinidas)

For $excecao_predefinida In $matriz_excecoes_predefinidas

    MsgBox(0,"",$excecao_predefinida)

Next

Thank you.

Edited by Darien

Share this post


Link to post
Share on other sites
mikell

Please note that if you use a For/To loop instead of a For/In, like this

For $i = 1 to UBound($matriz_excecoes_predefinidas)-1 
    MsgBox(0,"",$matriz_excecoes_predefinidas[$i])
Next

then you get an error msgbox with the cause of the failure written inside  :)

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

×