I have experienced here, and have seen in discussions here, and here (quote: "good as PowerShell is and as good as vscode is, together they actually stink ") that:
There is a material delta between how a powershell script runs (and debugs) in VSCode vs outside VSCode.
Question:
Where can I find a write up that explains the delta and how to manage for it?
Context:
I currently have code that runs fine within VSCode but fails outside, and man is it frustrating!
Related
This question already has answers here:
VBS Script - Need to change msgbox to echo
(3 answers)
Closed 9 months ago.
Background
I'm a tech writer but have dabbled in coding for many years now. For work, I need to test about a hundred different ancient script samples. The samples are stored in our documentation. They are in written in Basic (technically, in Cypress Enable BASIC, but it's essentially very similar if not identical to Basic scripting). I need to test them and fix any that are broken.
I want to set up Visual Studio Code to run these because I love VSC as it has a lot of benefits over the very old and vanilla scripting editor included with our product that I've been using.
My Need
Mainly, I need to be able to copy and paste the code I want to test into VSC into a simple .bas file and then run and test the code inside VSC with code coloring, code running, and a debugger. Intellisense would also be helpful. I can get color coding, but getting it to run and debug isn't working.
What I've Tried and Other Notes
I've already spent hours trying to set something up, but can't figure it out.
I have Windows 10
From something I found online, I've mapped this folder C:\Windows\Microsoft.NET\Framework64\v3.5 to my system's Path Environment Variable. (where <user> is my user name).
I've also tried different vbscript and vba related extensions, but have since uninstalled them as nothing seemed to resolve this very basic (no pun intended) problem.
I've searched various posts online and in this site, but haven't found a solution yet.
I tried enabling Run in Terminal in Code-runner to see if that made any difference.
Something is wrong, as I consistently get errors. For example, with Code Runner extension installed, if I try to run this very simple vbscript to show a test message box...
Sub Main ()
Dim testString
testString = "Meh... Will it work?"
MsgBox testString
End Sub
...I get this result in my VSC Output window:
[Running] cscript //Nologo "d:\Temp\vbscripttest.bas"
[Done] exited with code=0 in 0.174 seconds
I find very little info searching on code=0 error that is useful.
My script is in my d:\temp folder. I don't know if that makes a difference. If I try running the .bas file from the File Explorer window directly by double-clicking on it, nothing happens. Though from the icon style, it appears to be mapped to VBScript.
I gather either Windows or vbcode or both can't find the vbscripting goodness that makes things work, though I thought pointing the path variable to C:\Windows\Microsoft.NET\Framework64\v3.5 would fix that.
After two days of pulling my eyebrows out using our product's internal script editor to test my scripts (my hair has long since gone), I am hankering for some good old fashioned debugging support in my favorite code editor!
What do you recommend I do to get things working? Thank you in advance for your help.
Your sample program is running successfully. In that file there is no code in the code path. VBScript in a top level language (unlike VBA). That means code runs outside of a sub or function.
So insert before the first line Main to call Main. Or lose the Sub ... End Sub for VBScript. In VBA/VB6 you would choose Sub Main as the startup sub in Properties.
While this is not your problem, just to be complete, if you start a script in CScript or WScript using //b command line parameter then message boxes are not displayed. See CScript /?.
I am customizing cursor-word-related commands with new keybindings. And there are many cursor-word-related commands in VS code. I know the command with Part has something to do with _ in words in a VS Code GitHub issue. But what is the difference between all the other commands? Say, what is the difference between cursorWordLeft and cursorWordStartLeft?
I have been googling for a while, but I cannot find docs or anything official on this topic. And it is really timing-consuming to test out every command. So is there anything on this topic that I can look into?
Also, which two commands correspond to the operation we normally do with Ctrl+Right and Ctrl+Left on Windows?
I'm going to answer your question partially. The difference between cursorWord vs cursorWordStart is that cursorWord is what the VSCode developer team created for the VSCode editor (they can make it work however they want). While cursorWordStart is essentially what Visual Studio IDE uses and it was added to VSCode, made to work exactly the same (so they don't touch it).
My answer is expanded upon what Alex Dima posted on GitHub (a Microsoft developer working on VSCode). I don't think it gets much more official than that. Source
I need some help here. I think Visual Studio Code is a great replacement for PowerShell ISE, however, there a few things that I am not sure if I am doing something wrong or if VS Code is just buggy yet. When debugging my PowerShell code, not only Intellisense does not work (I press the up/down button and nothing happens - Using the latest VS Code available and the latest PS Extension) and for a a very strange reason when I set a global variable in my code VS Code creates it as a Local variable instead.
Here is what I get in VS_Code:
And here is what I get in PS_ISE:
Because of that, obviously my code crashes because as soon as I change the scope the variables are no longer available.
This is really preventing me from fully using VS Code completely (it forces me to debug code using PS ISE). If I'm doing anything wrong, any help is greatly appreciated.
Powershell ISE terminal has the IntelliSense feature. Is it possible to get/enable the same IntelliSense feature in VSCode powershell terminal
Many thanks
The PowerShell extension(PSReadLine) for VSCode is still in pipeline for the next Enhancement, the teams are working on it should be released soon enough.
From what I read seems like a lot of work before they can get PSReadline to coexist with the PowerShell extension's language.
As per the comment from David Wilson from the discussion
"PSReadline is not supported in the integrated console at this time. A non-trivial amount of work is needed to make PowerShell Editor Services and PSReadline play nicely together so this could take some time.
Features this will enable:
1.Ctrl+Arrow keys, etc (keyboard navigation of the input line)
2.Syntax highlighting of input text
3.Multi-line text input (writing a function definition in the console across multiple lines)"
You can follow the discussion on
https://github.com/PowerShell/vscode-powershell/issues/535
I'm coming from a pure Windows Visual Studio programming background with little Linux experience. It seems possible to use VS Code to program in Julia, but I can't figure out how to get things set up correctly.
Does anybody have good example launch.json, tasks.json, or other files that can serve as an example to build from?
This would be a great thing to see in a detailed tutorial.
Here is how things work if you are using the Julia extension for VisualStudio Code.
The extension adds a bunch of new commands. They all start with "julia", so filtering by that string should show you everything you can do with the extension.
In terms of running Julia code, the extension offers only two options right now. First, you can execute a command to start a REPL. This will just show a default Julia prompt, and you can interact with it like you would with any other Julia REPL. The second is that there is also a command, triggered by Ctrl + Enter, to send either the current editor selection or the current editor line to this REPL.
There is currently no further integration offered by the Julia extension. We do plan to add debugger support in the future, at which point I would expect F5 to start the current file in the debugger, or something like that. But that functionality is probably a couple of months away.