Michael36 Posted November 10, 2005 Share Posted November 10, 2005 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 More sharing options...
Zedna Posted November 10, 2005 Share Posted November 10, 2005 (edited) Try something like this: $txt = FileRead($file_name, FileGetSize($file_name)) GUICtrlSetData($Edit,$txt) Edited November 10, 2005 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Michael36 Posted November 10, 2005 Author Share Posted November 10, 2005 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 More sharing options...
Zedna Posted November 11, 2005 Share Posted November 11, 2005 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) Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Michael36 Posted November 11, 2005 Author Share Posted November 11, 2005 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 hehehehei understand what you mean thank you ! Link to comment Share on other sites More sharing options...
JSThePatriot Posted November 11, 2005 Share Posted November 11, 2005 ok thank you i understand now i was wondering where you got the $file_name var from hehehehei 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 More sharing options...
Michael36 Posted November 11, 2005 Author Share Posted November 11, 2005 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now