Overview of type2 class constants?

When writing scripts I’m using statements like:

set recordType to type of theRecord as string
if theRecordType is in {"bookmark", "«constant ****DTnx»", "webarchive", "«constant ****wbar»", "picture"}

Is there an overview of the classes that go with the type2 types? E.g. I can’t find the «constant …» which corresponds to the picture type.

1 Like

Actually this should be rarely necessary and not used by default.

I wish I could acknowledge that (I don’t want to check constants), but it’s definitely not the case: often type of theRecord as string actually gives back a constant rather than a type2 string (“bookmark”, “webarchive” etc.). I don’t know why, but using this type of checking is the only reliable way to get record types.

From what I’m seeing in other posts also other are doing this - is there something that can be done to always get a type2 string rather than a constant?

EDIT: also seeing it pop up in discussions like these it seems: Help determining the record type in a script - #9 by hertzs

1 Like

The latest versions actually improved this (especially the type of texts) but overall it’s one of the mysteries of AppleScript. Therefore an example still failing would be useful.

Okay, I’ll check and see if I can find a current example. I’m using this always to be on the safe side, but maybe the behavior hasn’t occurred anymore after recent updates. I’ll see what happens if I loosen the type checking.

Never used this is in any of my scripts actually and I did quite a bunch :slight_smile:

1 Like

I don’t use that form in my scripts either.

Will try if it works without. Seems btw that especially @pete31 and me are using this type checking (e.g. Script: Extract PDF URLs), maybe it’s something we used to need but not anymore.

It was definitely needed in Script: Colorize DEVONthink Icons (Color Code Magick). I even started a support ticket because the script did work in Script Debugger but failed for some record types when used via DEVONthink’s script menu. After starting the ticket I simply used a display dialog to show what type was delivered, this way it was obvious that via the script menu the conversion to a string resulted in a raw syntax string. Since then I use both forms because it’s a lot easier to always check for both than debugging a script.

1 Like

This basic script returns the expected values for all types (bookmark/‌feed/‌formatted note/‌group/‌html/‌markdown/‌PDF document/‌picture/‌plist/‌quicktime/‌rtf/‌rtfd/‌script/‌sheet/‌smart group/‌txt/‌unknown/‌webarchive/‌xml) both in the Script Editor.app and in the Scripts menu for me:

tell application id "DNtp"
	display dialog type of selected records as string
end tell
2 Likes