I don’t know the answer, but it’s interesting that it isn’t the caret “^”, it’s any number between 0 and 3 as text. Doesn’t matter if you use ‘ASCII character N’ for the number, either. It works as expected if you put a space between the caret and the number, and doesn’t work properly if you append ‘as unicode text’ to the expression, either.
Try it:
set nums to {5, 4, 3, 2, 1, 0}
repeat with N in nums
display dialog "^ " & (N as text) & " when side by side are " & "^" & N giving up after 1
end repeat
I just love bugs that have been there for years and years and no-one’s ever stumbled on them before.
But I’ve just been looking through my archives and see that this caused a small ripple on the AppleScript-Users mailing list in March 2004. It’s apparently something to do with place holders and “dynamic text” in dialogs, as explained on Apple’s Developer site. It is a bug and shouldn’t be bothering AppleScripters. I don’t know if there’s any way round it, unless you stick an invisible character in the string to break up the combination:
display dialog "^" & (ASCII character 0) & "0"
[i]Later: Sorry. I see I’m the latest of several to suggest that.[/i] :rolleyes:
set Msg to {"This text has ^0 in it", "This text has none", "This text has ^3 in it", "This text has ^7 in it"}
repeat with M in Msg
set O to offset of "^" in M
if O > 0 and character (O + 1) of M is in {"0", "1", "2", "3"} then set M to text 1 thru O of M & (ASCII character 0) & text (O + 1) thru -1 of M
display dialog M
end repeat
Because the Dialog Manager is a system utility of long standing, fixing this for AppleScript would break the dialogs in lots of Applications. They aren’t going to fix it, so your script has to (which is why I posted the workaround).