re: Month as Integer (or he's ranting again)
re: Month as Integer (or he's ranting again)
- Subject: re: Month as Integer (or he's ranting again)
- From: Nigel Garvey <email@hidden>
- Date: Mon, 4 Dec 2000 21:54:23 +0000
"Jason W. Bruce" wrote on Mon, 04 Dec 2000 11:02:39 -0600:
>
Hi Nigel,
>
>
I don't think you can use booleans as labels anywhere, but you can reassign
>
values to months, days, tab, and so-called constants if you place them in
>
records:
>
>
set foo to {December:December,tab:tab,monday:monday}
>
display dialog foo's December default answer ""
>
set foo's December to text returned of the result
>
display dialog foo's December -- displays whatever you entered
>
>
Records in AppleScript apparently have their own script context, and behave
>
like script objects. This means that you can use the same label in
>
different records in the same script, or the same label in a record and
>
elsewhere in a script -- even if the label is a so-called constant.
Hi, Jason.
Don't confuse the label with the constant just because they have the same
name. When you set foo to {December:December}, the December on the left
is a label of the record foo; the December on the right is a month
constant. Two different things with the same name. Your script replaces
the month constant with a string; it doesn't set the constant to a new
value. It *does* of course change the value assigned to the label.
Constants *do* exist in AppleScript and their values can't be changed -
largely, I suspect, because they *are* their own values and assigning
values to them is meaningless: the booleans (which, as you say, aren't
tolerated as record labels), the months, the weekdays, missing value, and
the mysterious null are examples. Other "constants" (as so described by
the AppleScript Language Guide) seem in fact to be predefined variables
and can take on new values. These include tab, space, return, pi, weeks,
days, hours, and minutes. These words can also be used as record labels
but - again - the labels are not the "constants". They just happen to be
described by the same word.
NG