# PLUGIN-DEV: Checking for numbers Classic List Threaded 7 messages Open this post in threaded view
|

## PLUGIN-DEV: Checking for numbers

 Hi all,To test whether a thing x is a number, I wrote the following:if(not(IsObject(x))) // THEREFORE IS NUMBER OR (LENGTH >= 0) STRING {    if(x = (x + 0)) // THEREFORE IS NUMBER OR CHARACTER (LENGTH = 1 STRING)    {        if(x != Asc(x)) // x IS A CHARACTER IF AND ONLY IF x IS ITS OWN UNICODE CODE POINT        {               // THEREFORE x IS OTHERWISE A NUMBER             if(x = Round(x))            {                return 1;            }            else            {                return 2;            }        }    }}return 0; 0: not a number, 1: an integer, 2: a non integer number.and then afterwards discovered Bob Zawalich already wrote a similar method in utils. Mine is simpler and therefore faster probably. I'm wondering if anybody can think of any situation where they would produce different results, I haven't found any. But my method abuses the Asc() method, which might be a bad thing... Andrew
Open this post in threaded view
|

## PLUGIN-DEV: Re: Checking for numbers

 (Please ignore this message. I obviously did rather poor testing: it's not working. I might come back later if I fix it.)2009/11/24 Andrew Moschou Hi all,To test whether a thing x is a number, I wrote the following: if(not(IsObject(x))) // THEREFORE IS NUMBER OR (LENGTH >= 0) STRING {    if(x = (x + 0)) // THEREFORE IS NUMBER OR CHARACTER (LENGTH = 1 STRING)    {        if(x != Asc(x)) // x IS A CHARACTER IF AND ONLY IF x IS ITS OWN UNICODE CODE POINT        {               // THEREFORE x IS OTHERWISE A NUMBER             if(x = Round(x))            {                return 1;            }            else            {                return 2;            }        }    }}return 0; 0: not a number, 1: an integer, 2: a non integer number.and then afterwards discovered Bob Zawalich already wrote a similar method in utils. Mine is simpler and therefore faster probably. I'm wondering if anybody can think of any situation where they would produce different results, I haven't found any. But my method abuses the Asc() method, which might be a bad thing... Andrew
Open this post in threaded view
|

## PLUGIN-DEV: Test is the list working?

 In reply to this post by Andrew Moschou this is just a test…
Open this post in threaded view
|

## Re: PLUGIN-DEV: Test is the list working?

 Verifying receipt Regards, The Music Transcriber Roman Molino Dunn http://www.themusictranscriber.com http://www.themusictranscriber.com/plugin-store 610-392-4807--- On Tue, 12/8/09, Bob Zawalich <[hidden email]> wrote:From: Bob Zawalich <[hidden email]>Subject: PLUGIN-DEV: Test is the list working?To: [hidden email]Date: Tuesday, December 8, 2009, 12:54 PM this is just a test…

Open this post in threaded view
|

## Re: PLUGIN-DEV: Test is the list working?

 In reply to this post by Bob Zawalich Success.2009/12/9 Bob Zawalich this is just a test…