Sign in to follow this  
Followers 0
Michael36

FileReadline

7 posts in this topic

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)

Share this post


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

Share this post


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

Share this post


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

Share this post


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

Share this post


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

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