Skip to main content
deckarduk
Inspiring
May 19, 2023
Answered

Visual Studio Code question...

  • May 19, 2023
  • 13 replies
  • 2395 views

Hi Everyone,

The other day I upgraded my OS and have to now use Visual Studio Code.

Are there any useful resources to check I'm using VSC correctly when writing/executing my scripts?

I've installed VSC and one other question I have is, if I'm using $.writeln is there somewhere I can see the output of this as per the JS Console in ESTK ?

Thanks.

This topic has been closed for replies.
Correct answer m1b
quote

I also have to select a version of InDesign each time I execute my script, is that correct?

Enter in the launch.json under hostAppSpecifierEnter your current version number of InDesign in the launch.json under hostAppSpecifier:

"hostAppSpecifier": "indesign-18.064"

Hi @deckarduk, with ExtendScript debugger for VSCode, use //@ instead of # for targetengine and include directives.

 

//@targetengine "main"
//@include '~/Desktop/myLibrary.js'

 

- Mark 

 

P.S. you can set the default targetengine in your launch.json file. See my example above ("engineName").

13 replies

rob day
Community Expert
Community Expert
May 20, 2023

if I'm using $.writeln is there somewhere I can see the output of this as per the JS Console in ESTK

 

Hi @deckarduk , Also, your $.writeln() should show in the debug console panel:

 

deckarduk
deckardukAuthor
Inspiring
May 22, 2023

Hi Rob,

Many thanks for the help.

Glad to see we can still do that sort of thing, I use it quite a lot.

I've only spent 1.5 days using VSC so still learning and the upgrade came during a reasonable sized project.

Thanks again 👍

 

m1b
Community Expert
Community Expert
May 24, 2023

@deckarduk, there is some info in this thread, too.

m1b
Community Expert
Community Expert
May 20, 2023

Hi @deckarduk, I've got lots to say about VSCode. I actually love using it, compared to the old ways. I'm assuming you have installed the ExtendScript Debugger. Here's a few quick things:

 

1. This is my launch.json file. Bring up the command palette and type launch.json to edit it.

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "extendscript-debug",
            "request": "attach",
            "name": "Attach Indesign",
            "hostAppSpecifier": "indesign",
            "engineName": "main",
            "hiddenTypes": [
                "builtin",
            ],
        },
    ]
}

 

2. Here's my debugging keyboard shortcuts. Bring up command palette and type key and choose "Open keyboard shortcuts (JSON) to edit. You'll need to set the keys how you like.

    {
        "key": "alt+cmd+.",
        "command": "workbench.debug.panel.action.clearReplAction"
    },
    {
        "key": "ctrl+alt+cmd+a",
        "command": "workbench.action.debug.stop",
        "when": "inDebugMode"
    },
    {
        "key": "ctrl+alt+cmd+a",
        "command": "workbench.action.debug.run",
        "when": "debuggersAvailable && debugState == 'inactive'"
    },
    {
        "key": "cmd+r",
        "command": "extension.extendscript-debug.evalInAttachedHost",
        "args": {
            "debugLevel": 1,
            "bringToFront": false
        }
    },
    {
        "key": "cmd+shift+r",
        "command": "extension.extendscript-debug.evalInAttachedHost",
        "args": {
            "debugLevel": 1,
            "bringToFront": true
        }
    },
    {
        "key": "cmd+.",
        "command": "extension.extendscript-debug.haltInHost",
        "when": "inDebugMode"
    },
    {
        "key": "ctrl+.",
        "command": "workbench.action.debug.stop",
        "when": "inDebugMode"
    },
    {
        "key": "ctrl+m",
        "command": "workbench.action.debug.stepInto",
        "when": "debugState != 'inactive'"
    },
    {
        "key": "ctrl+i",
        "command": "workbench.action.debug.stepOut",
        "when": "debugState == 'stopped'"
    },
    {
        "key": "ctrl+l",
        "command": "workbench.action.debug.stepOver",
        "when": "debugState == 'stopped'"
    },
    {
        "key": "ctrl+shift+l",
        "command": "workbench.action.debug.continue",
        "when": "debugState == 'stopped'"
    },
    {
        "key": "ctrl+shift+c",
        "command": "editor.debug.action.runToCursor",
        "when": "debugState == 'stopped'"
    },

 

3. To see the debug console, type cmd-shift-Y (MacOS) probably ctrl-shift-Y on Windows.

 

Hope that helps a bit. Post back if you get stuck.

- Mark

deckarduk
deckardukAuthor
Inspiring
May 22, 2023

Hi Mark,

Wow! Thanks for all the help, that's great.

I'll work through the stuff above and see I how I get on.

Thanks again for all help 👍