Jump to content
Sign in to follow this  
SoulBlade

Display text file content in GUICtrlCreateEdit

Recommended Posts

SoulBlade

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!

Share this post


Link to post
Share on other sites
Fulano

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!

Share this post


Link to post
Share on other sites
Yoriz

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.

Share this post


Link to post
Share on other sites
nitekram

Look into FileRead()

EDIT - that will teach me to refresh before posting

Edited by nitekram

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

 

WindowsError.gif

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

Share this post


Link to post
Share on other sites
SoulBlade

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.

Share this post


Link to post
Share on other sites
Fulano

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

Share this post


Link to post
Share on other sites
SoulBlade

$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!

Share this post


Link to post
Share on other sites
Fulano

Np, happy scripting Posted Image


#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!

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.