Script app won't run

I have a relatively simple script, saved as an Application. It will not run when invoked from my menu bar script icon, the windows on my desktop faintly blink for an instant but nothing else happens. But I can open the script/app in Script Debugger and it runs normally. The script ran normally when originally written and until a few months ago, and I have no clue what changed either in the code or MacOS that corresponds to the change in behavior.

The app is in my User Scripts Folder along with a dozen or so other scripts which all run fine when either activated directly or by other scripts. Just this one script seems a NOP. Very mysterious.

------------------------------------------------------------------------------------------------------------------------
(*
	KPCW JZ

	Written September 2024 by Jay Zorzy

	Updates JZ's fav tunes with last played date from KPCW EVS.	
	
	1. Import EVS CSV to KPCW database
	2. Run this script (only duplicate s/b Weird Science)
	3. Open JZ table, Copy/Paste all rows into JZ KPCW Favorites/JZ
	4. Should automatically update all other sheets

		V1.0 (9/14/24) Written.
		V1.1 7/29/26 Added Swap handler for Artist field
*)
------------------------------------------------------------------------------------------------------------------------
use AppleScript version "2.4" -- Yosemite (10.10) or later
use sqlLib : script "SQLite Lib2" version "1.1.0" --SQL stuff
use scripting additions

-- Open KPCW DB
property DBfile : "~/Library/Databases/KPCW.db" --SQL database
property preThe : "The "
property postThe : ", The"

set KPCWdb to open db in file DBfile with can write

------------------------------------------------------------------------------------------------------------------------
set buttonCancel to "Cancel"
set buttonOK to "OK"
set noText to ""
set SongCount to 0
set DiscoFunk to "DF Disco/Funk"

set getJZ to "Select Artist,Album,Title,Rating from JZ order by Artist,Album,Title"
set JZfavs to query db KPCWdb sql string getJZ result type list of records
set recCount to count of JZfavs

repeat with i from 1 to recCount
	set jzArtist to Artist of item i of JZfavs
	set evsArtist to SwapThe(jzArtist)
	set jzAlbum to Album of item i of JZfavs
	set jzTitle to Title of item i of JZfavs
	set jzRating to Rating of item i of JZfavs
	set getEVS to "Select Artist,Album,Title,Category,Time,Played from EVS where Artist like \"" & evsArtist & "%\" and Title like \"" & jzTitle & "%\" order by Artist,Album,Title"
	set EVSdata to query db KPCWdb sql string getEVS result type list of records
	set findCount to count of EVSdata
	if (findCount = 1) then -- single record, bingo
		set evsTime to |Time| of item 1 of EVSdata
		set evsPlayed to Played of item 1 of EVSdata
		set evsCat to Category of item 1 of EVSdata
		if (evsPlayed ≠ noText) then set evsPlayed to text 1 thru ((offset of space in evsPlayed) - 1) of evsPlayed -- trim off time
	else if (findCount > 1) then -- multiple matches, add album criteria
		set getEVS to "Select Artist,Album,Title,Category,Time,Played from EVS where Artist like \"" & evsArtist & "%\" and Album like \"" & jzAlbum & "%\" and Title like \"" & jzTitle & "%\" order by Artist,Album,Title"
		set EVSdata to query db KPCWdb sql string getEVS result type list of records
		set evsTime to |Time| of item 1 of EVSdata
		set evsPlayed to Played of item 1 of EVSdata
		set evsCat to Category of item 1 of EVSdata
		if (evsPlayed ≠ noText) then set evsPlayed to text 1 thru ((offset of space in evsPlayed) - 1) of evsPlayed -- trim off time
		set findCount to count of EVSdata
		if (findCount > 1) then -- still multiple matches
			set SearchResults to {} -- reset results list
			repeat with i from 1 to findCount -- format search results (tab delimited)
				set iArtist to (Artist of item i of EVSdata) & tab
				set iAlbum to (Album of item i of EVSdata) & tab
				set iTitle to (Title of item i of EVSdata) & tab
				set iTime to (|Time| of item i of EVSdata) & tab
				set iPlayed to (Played of item i of EVSdata) & tab
				set end of SearchResults to iArtist & iTitle & iAlbum & iTime & iPlayed & return
			end repeat -- format search results
			
			set Choice to false
			set ChoosePrompt to evsArtist & " / " & jzTitle & " / " & jzAlbum
			repeat until Choice
				set Choice to choose from list SearchResults with prompt ChoosePrompt without multiple selections allowed and empty selection allowed
				try
					-- Extract record from choice list, then parse each field according to fetch
					-- (Artist,Title,Album,Time,Played)
					-- Extract field then trim from Choice
					set Choice to item 1 of Choice
					
					set findTab to offset of tab in Choice
					set lenChoice to length of Choice
					set evsArtist to text 1 thru (findTab - 1) of Choice
					set Choice to text (findTab + 1) thru lenChoice of Choice -- skip Artist
					
					set findTab to offset of tab in Choice
					set lenChoice to length of Choice
					set evsTitle to text 1 thru (findTab - 1) of Choice
					set Choice to text (findTab + 1) thru lenChoice of Choice -- skip Title
					
					set findTab to offset of tab in Choice
					set lenChoice to length of Choice
					set evsAlbum to text 1 thru (findTab - 1) of Choice
					set Choice to text (findTab + 1) thru lenChoice of Choice -- skip Album
					
					set findTab to offset of tab in Choice
					set lenChoice to length of Choice
					set evsTime to text 1 thru (findTab - 1) of Choice -- get Time
					set Choice to text (findTab + 1) thru lenChoice of Choice
					
					-- Last field Played is date/time delimited by space so trim time				
					set evsPlayed to text 1 thru ((offset of space in Choice) - 1) of Choice
					
					set putDUPS to "Insert into DUPS (Artist,Album,Title,Time,Played) values (\"" & evsArtist & "\",\"" & evsAlbum & "\",\"" & evsTitle & "\",\"" & evsTime & "\",\"" & evsPlayed & "\")"
					update db KPCWdb sql string putDUPS
					
				on error
					set Choice to false
				end try
			end repeat
		end if
	else -- no match in EVS?
		display dialog "No match for " & jzTitle & " by " & evsArtist
	end if -- single/multiple/no matches
	
	-- Check if in Disco/Funk list (DISCO table)
	set getDISCO to "Select * from DISCO where Artist like \"" & jzArtist & "%\" and Title like \"" & jzTitle & "%\" "
	set DISCOdata to query db KPCWdb sql string getDISCO result type list of records
	if ((count of DISCOdata) > 0) then set evsCat to DiscoFunk
	
	set updJZ to "Update JZ set Time=\"" & evsTime & "\", Played=\"" & evsPlayed & "\", Category=\"" & evsCat & "\" where Artist=\"" & jzArtist & "\" and Title=\"" & jzTitle & "\""
	update db KPCWdb sql string updJZ
	
	---  Reset Top rating (10 to 2.5) now as Top script will update later
	if (jzRating = 10) then
		set updJZ to "Update JZ set Rating=2.5 where Artist=\"" & jzArtist & "\" and Title=\"" & jzTitle & "\""
		update db KPCWdb sql string updJZ
	end if
	
	set SongCount to SongCount + 1
end repeat

close db KPCWdb
display dialog (SongCount as text) & " songs in JZ list updated."

-- End script

on SwapThe(theArtist)
	set aThe to the offset of postThe in theArtist
	if (aThe > 0) then
		set newArtist to preThe & text 1 thru (aThe - 1) of theArtist
	else
		set newArtist to theArtist
	end if
	return newArtist
end SwapThe

I would open this code in Script Debugger and save it as an application on the current version of macOS that you are using. Try it again. If it fails, then there may be an issue in the following paragraph.

Shane released SQLite Lib 2 1.1.0 several years ago as far as I can tell. Since it likely uses AppleScript/Objective-C and Apple has continuously changed those Framework contents over the years, there is a good possibility that the code is no longer compatible with current releases of macOS — you do not mention which macOS version. Perhaps Shane can answer that over in LateNightSw.

Shane’s notes indicate that with Mojave or later, the coding using SQLite 2 1.1.0 must be edited in Script Debugger, not Apple’s Script Editor, owing to security issues.

I’d opened the code in Script Debugger and re-saved it as an app several times in the past since this oddity began occurring and just did so again to be sure, and the same behavior persists. I always use Script Debugger and can’t remember the last time I used Apple’s Script Editor.

Most if not all my script apps use SQL databases and all except this one work fine.

I have macOS Tahoe 26.6.2

My suggestion would be to enter the shadowy world of preferences. If you can find an old file and delete it, you may be able to get it going again. I’m sorry I can’t give you more details, but if you can search for something referred to in your script, or the name of the script app you created, then ensure that what you find is related to your script, you may be able to work from there. You could read up on something like Preferee from ManyTricks.com, and try using that. I don’t know whether that’s available anymore. I have no affiliation with ManyTricks, except that I have a friend who works there. Anyway, that’s the only way I’ve ever made progress with a situation such as yours. Good luck.