code:applescript:age
Differences
This shows you the differences between two versions of the page.
| code:applescript:age [2005/11/04 14:29] – external edit 127.0.0.1 | code:applescript:age [2018/08/29 07:37] (current) – removed hop | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | Calculate the age of a person in Apple' | + | |
| - | <code applescript> | + | |
| - | using terms from application " | + | |
| - | on age(e) | + | |
| - | set cy to (year of (current date)) | + | |
| - | set y to (cy - (year of e)) | + | |
| - | + | ||
| - | set cd to (day of (current date)) | + | |
| - | set cm to ((month of (current date)) as integer) | + | |
| - | + | ||
| - | set d to (day of e) | + | |
| - | set m to ((month of e) as integer) | + | |
| - | + | ||
| - | if (cm ≤ m) and (cd < d) then | + | |
| - | return y - 1 | + | |
| - | else | + | |
| - | return y | + | |
| - | end if | + | |
| - | end age | + | |
| - | + | ||
| - | on action property | + | |
| - | return "birth date" | + | |
| - | end action property | + | |
| - | + | ||
| - | on action title for p with e | + | |
| - | -- return (age(e) as string) & " years old" | + | |
| - | return (age(e)) | + | |
| - | end action title | + | |
| - | + | ||
| - | on should enable action for p with e | + | |
| - | return true | + | |
| - | end should enable action | + | |
| - | + | ||
| - | on perform action for p with e | + | |
| - | display dialog (name of p & " is " & (age(e)) as string) & " years old" | + | |
| - | return true | + | |
| - | end perform action | + | |
| - | end using terms from | + | |
| - | </ | + | |
code/applescript/age.1131114546.txt.gz · Last modified: 2005/11/04 14:29 by 127.0.0.1
