PDA

View Full Version : Help on text string neded please


DTX
08-10-2006, 11:57 PM
Hi,

I am trying to create an application that collects data from 12 input fields, and concat them to one long string, so that it maybe output to a text file.

This file when complete would be uploaded to a server and the string is then read IN to a flash movie. I have the upload, write to text bit sorted, but can not work out how to make my required string to sotre in the text file.

I need to output to a .txt file in the following format exactly

fieldname1=Result1&fieldname2=Result2&fieldname3=Result3 etc..

My problem is this. I need to use = and the & characters in my final string. Which I know are reserved

Any help appreciated
Cheers
Drew

Dermot
08-11-2006, 03:08 AM
This should do the trick.

result1 = Input.GetText("field1")
result2 = Input.GetText("field2")
result3 = Input.GetText("field3")

sOutput = "field1="..result1.."&field2="..result2.."&field3="..result3

DTX
08-11-2006, 09:01 PM
That's very kind of you, thank you very much. It works a treat!

Cheers
Drew

DTX
08-12-2006, 12:24 AM
Hi,

I have tried Masking each input field using ### to only allow Numerical input of a maximum 3 digits, this works fine, except when there is an input of only 2 digits.

The string...

sOutput = "field1="..result1.."&field2="..result2.."&field3="..result3

Ends up like sOutput = "field1="123"&field2="12 "&field3="123

Field 2 has a whitespace after the result of 12 this would cause errors in the Flash file reading of the string.

I have tried changing the option from "Formatted" to "As Typed". But this does not make a difference.

So I guess my question is, is there a Mask character that would not show a whitespace in the result if no 3rd character was input.

Or is there anyway I can just say only accept numbers?

OR is there anyway to auto strip the whitespace from my sOutput string?

Thanks in advance
Cheers
Drew

Dermot
08-12-2006, 01:40 AM
The best thing is to use the String.TrimRight() function to remove any trailing blank spaces

result1 = String.TrimRight(Input.GetText("field1"), nil)
result2 = String.TrimRight(Input.GetText("field2"), nil)
result3 = String.TrimRight(Input.GetText("field3"), nil)

sOutput = "field1="..result1.."&field2="..result2.."&field3="..result3

DTX
08-12-2006, 03:11 AM
Once again, you have solved my problem.

Many thanks once again! :yes

That final problem, I am pleased to say, completes this project for me.

Cheers
Drew

Dermot
08-12-2006, 11:43 AM
No problem. Glad to hear you got it all working. :yes