![]() |
savelines() new line in file?
PHP Code:
|
Try the NL concat operator to create a new line:
PHP Code:
|
Eek, didn't work.
This is the outcome: This is an attempt to\nFigure out\nIf this works Same thing :( |
Here's some basic examples for the savestring and savelines functions.
PHP Code:
|
Quote:
My script loads a file from the server, displays it in a GUI, allows editing, but when it's saved, the new lines only show in the GUI and are not displayed in the original textfile, which could be a problem for things like guild text files, etc. If I could use the first thing shown (creating lines manually) I would, but that would destroy the use of the script all together. I need to overwrite, not append the text files. Lastly, what's being sent to the serverside part of the script to save the lines is the GUIs text. |
I'll be willing to bet your issue is that you're viewing the file on Windows, which doesn't properly display \n as linebreaks. You need to use \r\n.
|
No dice. Outcome:
I\'m currently\r\ntrying to figure out\r\nhow the hell\r\nthis thing\r\nworks\r I was also in the process of reading up on line breaks when this was posted... What a coincidence :p |
Oh. If you are actually storing the control sequences as letters, then you'll need to do a conversion before/after you save/load the file. Just replace \n with an actual line break, and vice versa.
|
That's my problem; figuring out how to do that xP
|
You can use shared.replacetext(string, search, replace) from http://forums.graalonline.com/forums...ad.php?t=81277.
|
Quote:
EDIT: Tested, not sure what I should be replacing the saving part with instead of \n... |
Ah, I see your actual problem now.
If you use savelines and loadlines, it automatically converts actual line breaks to the string \n. If you use savestring and loadstring it won't do that. So basically just use savestring and loadstring like in fp4's example and your problem should go away. |
The only problem I have when doing that is loadstring(). It doesn't actually load the file, it just displays a 0 in the GUI
|
Are you accessing the text via object.text or object.getlines()?
Your example seems to leave out the GUI part of your problem. |
object.text as it doesn't return in "","" form
|
My guess is that you are sending a string to the server, not the lines.
Perhaps something like this will work for you: PHP Code:
|
Quote:
JUST,WORK,ALREADY instead of what I want, which should be JUST WORK ALREADY it's getting closer, I'm just not sure what it is, exactly X.X By the way, the outcomes are what is displayed in the text file. PHP Code:
|
Quote:
PHP Code:
|
I edited the post with that in mind, but again, that was in both, the file and the GUI. I want both, the text file and the GUI, to display a line break. I know the MultiLineEdit can do that, but the goal is to display the text file exactly and the text file needs line breaks in order to do so
|
perhaps load and save the string rather than the lines then.
PHP Code:
|
This works, except the GUI doesn't display line breaks lol
|
1 Attachment(s)
This works just fine, the file will look messed up (all on one line) in regular Windows Notepad (Terriblepad) instead use Wordpad or Notepad++
PHP Code:
|
SO is there really no way to display line breaks in the GUI even though it's in the file itself?
|
Quote:
If you want them to you have to escape them... PHP Code:
|
Quote:
Save the string, since that worked before. Could work... PHP Code:
|
Ah, I've figured it out.
Maybe this could clarify some? Here is the completed code: PHP Code:
|
You're using getlines and setlines properly throughout and keeping it in it's line form.
Try using: PHP Code:
|
Quote:
What is the purpose of this line of code? |
Using lines is probably the best in v5.
In v6 we have added a new attribute GuiMLTextCtrl.plaintext which will give you the plain text without escapes. |
Quote:
And for Pix and fowlplay, I accidentally left that in there from previous attempts on bsing my way through savestring() and savelines()... I've edited it and used fowlplay's way as there's no reason for a temporary save there. Thank you all for your help :D |
| All times are GMT +2. The time now is 10:38 PM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.