Display dialog "^0" doesn't display the string within the quotes

Here’s a simple question, for which I couldn’t find an answer in the forums.

Why is it that the following command generates a dialog box with a null string output:

Display dialog "^0" -- ("Zero", not the letter "O")

Ie, the string between the quotes doesn’t get displayed.


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

In other words: IT’S A BUG!

Wow, I stumbled on a real BUG ?!?!

It sounds like you tried various workarounds without success. Thanks for your efforts.

I’d still like to be able to display that combination if there is any way possible!


You can put a null character after the caret (ascii character 0). I couldn’t find anything on it either.


Even this doesn’t work:

display dialog «data utxt005E0030» as Unicode text

It does work of course with any other character in between, including a space “^ 0”

Or using Kel’s suggestion:

display dialog "^" & (ASCII character 0) & "0"


I just love bugs that have been there for years and years and no-one’s ever stumbled on them before. :slight_smile:

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:

On applescript-users.lists.apple.com, Chris Nebel (AppleScript Engineering) spake thusly:

Thanks to you all for the extraordinarily fast and helpful responses. You guys are the best. I’ll use the “ASCII character 0” trick as a workaround.


You could go after the special cases:

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

Thanks again. What is the chance of getting Apple to fix the “bug”, and how would one go about requesting it?

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).

Thanks for the info. The null character workaround is easy enough.