Page 1 of 1

my first Javascript - parseint :)

Posted: Thu Nov 25, 2010 1:55 pm
by flowdesigner
Hi,

I guess that would be easy. I want to send an integer embedded inquotes into a js, remove the quotes, like fromsymbol, and and output an integer.
What would this look like?

Thanks

Re: my first Javascript - parseint :)

Posted: Thu Nov 25, 2010 2:27 pm
by pid
sorry i couldn't resist

<pre><code>
----------begin_max5_patcher----------
758.3oc0Xt0aaBCEG+YxmBjeNqBeiK6s84XoZhj3lxTvDANZ8h528EeLVwMi
TLAxZ5CkiNFp4u+w4hcdcV.ZY0ShFT32C+YXPvqyBBfgzCDz5GfJyeZ017F3
wPK2qTURzbysJVCCVs72eiDYGbWsnQHU4phJ4upEqTl4mg42EMOjfwZST6kv
6a+uj6KKjaEJ30fsSUtZ0iExMcLMQDiwd0chp1qNclLCoddmvLMnk4xMnv60
28sYyzWl6IBjh+bXAaWsJwSfxPurMbqnKxfyrC9PkTIyKAIf9QcQ9VTWqdxG
r5y.5QwwfIqmUOw4E2T7B7hwZvcFnfle3uoDJpvCToKljNPl3QDQLvjL1c7a
albHPYSc09ccgkjILTwfEJiBXgeyDpTJZZx2H9GtzHTcgDVO0UnTSk.Nsy5J
iGjjzHCHM4bDc7ENs2JNdCxo.ht.i6IvRRtx.KALXNCLe1D6LYiOTWU17b4x
pNKSE2GKignNBIaLrr+hasE7Snd1t6SAkEJQcWPjN805MsAII2D33bEzVfXj
EnvEHRFXRS.SBCLXV5BTW3hzWLGK0jWEckxesPlA0Ivrnah72ytySLdnQQXS
o7jrOqsPNrVfS39GwlOs3T1WhdYI81Jy7widsZkgsm1.R43QeY6jEOc0fayd
vwQ2Psj93Zvc.D5DlT0BDb1+gjJXRQaKjmdtcPX5weOkZp1WuxNU1CpGdTaq
EMpBIjX47P5lPNOziEqWKf6aUYYw5cUERUqHXDywtnXsw06LeM8Us5MOzuZi
uH0RwPrqq2XUKwG0ldYrMl3xVs2XUapOpkdYpMM0gsf2TnVbepMaXpkGYNpx
ACeN3wa8FqZy7gsIuaI4kZ05y76935MV0l3iZ4CSs17JyuKiq2XUarur8BpI
XXqq2XUKyW1N.0RRyrzDRuN5MV0h8PsCrj.lygVhG1Dk133MRw5SN1.CCvsE
rh.iq2H0ZrmZEObtlQc4p1ajZ0mdtwWVLf8rqG8NY2Myda1eA.ttP1F
-----------end_max5_patcher-----------
</code></pre>

i guess there would be an advantage to js if you were doing something else with these numbers in quotes...

Re: my first Javascript - parseint :)

Posted: Fri Nov 26, 2010 1:01 pm
by Gravis
I have this exact solution in my JS code :)

Will post it for you in a day or two when i get home

Re: my first Javascript - parseint :)

Posted: Tue Nov 30, 2010 11:36 pm
by Gravis

Code: Select all

blah = parseInt(StringToParse, 10);
This will ensure any string you pass into the method will be returned with base 10 which is what you want.

You may also want to strip the " " from a number(i think that might be the problem you are talking about)

Code: Select all

// remove the first "
myString = myString.substring(1, myString.length);

// remove the trailing "
myString = myString.substring(0, myString.length-1);
Does that make sense?

Re: my first Javascript - parseint :)

Posted: Wed Dec 01, 2010 8:05 pm
by flowdesigner
thanks man, I check it out when I come home

Re: my first Javascript - parseint :)

Posted: Thu Dec 02, 2010 5:49 am
by fxcoaching
Gravis wrote:

Code: Select all

blah = parseInt(StringToParse, 10);
This will ensure any string you pass into the method will be returned with base 10 which is what you want.

You may also want to strip the " " from a number(i think that might be the problem you are talking about)

Code: Select all

// remove the first "
myString = myString.substring(1, myString.length);

// remove the trailing "
myString = myString.substring(0, myString.length-1);
Does that make sense?

this is correct