Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Multiline String variable

Guest
Oct 02, 2010 Oct 02, 2010

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

TOPICS
ActionScript
932
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Oct 03, 2010 Oct 03, 2010

just about all applications will show two lines when your use \r EXCEPT notepad.  for notepade, use

"\r\n"

for a new line

Translate
Community Expert ,
Oct 02, 2010 Oct 02, 2010

\n for new line

\r for carriage return.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Oct 02, 2010 Oct 02, 2010

those does not work when save to a .txt

that symbols could only be recognized by flash environment, not by Notepad.

I wrote.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 02, 2010 Oct 02, 2010

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Oct 02, 2010 Oct 02, 2010

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 03, 2010 Oct 03, 2010

just about all applications will show two lines when your use \r EXCEPT notepad.  for notepade, use

"\r\n"

for a new line

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Oct 03, 2010 Oct 03, 2010

Oh Yeah! So cool!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 03, 2010 Oct 03, 2010
LATEST

you're welcome.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines