Exucute code in VS Code

I’m trying to use VS Code, and I got the REPL to run, as well as doing a little bit of arithmatic, but I’m not sure how to run a file.

There’s a little “Play” button on the top right:

image

I do that, and it runs the debugger. I don’t get any errors, but if I put in something like f(x,y)=x+y, I don’t get f generic function with 2 methods, and when I put f(3,2), I don’t get 5, but I get both if I put them straight in the REPL

What’s your setting for the result display?

image

1 Like

Also note that if you run a file, it is expected that you only get the output of the last evaluated expression, unlike if you enter the same code line-by-line in the REPL. Example:

Here I have enabled inline display, and have run the file using Shift+Enter - then all lines are executed, but the only result displayed is that of the last evaluated expression, here g(2, 3)

but if I do the same thing,i it doesn’t show g(2,3), nor do I see the answer on the line in the code, like in your sample.

do I need to put in a file location in Juno:executable path ?

Wait I thought this thread is about VSCode, not Juno? Also which setting are you using for results display (the screenshot in my second answer)?

the second screenshot. As for VS Code, yes I am, but in settings, just above Execution Code in REPL, and Execution Type, is a box labled Executable Path (I guess before I said Juno, sorry).

If you don’t set an executable path, then it will just default to whatever Julia installation is on your systemwide PATH (i.e. the Julia which starts when you just type julia into a shell).

But if I understand you correctly you have a working REPL in VSCode, so your problem is not that VSCode can’t find your Julia installation?

Ok, that’s good, and I thought that was working. Are there any more settings I should look at?

Sorry I’m not sure I’m following - are things working as expected now?

In principle I guess all settings could be relevant, depending on what you want to do :slight_smile:

In your example, it has a 6 next to g(2,3), and mine doesn’t. I don’t know why.

That is because I set the display to inline in the setting which I showed above, and I executed the code using Alt+Enter - see the docs here for different ways to execute code: https://www.julia-vscode.org/docs/stable/userguide/runningcode/

I set it to both, and using Alt+Enter, it does exactly that. Thanks!

1 Like