Jump to content

FileReadline


 Share

Recommended Posts

Hi all

i'm having a hard time puting the text of a txt file into a editbox

i try'd to put this code into a loop but it jsut keeps adding the first like i would like to put a txt file into a edit

i'm not sure what i'm doing Wrong any ideas on how i could do this ?

thank you

Michael

$file = FileOpen("test.txt", 0)
$ch = FileReadline($file, 1)
GUICtrlRead($Edit,GUICtrlSetData(-1,$ch)& @LF )
FileClose($ch)
Link to comment
Share on other sites

Try something like this:

$txt = FileRead($file_name, FileGetSize($file_name))
GUICtrlSetData($Edit,$txt)
thank you for your help your example did not work for me but i did get it to work like this

$file= FileOpen("test.txt", 0)
$txt = FileRead($file,100000000)
GUICtrlSetData($Edit,$txt)
FileClose($ch)
Link to comment
Share on other sites

thank you for your help your example did not work for me but i did get it to work like this

$file= FileOpen("test.txt", 0)
$txt = FileRead($file,100000000)
GUICtrlSetData($Edit,$txt)
FileClose($ch)
I expected, you put name of file into variable $file_name:

$file_name = "test.txt"
$txt = FileRead($file_name, FileGetSize($file_name))
GUICtrlSetData($Edit,$txt)

OR

$txt = FileRead("test.txt", FileGetSize("test.txt"))
GUICtrlSetData($Edit,$txt)
Link to comment
Share on other sites

I expected, you put name of file into variable $file_name:

$file_name = "test.txt"
$txt = FileRead($file_name, FileGetSize($file_name))
GUICtrlSetData($Edit,$txt)

OR

$txt = FileRead("test.txt", FileGetSize("test.txt"))
GUICtrlSetData($Edit,$txt)
ok thank you i understand now i was wondering where you got the $file_name var from hehehehe

i understand what you mean thank you !

Link to comment
Share on other sites

ok thank you i understand now i was wondering where you got the $file_name var from hehehehe

i understand what you mean thank you !

Just a quick note. A better programming practice is to follow the advice of the FileGetSize() function as your size to read, because eventually the file may exceed your reading abilities. It is just safer and a better programming practice. I just wanted to mention that, incase you havent already added it to your working script.

JS

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Link to comment
Share on other sites

Just a quick note. A better programming practice is to follow the advice of the FileGetSize() function as your size to read, because eventually the file may exceed your reading abilities. It is just safer and a better programming practice. I just wanted to mention that, incase you havent already added it to your working script.

JS

ok thank you for the advice i will do that it's a very good point

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