Formatting HTTML
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Formatting HTTML
If I have a chunk of html text in a variable:
tVar="<td align=right>16.2512</td>"
I can say answer tVar and I get a nice looking 16.2512
What operation on tVar will convert tVar to a regular number?
Thanks Larry
tVar="<td align=right>16.2512</td>"
I can say answer tVar and I get a nice looking 16.2512
What operation on tVar will convert tVar to a regular number?
Thanks Larry
Re: Formatting HTTML
Hi.
Can you tell me what you mean by convert to a number?
When a field is set to the htmlText of your string, the value "16.2512" is represented according to the tags attached to the html string.
What do you want to see from that string that is not already there?
Craig Newman
Can you tell me what you mean by convert to a number?
When a field is set to the htmlText of your string, the value "16.2512" is represented according to the tags attached to the html string.
What do you want to see from that string that is not already there?
Craig Newman
Re: Formatting HTTML
Hi Craid,
Regards,
Larry
I guess I mean I want to get rid of all html markings so that I have a number in tVar, something that could be added to another number for example. My actual use is to put the number back into a place in the data grid.Can you tell me what you mean by convert to a number?
Regards,
Larry
Re: Formatting HTTML
Hi Larry,
Look up isNumber in the dictionary.
and then use a
repeat for each char tChar in tVariable
Simon
Look up isNumber in the dictionary.
and then use a
repeat for each char tChar in tVariable
Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!
Re: Formatting HTTML
Hello Simon,
Regards,
Larry
I had hoped for something better. If I have to do all that, my preference would be to use offset to get the '>', truncate there and then use offset to get the '<' and then take everything in between.Look up isNumber in the dictionary.
and then use a
repeat for each char tChar in tVariable
Regards,
Larry
Re: Formatting HTTML
You guys do too much work to strip off the HTML tags, just use the templateField for quick, in memory processing..
Code: Select all
on mouseUp
local tVar
put "<td align=right>16.2512</td>" into tVar
set the htmlText of the templateField to tVar -- set the htmlText property
local tVarStripped
put the text of the templateField into tVarStripped -- grab the plain text that would be displayed
put tVarStripped
reset the templateField -- reset so creating a new field does not have your htmlText in it..
end mouseUp
Re: Formatting HTTML
shaosean,
Wow. It works, but it is going to take me some time to figure out what happened.
Larry
Wow. It works, but it is going to take me some time to figure out what happened.
Larry
Re: Formatting HTTML
Just make it a function that you can reuse..
Code: Select all
function htmlToText pHtml
set the htmlText of the templateField to pHtml
local tReturn
put the text of the templateField into tReturn
reset the templateField
return tReturn
end htmlToText
Re: Formatting HTTML
Hi Sean,
I use MetaCard/Revolution/Livecode for over 12 years now and still learn something new almost every day!
Thanks a lot for this little gem!
Best
Klaus
DAMN!shaosean wrote:...just use the templateField for quick, in memory processing...

I use MetaCard/Revolution/Livecode for over 12 years now and still learn something new almost every day!

Thanks a lot for this little gem!
Best
Klaus