[Q] asDate asNumber - not really working?

Chris Cunningham csque0 at lycos.com
Wed Feb 4 22:27:25 UTC 2004


I'm writting a little app where I want to write out (in readable format) a fraction, and then later read it back in.  At first, I thought I'd try converting the fraction to a string, and just write that out.  Later, I would get that string, and just send it #asNumber.  Interestingly, this doesn't work.

So:
(1/24) asString asNumber
returns an error (At least one digit expected here).  This is because the #asString puts parenthesis around the string.

Next, I wondered how often this happened.  So, I tried this with other objects.  It works just fine with integers, floats, Dates, Times:
1 asString asNumber
2.392 asString asNumber
1 asString asNumber
2.392 asString asNumber

However, it doesn't work with TimeStamps:
TimeStamp fromString: (TimeStamp current asString)
(note: no #asTimeStamp in String).

I also note there isn't an #asFloat in String, which is probably just fine.

For now, I will either create a new flavor of Float>>readFrom: to handle the ()'s around the number, or hack the current version in Float to read this.  I'd be more than happy to modify Float>>readFrom: to take read this in and post it as a [enh] if it is desired - I'm just not sure that this is really the desired behaviour.

-Chris



____________________________________________________________
Get advanced SPAM filtering on Webmail or POP Mail ... Get Lycos Mail!
http://login.mail.lycos.com/r/referral?aid=27005



More information about the Squeak-dev mailing list