i spent a day tearing out my hair unable to figure out why my app wasn’t working. finally i discovered it was a bug in AppleScript (unless i’m really missing something here).
try this code:
set x to current date
set y to x
set time of x to 0
get y
when you change the time of one variable, you also change the time of every other variable with the same time !!!
what is up with that?
once i figured out why nothing was functioning, the workaround proved quite simple:
set x to current date
set y to x
set x to x + 1
set time of x to 0
get y
For simple types like integers and reals the behaviour you describe wont happen.
However for more complex types which require more memory then diferent variables can point to the same object.
When you need to make sure that you have a completely seperate object so that you can compare them after modifying one of them for example you need to copy the orignal object.
set x to current date
copy x to y
set time of x to 0
get y