PDA

View Full Version : Creating a text file from user input -help :(


robmaggs
03-08-2008, 07:10 AM
Hiya, I want to create a program to take several sets of data from user input, store the data and finally combine the elements together in a single text file.

I want to have three input fields comprising of a one line title, followed by a multi line summary and then finally a multi line body.

The problem is I'm not sure how to get ams to insert carriage returns when I append the data

Here's what I've done so far

title = Input.GetText("Input1");
summary = Input.GetText("Input2");
body = Input.GetText("Input3");
TextFile.WriteFromString("C:\\article.txt", title, false);
TextFile.WriteFromString("C:\\article.txt", summary, true);
TextFile.WriteFromString("C:\\article.txt", body , true);

This looks clumsy to me too, my logic says I should do something like:

Textfile.WriteFromString(C:\article.text", variable1, variable2, variable3, false);

and have carriage returns inserted after each variable.

Any suggestions would be gratefully received.

Many thanks Rob

longedge
03-08-2008, 09:35 AM
You just include "\r\n" at the points you wish to start a new line e.g.

Variable1 = "Hello."
Variable2 = "This is the next line of your final file."
Variable3 = "And in conclusion we have the last line."
Variable_final_text = Variable1.."\r\n"..Variable2.."\r\n\r\n"..Variable3

robmaggs
03-08-2008, 11:59 AM
Thanks Longedge you are a star :)