Saving and Opening Text Area Text
BlitzPlus Forums/BlitzPlus Programming/Saving and Opening Text Area Text
| ||
I wanna be able to load and save text area text to a file but I'm having trouble with the lines. I know I need chr$(10) and chr$(13) at the end of every line but it isnt quite working how it should. Here is my code: Global Config Global TextField1 Global EnterAHomepage Global TEXTAREA1 Global EnterYourApps Global Submit CreateConfig() While WaitEvent() If EventID()=$401 And EventSource()=submit DeleteFile("config.txt") file=WriteFile("config.txt") WriteLine(file,TextFieldText(textfield1)) WriteLine(file,TextAreaText(textarea1)) FreeGadget(config) End If If EventID()=$803 And EventSource()=config FreeGadget(config) End If Wend Function CreateConfig() Config = CreateWindow("Butane Configuration",220,151,300,295,Desktop(),17) TextField1 = CreateTextField(5,20,280,20,Config,0) label1 = CreateLabel("Enter Your Homepage",5,5,280,15,Config,0) TEXTAREA1 = CreateTextArea(5,65,280,180,Config,0) label2 = CreateLabel("Enter Application Locations and Nicknames",5,50,280,15,Config,0) Submit = CreateButton("Enter",100,250,100,20,Config,0) file=ReadFile("config.txt") SetGadgetText(textfield1,ReadLine(file)) While Not Eof(file) AddTextAreaText(textarea1,ReadLine(file)) AddTextAreaText(textarea1,Chr$(10)) AddTextAreaText(textarea1,Chr$(13)) Wend CloseFile(file) End Function |
| ||
What's not working? It loads and saves the text fine for me. |
| ||
@soja Isn't it obvious what's wrong? it isnt quite working how it should I don't see how you missed that. It's so black/white. |
| ||
From a quick glance there is no matching CloseFile to go with: file=WriteFile("config.txt") which will cause unpredictable results. |
| ||
OK. Sorry guys. If you open the config file in notepad, many of the lines that were shown in the text area are on one line seperated only by a undisplayable character. There also seem to be some problems when opening and saving a file repeatedly. |
| ||
The XP version of notepad has some pretty wierd handling of chr(13), I advise just using chr(10). |
| ||
thanks. that seems to have worked! |
| ||
So are you working on a word processor? I'm in the middle of one right now. I have a problem though. I want to change a certain font on a textarea, but It will change everything. Is there a way around this? |