Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
8

Script using uxp module crashes in Developer Tool, but not without

Community Beginner ,
Jun 14, 2023 Jun 14, 2023

The following script runs fine when launched from the Scripts Panel, but when run in the UXP Developer Tool, it gives this error message: "Cannot read properties of undefined (reading 'on')".

 

const versionInfo = await getVersion();
alert(versionInfo);

function alert(msg) {
    const theDialog = app.dialogs.add(),
        col = theDialog.dialogColumns.add();
	
	msg.split('\n').forEach(line => {
		const colText = col.staticTexts.add();
		colText.staticLabel = line;
	});
    
	theDialog.canCancel = false;
    theDialog.show();
    theDialog.destroy();
}

async function getVersion() {
	const versions = require('uxp').versions;
    const host = require('uxp').host;
    return `Host: ${host.name} ${host.version} ${host.uiLocale}\nUXP: ${versions.uxp}`;
}

Stepping through, require('uxp').host is the offending command.

Using InDesign 18.3 with UXP 6.5.0

TOPICS
Scripting , UXP Scripting
221
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 29, 2023 Jun 29, 2023
LATEST

My experiments with UXP indicate that it is an unfinished product feature and cannot be relied upon yet.

Mike Witherell
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines