Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I need help with numerical formatting

Status
Not open for further replies.

Wolfsnap

Programmer
May 26, 2001
3
US
Still getting stuck on the number formatting thing.

What I have is a director movie that I'm trying to translate into flash.
My director code to get rid of commas reads like this:

--Get rid of commas
put field "dollars 1" into Gcomma
repeat with n=1 to length(Gcomma)
if char(n) of Gcomma = "," then delete char(n) of Gcomma
end repeat

All it does is looks at a string and deletes commas (with the input
fields I'm having in my project, it's going to be common for people to
input numbers like "50,000.00" - and when I try to convert that field
into a Number, I get a NaN result.

Not really a request for a site test (I realize this isn't the place),
but it may clarify what I'm trying to attempt


Seems to me there should be a simple way to do this - but for the life
of me, I can't figure it out (and, yes, I am definately a newbie at
this)

THX!
 
hi Wolf


The first link basically does as your request, parsing the "," character from a variable.

In the second link I've included an input box to select the character to be parsed. Might not be useful to you at the minute, but it's there for future reference.

If you have any questions, just ask.

Hope this helps your problem.
dave
dave@pinkzeppelin.com

^^^^^^^^^^^^^^^^^^^^^​
 
Hi Wolf

Thought I'd better explain the actions before 'someone' complains. You might not need an expo, but others might not be able to find the 'Help' section by themselves.

There might be an 'ouput=""' variable in the FLA, you can safely remove this.

The Stage consists of an Input box (variable: 'input') and a dynamic text box (variable: 'output').

//the first variable sets up the variable to be parsed
//from the value they entered in the Input box.

word = input;
//The following 'for' script carries out the process
//of checking each character of the Input value
//to determine whether a "," is present.
//The 'if' statement creates the new variable 'output'
//and for each iteration of the 'for' statement
//it appends the current character being processed
//to the 'output' variable, providing that it isn't a ","
//and providing that a value has been entered (hence: "")

for (n=0; n<=length(word); n++) {
if ((word.charat(n) ne &quot;,&quot;) and (word.charat(n) ne &quot;&quot;)) {
output = output+word.charat(n);
}
}

The function 'length(word)' tells the script how many characters are contained within the variable 'word'. So if word=&quot;DAVDESIGN&quot;, then: length(word)=9. Hence the 'for' statement is carried out for 9 iterations. The n++ statement is exactly the same as saying n=n+1. So the entire 'for' statement basically reads as:

Starting at 'n=0' , carry out the following 'IF' statement. Each time the IF statement is carried out, add 1 to the value of 'n'. Stop carrying out the IF statement when the whole word has been processed

The function 'word.charat(n)' checks the character at position 'n' in the string 'word'. For example, in the word DAVDESIGN the character at n=5 is 'E'. So if word=&quot;DAVDESIGN&quot; and n=5, then: word.charat(n)=&quot;E&quot;.

That should just about cover everything a newbie would ask for. If something still isn't clear, just shout.

dave
dave@pinkzeppelin.com

^^^^^^^^^^^^^^^^^^^^^​
 
I hope this is going to the right place - I wanted to thank those who responded to my question. It being 8:07 AM - I'm going to take a short coma and try these suggestions a first (second...third...) light. Rest assured, any information - usable or not - is GREATLY appreciated and will be shown so after my &quot;coma&quot; - Thanks again and...well...thanks again!
(I will NOT sing at your wedding, however - photograph it, maybe, but not sing (G))
Thaanks!
 
Yup - tried it and it's just what I needed - after looking at it, I'm kinda embarrassed I couldn't figure it out - but I do GREATLY appreciate the help!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top