handy applescript

Kelly Burgess kellyb at montana.com
Sun Aug 13 11:00:59 UTC 2023


I just revised a 'droplet' tool I have, adding Studio 11 awareness. This is a compiled Applescript app whose icon you can drag and drop an Omnis library onto, and it will tell you which version of Studio it was last used with. Saves you from launching a library with the wrong version, having to decline the offer to convert or deal with the 'can't read library' error when there's a version mismatch.

If you don't use Macs, it also serves as a list of the first-byte values you can hex-edit to back-convert a library in some cases.

Paste this script into Apple's Script Editor and save it as a run-only Application that doesn't stay open.

Kelly 



on open files_
	repeat with file_ in files_
		set file_ to POSIX path of file_
		-- read the first three bytes
		set foo to (open for access (POSIX file file_))
		set txt to (read foo for 3)
		close access foo
		-- map bytes to version
		set byteOne to ASCII number (first character of txt)
		set byteTwo to ASCII number (second character of txt)
		set byteThree to ASCII number (third character of txt)
		set dialogMsg to file_ & " is not a Studio 3 or Studio 4 library."
		if byteTwo = 1 then -- 0x01
			if byteOne = 44 then -- 0x2C
				set dialogMsg to file_ & " is a Studio 3.x library."
			end if
			if byteOne = 45 then -- 0x2D
				set dialogMsg to file_ & " is a Studio 4.x library."
			end if
			if byteOne = 46 then -- 0x2E
				set dialogMsg to file_ & " is a Studio 4.3.1+ library."
			end if
			if byteOne = 47 then -- 0x2F
				set dialogMsg to file_ & " is a Studio 5.0.x library."
			end if
			if byteOne = 48 then -- 0x30
				set dialogMsg to file_ & " is a Studio 5.1.x library."
			end if
			if byteOne = 49 then -- 0x31
				set dialogMsg to file_ & " is a Studio 5.2.x library."
			end if
			if byteOne = 50 then -- 0x32
				set dialogMsg to file_ & " is a Studio 6.0.x library."
			end if
			if byteOne = 51 then -- 0x33
				set dialogMsg to file_ & " is a Studio 6.1.x library."
			end if
			if byteOne = 52 then -- 0x34
				set dialogMsg to file_ & " is a Studio 8.0.x library."
			end if
			if byteOne = 53 then -- 0x35
				set dialogMsg to file_ & " is a Studio 8.1.x library."
			end if
			if byteOne = 54 then -- 0x36
				set dialogMsg to file_ & " is a Studio 10.0.x library."
			end if
			if byteOne = 55 then -- 0x37
				set dialogMsg to file_ & " is a Studio 10.1.x library."
			end if
			if byteOne = 56 then -- 0x38
				set dialogMsg to file_ & " is a Studio 10.2.x library."
			end if
			if byteOne = 57 then -- 0x39
				set dialogMsg to file_ & " is a Studio 11.0.x library."
			end if
			if byteThree = 1 then
				set dialogMsg to dialogMsg & " (Unicode)"
			end if
		end if
		display dialog dialogMsg buttons {"OK"} default button "OK"
	end repeat
end open





More information about the omnisdev-en mailing list