Re: Since Apple Listens to this List... [Case Statements]
Re: Since Apple Listens to this List... [Case Statements]
- Subject: Re: Since Apple Listens to this List... [Case Statements]
- From: email@hidden
- Date: Tue, 12 Feb 2002 01:32:50 EST
Has Wrote:
>
In the case of retrieving information based on, say,
>
3-digit phone codes, that's an easy one. I wouldn't even
>
consider using an if...elseif or switch...case block for
>
something like this - there's other methods that are much
>
better suited.
It was an example I pulled out of the air. Unlike US area codes,
international dialing country codes can vary in size from as small as one
digit (1 = USA) to three or more digits (357 = Cyprus). If I were truly
intent on doing this, I would convert the number to string, then match length
+ character (+character, etc) to speed the decision execution. BUT, it was
simply designed to demonstrate an example for which a case statement would be
useful, especially to a semi-novice programmer.
>
Myself, I'd build a thousand-item list, putting the
>
relevant information in the 'valid' slots and 'missing
>
value' in the rest. All you do then is feed in the number
>
[get item n of theList] and out comes the info/missing
>
value (depending on whether the number was valid or not).
>
The list itself could be constructed at compile-time from
>
whatever source data you like, say by pulling info from a
>
database or flat text file on disk. Very flexible and
>
maintainable, with super zippy lookup times.
I haven't tried this with AppleScript yet, although I have done it in other
languages. I was trying to keep it simple-stupid (KISS) -- building a record
list seems overkill for a starting programmer compared to a case statement.
In the bigger scheme of things, I would also think that implimenting a case
statement would be a fairly quick issue for the development team (less than
3-man-days with testing), since the underlying code already exists in the
development language(*).
NOTE: (*) I might be wrong. I don't actually know how AppleScript's
compiler/interpreter is coded behind the scenes -- I figure C/C++, but it
might be something else.
Either way, I can always state what my hopes for the future of the product
are :)
=-= Marc
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.