GUI//Writing too files
Author |
Message |
uberwalla

|
Posted: Fri Apr 06, 2007 10:36 pm Post subject: GUI//Writing too files |
|
|
well, i decided even though theres no turing in school this semester I'd go at it anyways. I am a little rusty, So i got a few questions.
I am creating a program with the pre-made GUI functions in which i have a GUI menu, text box and text field. When you write in the text field it goes into the textbox. what i want to do is instead of having when you type and such it writes to the file. i want to get so that i can write to the text box and then later when finished i can use the GUI menu to save. so basically like programs you go... File:save then it writes to the file? would that work? how?
thanks ahead of time |
|
|
|
|
 |
Sponsor Sponsor

|
|
 |
md

|
Posted: Sat Apr 07, 2007 11:26 am Post subject: RE:GUI//Writing too files |
|
|
If you have a large buffer you can store all the text in memory; assuming you can dynamically allocate memory in Turing it should be easy to write a doubly linked list type structure that holds chunks of text. Using a doubly linked lisk has other benifits too; like ease of inserting text, ease of moving back and forward in the buffer, etc.
When you save you just write the text in the linked list to a file. |
|
|
|
|
 |
uberwalla

|
Posted: Sat Apr 07, 2007 12:15 pm Post subject: Re: GUI//Writing too files |
|
|
so do you mean have a separate file that it writes too? and then saves to that also later? or like is it possible to have the text saved in like a variable format that would write there and then be able to save? lol i don't i am making much sense. you understood my question and answered it thank you, but i am now confusing myself i think because i do not understand what exactly you mean.
where/how would i store it? is there a way to save it through this but still be in the file and edit it more so this say my comp shut down, and i saved it 5 min before it would have it saved as long as i hit save? (as in it doesn't end the program?)
thx. |
|
|
|
|
 |
md

|
Posted: Sat Apr 07, 2007 4:07 pm Post subject: RE:GUI//Writing too files |
|
|
you're not understanding at all... but then I get the feeling you may not understand linked lists.
Let's say you have an empty document; that's just an empty list. As you type you can add blocks of text to your list. If you go back and edit something you split the block that was there into two new parts; the stuff before the edit and the stuff after. Then you insert the new text into the list between those two blocks.
When you save you just write all the blocks to a file as text; no need to save the structure of the list or anything. Just output it as a stream of acsii (or UTF-8) characters.
When reading a file you just make a single block and load it into that. If you edit previous text you do the same as above. If you add on to the end you just make another block and add it to the end of your list.
I think maybe I'm not explaining it well still... but really it's easy as pi. |
|
|
|
|
 |
|
|