How do you save the contents of an editor gadget?

Just starting out? Need help? Post your questions and find answers here.
Mr Tickle
User
User
Posts: 25
Joined: Mon Oct 13, 2003 10:33 pm
Location: England, Derbyshire.

How do you save the contents of an editor gadget?

Post by Mr Tickle »

I've managed to open a textfile and show the contents of it in an editor gadget. But once I've edited the file I can't seem to save it.

What's the easiest way to write the contents of an Ed Gadget?

Cheers
Mr Tickle.
Athlon xp 2500+, Gigabyte KT400-FSB333, Gf3 Ti200, SB Live 5.1
Kale
PureBasic Expert
PureBasic Expert
Posts: 3000
Joined: Fri Apr 25, 2003 6:03 pm
Location: Lincoln, UK
Contact:

Post by Kale »

Open a file, get the text from the Editor Gadget using 'Text$ = GetGadgetText(#Gadget)' then write that to the file using 'WriteString(Text$)'. Thats the easiest way... BUT you will have problems with strings over 64k due to PB internal string buffer, so its maybe best in using memory buffers to hold the string before writing and using 'WriteData(*MemoryBuffer, LengthToWrite)'. :)
--Kale

Image
Mr Tickle
User
User
Posts: 25
Joined: Mon Oct 13, 2003 10:33 pm
Location: England, Derbyshire.

Post by Mr Tickle »

Thanks Kale, I nearly got it right. I tried using GetItemText before realizing it's not a tree view :oops:
I don't fully understand about using a mem buffer to hold the string :?:

Won't it too only hold the max value of the string (64k) :?:
Mr Tickle.
Athlon xp 2500+, Gigabyte KT400-FSB333, Gf3 Ti200, SB Live 5.1
Kale
PureBasic Expert
PureBasic Expert
Posts: 3000
Joined: Fri Apr 25, 2003 6:03 pm
Location: Lincoln, UK
Contact:

Post by Kale »

Won't it too only hold the max value of the string (64k)
No... you are only limited to your free memory, but you'll have to avoid most PB's native string commands and supplement them with the Windows API.
--Kale

Image
Post Reply