Sign in to follow this  
Followers 0
bowain

_FileReadToArray question

8 posts in this topic

Okay, is it possible to use file handles in _FileReadToArray or not? I've scoured the forum and re-re-re-read the help file description and have only come to the conclusion that you must use a string as in

$MyFile="c:\windows\notepad.exe"

_filereadtoarray ($MyFile,$MyArray)

or literally put the file path in the line as in

_filereadtoarrray ("c:\windows\notepad.exe",$MyArray)

After the week I have had so far I just want to make sure I'm not losing it somewhere. Also hoping this might help some other poor frazzled coder in his quest for greatness... :P

(apologies in advance if this has already been answered)

#include <sincere_apology.au3>

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Just a clarification:

$MyFile="c:\windows\notepad.exe"

Is not a file handle - it is a string and as such:

_filereadtoarray ($MyFile,$MyArray)

is the same as

_filereadtoarrray ("c:\windows\notepad.exe",$MyArray)

The file handle would be:

$hFile=FileOpen("c:\windows\notepad.exe")

I don't know how filereadtoarray or fileopen would handle .exe's

A quick way would be to write a script using both handles and paths to see if the arrays are the same.

Bob

Edited by YellowLab

You can't see a rainbow without first experiencing the rain.

Share this post


Link to post
Share on other sites

Just a clarification:

$MyFile="c:\windows\notepad.exe"

Is not a file handle - it is a string and as such:

_filereadtoarray ($MyFile,$MyArray)

is the same as

_filereadtoarrray ("c:\windows\notepad.exe",$MyArray)

The file handle would be:

$hFile=FileOpen("c:\windows\notepad.exe")

I don't know how filereadtoarray or fileopen would handle .exe's

A quick way would be to write a script using both handles and paths to see if the arrays are the same.

Bob

Yeah guess not the best example :P . Try this...

$FileToOpen=FileOpen("c:\any.txt",0)

_FileReadToArray($fileToOpen,$MyArray)

The above does not work, but...

$FileToLookAt="c:\any.txt)

_FileReadToArray($FileToLookAt,$MyArray)

this way does as does (and to your point this being essentially the same)...

_FileReadToArray("c:\any.txt",$MyArray)

Share this post


Link to post
Share on other sites

Yeah guess not the best example :P . Try this...

$FileToOpen=FileOpen("c:\any.txt",0)

_FileReadToArray($fileToOpen,$MyArray)

The above does not work, but...

$FileToLookAt="c:\any.txt)

_FileReadToArray($FileToLookAt,$MyArray)

this way does as does (and to your point this being essentially the same)...

_FileReadToArray("c:\any.txt",$MyArray)

The first example doesn't work because the _FileReadToArray() needs a filename as input.

The Notepad.exe will also not work as this UDF bexpects a regular text file.

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                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

The first example doesn't work because the _FileReadToArray() needs a filename as input.

The Notepad.exe will also not work as this UDF bexpects a regular text file.

Jos

Yeah caught that and reposted with better example, sorry I'm just a bit discombobulated, but the main question still bugs me, can a file handle be used in _readfiletoarray. I know it's a nit picky thing but it's like an itch you can't reach, ya know?

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Yeah caught that and reposted with better example, sorry I'm just a bit discombobulated, but the main question still bugs me, can a file handle be used in _readfiletoarray. I know it's a nit picky thing but it's like an itch you can't reach, ya know?

You mean that the first line I typed and the helpfile aren't explicit enough ? :P

EDIT: you can of cource copy the standard UDF and modify it to your needs.

Jos

Edited by Jos

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                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

#7 ·  Posted (edited)

I'm utterly confused. I guess I caused some weirdness passing a handle as the file path string...

:P

Edited by PsaltyDS

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

You mean that the first line I typed and the helpfile aren't explicit enough ? :(

EDIT: you can of cource copy the standard UDF and modify it to your needs.

Jos

Maybe it gets lost in translation :P

As for editing the UDF, wheres the fun in that? That would be like *gasp* work!!!! Much easier just to complain and get things fixed (at least that's the way the end users at my job think) :idea: (It would be a good exercise I guess, but far too much to do at the moment)

Seriously thanks for the information and help, I'll be crawling back under the rock I oozed out from until another itch needs scratched.

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