Abbreviations Question

Today whilst trying to set a variable to “nD” I got a compile error “Expected expression but found nd”. I suspect this is an abbreviation so tried rD & tH same result. Apart from the “app” example I can’t find much about this. If these are abbreviations then how would I use them? Is there some sort of list of know abbreviations that I could use. Does anybody use this?

Hi, Mark.

nd is one of AppleScript’s reserved words, which not many people use but is nevertheless there. It’s an ordinal suffix that can be used in an alternative syntax when specifying the second something of something:

item 2 of myList
2nd item of myList
second item of myList

The other English ordinal suffixes are similarly reserved.

The AppleScript abbreviations of which I know are app, ref, and prop. You can also put just end at the end of a block and it will compile as the appropriate end statement. A contrived illustration:

prop fred : "Fred.txt"

tell app "Finder"
	set bert to ref file fred of desktop
end

doThis("barmy")

on doThis(sid)
	considering case
		repeat 10 times
			if (sid is "barmy") then
				beep
			end
		end
	end
end

Not relevant here, but the coercions as centimetres, as metres, as kilometres compile to their American spellings.

Thank you Nigel, for the “contrived illustration” the end, end, end is a nice tip. I notice the if I’ve used a “ordinal suffix” and change the number preceding it then the appropriate “ordinal suffix” is complied too.