• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: handler failure [oops! correction]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: handler failure [oops! correction]


  • Subject: Re: handler failure [oops! correction]
  • From: Mike Fischer <email@hidden>
  • Date: Thu, 14 Nov 2002 01:58:40 +0100

Hi has,

Am Mittwoch, 13.11.02 um 20:40 Uhr schrieb has <email@hidden>:

As you can see, the result is completely crack-addled. (I know what's going
wrong here, but let's see who else can figure it out.)

Here is an exploit of this "feature" which demonstrates that it might actually be useful:

======================================================================
script langEnglish
property _Jan : "January"
property _Feb : "Febuary"
property _Mar : "March"
property _Apr : "April"
property _May : "May"
property _Jun : "June"
property _Jul : "July"
property _Aug : "August"
property _Sep : "September"
property _Oct : "October"
property _Nov : "November"
property _Dec : "December"

on GetMonthName(inMonth)
if inMonth = 1 then
return _Jan
else if inMonth = 2 then
return _Feb
else if inMonth = 3 then
return _Mar
else if inMonth = 4 then
return _Apr
else if inMonth = 5 then
return _May
else if inMonth = 6 then
return _Jun
else if inMonth = 7 then
return _Jul
else if inMonth = 8 then
return _Aug
else if inMonth = 9 then
return _Sep
else if inMonth = 10 then
return _Oct
else if inMonth = 11 then
return _Nov
else
return _Dec
end if
end GetMonthName
end script

script langGerman
property _Jan : "Januar"
property _Feb : "Februar"
property _Mar : "Mdrz"
property _Apr : "April"
property _May : "Mai"
property _Jun : "Juni"
property _Jul : "Juli"
property _Aug : "August"
property _Sep : "September"
property _Oct : "Oktober"
property _Nov : "November"
property _Dec : "Dezember"

property GetMonthName : missing value
end script

on Initialize()
set langGerman's GetMonthName to langEnglish's GetMonthName
end Initialize

on run
Initialize()
set s to "#" & tab & "English" & tab & "German" & return ,
& "--" & tab & "---------" & tab & "---------"
repeat with i from 1 to 12
set s to s & return ,
& (i as string) & tab ,
& (langEnglish's GetMonthName(i)) & tab ,
& (langGerman's GetMonthName(i))
end repeat
end run
======================================================================

A bit perverse but it actually works (at least on Mac OS X 10.2.2 Build 6F21, AS 1.9):
-->
"# English German
-- --------- ---------
1 January Januar
2 Febuary Februar
3 March Mdrz
4 April April
5 May Mai
6 June Juni
7 July Juli
8 August August
9 September September
10 October Oktober
11 November November
12 December Dezember"

Now if somone can tell me the trick of addressing properties by index the GetMonthName handler could be even more elegant...
(And please don't tell me I could use an array. That'd be beside the point.)

It does kind of remind me of obscure pointer arithmetic in C though ;-)

Now I wonder if this is actually a feature of AS that we can rely on or something of an implementation dependent side effect?

Mike
--
Mike Fischer Softwareentwicklung, EDV-Beratung
Schulung, Vertrieb
_______________________________________________
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.

  • Follow-Ups:
    • Re: handler failure [oops! correction]
      • From: has <email@hidden>
    • Re: handler failure [oops! correction]
      • From: Mike Fischer <email@hidden>
  • Prev by Date: Terminal Colors?
  • Next by Date: Re: GraphicConverter & saving files in new places
  • Previous by thread: Re: handler failure [oops! correction]
  • Next by thread: Re: handler failure [oops! correction]
  • Index(es):
    • Date
    • Thread