Referencing PopClip variables in JavaScript

In documentation:

is sentence: “In JavaScript, you access variables in the popclip global object. See JavaScript environment.”

but I don’t see information how create names of vars and reference them in JavaScript global object popclip.

For example how to get app name
I tried to replace space by underscore: app_name but it doesn’t work.

popclip.app_name
returns
undefined.

1 Like

In JavaScript, the properties are arranged and named differently than the scheme for shell scripts and AppleScripts. The app name is accessed as:

popclip.context.appName

See the documentation for the popclip global, and in particular:

I suggest to add this explanation in part of doc referencing to JavaScript, something like:
Variables in JavaScript are available in Context object, see …

2 Likes

Thanks for the suggestion – I have amended the docs along those lines.

1 Like