
Copy link to clipboard
Copied
Hello everyone
I need to place a multiline text into a .txt file.
Have a .php service file that creates a file from App's parameters sended to it:
<?php
$getVar = $_POST['TheString'];
$file = 'test.txt';
$writeVar = fopen($file,'w');
fwrite($writeVar,$getVar);
fclose($writeVar);
?>
and the collection of AS service functions to send parameters.
private function sendData(str:String):void {
variables = new URLVariables();
fData = new URLRequest("fileservices/SaveService.php");
fData.method = URLRequestMethod.POST;
fData.data = variables;
fLoader = new URLLoader();
fLoader.dataFormat = URLLoaderDataFormat.VARIABLES;
fLoader.addEventListener(Event.COMPLETE, sendComplete);
variables.TheString = str;
fLoader.load(fData);
}
All works, but can only write a single-line string into a file.
when send a string containing '/n' paragraph character, it does not work in .txt file opened with Notepad.
So, what is that specific character to use to mark paragraphs returns,
or should i use the different class instead of String,
or have i to edit my .php file to add such usability (and what is that magic changes to bring)?
Thanks in advance
1 Correct answer
just about all applications will show two lines when your use \r EXCEPT notepad. for notepade, use
"\r\n"
for a new line
Copy link to clipboard
Copied
\n for new line
\r for carriage return.

Copy link to clipboard
Copied
those does not work when save to a .txt
that symbols could only be recognized by flash environment, not by Notepad.
I wrote.
Copy link to clipboard
Copied
you used a forward slash. use a backslash.
if you don't see multiline text in your text file, show the string you're writing to your text file.

Copy link to clipboard
Copied
Sorry, i used forwrahd slash hear, but i used backslash in my code. When opening te resulting text file in Flex's editor, it's multiline!
But when with the other program, it's not!
There's string's procedure
public function composeJobAd(item:Object):String {
var string:String;
string = item.Profession;
string = string+'\r'; //////////////////// or '\n', it doesn't matter
return string;
}
There's final string procedure:
private function prepareData(dataCollection:Object):void {
var str:String = '';
for each (var item:Object in dataCollection) {
var comp:StringComposer = new StringComposer();
str = str + comp.composeJobAd(item);
}
sendData(str);
}
Thank you Kglad any way!
I surprised, but nobody can tell me what to do.
Copy link to clipboard
Copied
just about all applications will show two lines when your use \r EXCEPT notepad. for notepade, use
"\r\n"
for a new line

Copy link to clipboard
Copied
Oh Yeah! So cool!
Copy link to clipboard
Copied
you're welcome.

