![]() |
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
|
All times are GMT +2. The time now is 11:18 PM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.