Typinator got an error: Can't make "case does not matter" into type constant

Howdy folks, I have been working on an AppleScript to use in conjunction with Keyboard Maestro to add a new expansion to Typinator and am running into an error when trying to set two different properties; one for case handling and the other for the expansion type.

I am able to pass the variables setName, abbName, expName, descr and whlWrd with no issues. But when I try to pass either of the variables casHndl or expType I get an error saying that it can’t make the contents of those variables into type constant. Attached are screenshots of the errors themselves. As you can see in the AppleScript itself, I am setting those variables to the exact same string that I would otherwise put directly into the properties area, but when that same text is passed as a variable the script fails.

For instance, for case handling I can put in case handling:case does not matter and it works fine, but if I try to use case handling:casHndl it fails. Same for expansion type.

I’m hoping somebody here might have an idea as to what I can do to fix this. I’ve reach out to Guy at Typinator and am waiting to hear his response. Any help is greatly appreciated!

-Chris

Case handling error screenshot (click to expand/collapse)

Expansion type error screenshot (click to expand/collapse)

### Requires Keyboard Maestro 8.0.3+ ###
set kmInst to system attribute "KMINSTANCE"
tell application "Keyboard Maestro Engine"
	set setName to getvariable "local__Set Name" instance kmInst
	set abbName to getvariable "local__Abbreviation" instance kmInst
	set expName to getvariable "local__Expansion" instance kmInst
	set descr to getvariable "local__Description" instance kmInst
	set whlWrd to getvariable "local__Whole Word" instance kmInst
	--set casHndl to getvariable "local__Case Handling" instance kmInst
	--set expType to getvariable "local__Expansion Type" instance kmInst
end tell

--for debugging
set setName to "Test Set"
set abbName to "this is the abbreviation"
set expName to "this is the expansion"
set descr to "this is the description"
set whlWrd to "true"
set casHndl to "case does not matter" --this returns an error
set expType to "plain text" --this returns an error

tell application "Typinator"
	set setName to rule set setName --sets the Set name to the variable entered above
	
	tell setName
		-- These next two lines are the notes that Gue at Typinator provided me
		-- case handling: case does not matter, case must match, case affects expansion
		-- expansion type: plain text, HTML
		set setName to make new rule with properties ¬
			{abbreviation:abbName, plain expansion:expName, description:descr, whole word:whlWrd, case handling:casHndl, expansion type:expType}
		set newEntry to properties of setName
	end tell
	
end tell

newEntry

Just tried it and get the same result. whole word accepts its variable as text but case handling does not.

Have no wisdom to offer but would like to know the solution if/when you find it!

Hey Phillip, thanks for confirming that it’s not just me that it doesn’t work for!

I’ll definitely post back here if/when I hear back from Gue.

In the meantime I’ve come up with this (rather ugly) workaround.

----------------------------------------------------------
# Author:			Chris Thomerson (@cdthomer)
#
# Current Version:	2.0 (Added if statements for case handling and formatting... waiting to back from Gue at Typinator)
# Version History:	1.0 (Initial script)
#
# Created:			Thursday, February 10, 2022
# Modified:			Thursday, February 10, 2022
# macOS:			11.6.3 (Big Sur), 12.1 (Monterey)
# Tags:				Typinator
#
# DISCLAIMER
# Permission to use, copy, modify, and/or distribute this
# software for any purpose with or without fee is hereby granted.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
# WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
# THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
# CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
# CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
----------------------------------------------------------

### Requires Keyboard Maestro 8.0.3+ ###
set kmInst to system attribute "KMINSTANCE"
tell application "Keyboard Maestro Engine"
	set setName to getvariable "local__Set Name" instance kmInst
	set abbName to getvariable "local__Abbreviation" instance kmInst
	set expName to getvariable "local__Expansion" instance kmInst
	set descr to getvariable "local__Description" instance kmInst
	set whlWrd to getvariable "local__Whole Word" instance kmInst
	set casHndl to getvariable "local__Case Handling" instance kmInst
	set format to getvariable "local__Format" instance kmInst
end tell

(*
	--for debugging... ignore this... I am waiting to hear back from Gue so I can streamline some things in a future update
	set setName to "Test Set"
	set abbName to "this is the abbreviation"
	set expName to "this is the expansion"
	set descr to "this is the description"
	set whlWrd to "true"
	set casHndl to "case affects expansion" --this returns an error
	set format to "plain text" --this returns an error
*)

tell application "Typinator"
	set setName to rule set setName --sets the Set name to the variable entered above
	tell setName
		
		--make abbreviation with case does not matter properties
		if casHndl is "case does not matter" then
			
			--make abbreviation with plain text properties
			if format is "plain text" then
				set setName to make new rule with properties ¬
					{abbreviation:abbName, plain expansion:expName, description:descr, whole word:whlWrd, case handling:case does not matter, expansion type:plain text}
				set newEntry to properties of setName
			end if
			
			
			if format is "HTML" then
				set setName to make new rule with properties ¬
					{abbreviation:abbName, plain expansion:expName, description:descr, whole word:whlWrd, case handling:case does not matter, expansion type:HTML}
				set newEntry to properties of setName
			end if
		end if
		
		--make abbreviation with case must match properties		
		if casHndl is "case must match" then
			
			--make abbreviation with plain text properties			
			if format is "plain text" then
				set setName to make new rule with properties ¬
					{abbreviation:abbName, plain expansion:expName, description:descr, whole word:whlWrd, case handling:case must match, expansion type:plain text}
				set newEntry to properties of setName
			end if
			
			--make abbreviation with HTML properties			
			if format is "HTML" then
				set setName to make new rule with properties ¬
					{abbreviation:abbName, plain expansion:expName, description:descr, whole word:whlWrd, case handling:case must match, expansion type:HTML}
				set newEntry to properties of setName
			end if
		end if
		
		--make abbreviation with case affects expansion properties
		if casHndl is "case affects expansion" then
			
			--make abbreviation with plain text properties
			if format is "plain text" then
				set setName to make new rule with properties ¬
					{abbreviation:abbName, plain expansion:expName, description:descr, whole word:whlWrd, case handling:case affects expansion, expansion type:plain text}
				set newEntry to properties of setName
			end if
			
			
			--make abbreviation with HTML properties
			if format is "HTML" then
				set setName to make new rule with properties ¬
					{abbreviation:abbName, plain expansion:expName, description:descr, whole word:whlWrd, case handling:case affects expansion, expansion type:HTML}
				set newEntry to properties of setName
			end if
		end if
		
	end tell
end tell

newEntry

I heard back from Gue and he helped me to understand that those particular portions of the script are enumeration constants recognized only by Typinator so it was basically just a matter of moving the portion that sets those variables inside the tell application "Typinator" block for them to work.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.