SoulBlade Posted March 4, 2010 Posted March 4, 2010 Hi! Im trying to display an entire TXT file inside a GUICtrlCreateEdit control without any sucess. Im using the following code: $file = FileOpen(@ScriptDir & "\test.txt", 0) $control = GUICtrlCreateEdit($file, 180, 100, 480, 275, $ES_AUTOVSCROLL + $WS_VSCROLL + $ES_READONLY) This only displays "1", meaning that it managed to open the text file. Any help will be appreciated! Thanks!
Fulano Posted March 4, 2010 Posted March 4, 2010 I'd check up on the documentation for the File functions. FileOpen only makes the file available for access, you need to use FileRead to actually read in the contents of the file.Thank you for supplying sample code, but please, please surround it with '[autoit][/autoit]' or '' tags, it makes life much, much easier for everyone. #fgpkerw4kcmnq2mns1ax7ilndopen (Q, $0); while ($l = <Q>){if ($l =~ m/^#.*/){$l =~ tr/a-z1-9#/Huh, Junketeer's Alternate Pro Ace /; print $l;}}close (Q);[code] tag ninja!
Yoriz Posted March 4, 2010 Posted March 4, 2010 FileOpen only Opens a text file for reading or writing, giving you a "handle" for use with subsequent file functions. You then need to use FileRead or FileReadLine to actually read it. GDIPlusDispose - A modified version of GDIPlus that auto disposes of its own objects before shutdown of the Dll using the same function Syntax as the original.EzMySql UDF - Use MySql Databases with autoit with syntax similar to SQLite UDF.
nitekram Posted March 4, 2010 Posted March 4, 2010 (edited) Look into FileRead() EDIT - that will teach me to refresh before posting Edited March 4, 2010 by nitekram 2¢ All by me:"Sometimes you have to go back to where you started, to get to where you want to go." "Everybody catches up with everyone, eventually" "As you teach others, you are really teaching yourself." From my dad "Do not worry about yesterday, as the only thing that you can control is tomorrow." WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2 AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit Docs SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language Programming Tips Excel Changes ControlHover.UDF GDI_Plus Draw_On_Screen GDI Basics GDI_More_Basics GDI Rotate GDI Graph GDI CheckExistingItems GDI Trajectory Replace $ghGDIPDll with $__g_hGDIPDll DLL 101? Array via Object GDI Swimlane GDI Plus French 101 Site GDI Examples UEZ GDI Basic Clock GDI Detection Ternary operator
SoulBlade Posted March 4, 2010 Author Posted March 4, 2010 Thanks for your input! Sorry for the lacking code tags. FileReadLine only to shows a line at a time; i want to display the entire file! I've read the documentation and searched this entire forum and haven't found anything that displays an entire file content to the GUI. I believe i can use a while - wend loop to read a line at a time, adding text to the control but i hope that there is another way.
Fulano Posted March 4, 2010 Posted March 4, 2010 (edited) You're on the right track, but it will 'flicker' less if you read the file into a variable first, then send it to the control. EDIT: Ran into this little jem in the File UDF Local $FileContents = FileRead($FileHandle, FileGetSize($FilePath)) Edited March 4, 2010 by Fulano #fgpkerw4kcmnq2mns1ax7ilndopen (Q, $0); while ($l = <Q>){if ($l =~ m/^#.*/){$l =~ tr/a-z1-9#/Huh, Junketeer's Alternate Pro Ace /; print $l;}}close (Q);[code] tag ninja!
SoulBlade Posted March 4, 2010 Author Posted March 4, 2010 $file = FileRead(@ScriptDir & "\test.txt") $control = GUICtrlCreateEdit($file, 180, 100, 480, 275, $ES_AUTOVSCROLL + $WS_VSCROLL + $ES_READONLY) These 2 lines did the trick! Many thanks Fulano!
Fulano Posted March 4, 2010 Posted March 4, 2010 Np, happy scripting #fgpkerw4kcmnq2mns1ax7ilndopen (Q, $0); while ($l = <Q>){if ($l =~ m/^#.*/){$l =~ tr/a-z1-9#/Huh, Junketeer's Alternate Pro Ace /; print $l;}}close (Q);[code] tag ninja!
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