Can you save variables in Visual Studio Code? - variables

I am trying to teach myself code/automate some tasks in my downtime at work, and the IDE that IT installed for me use python with is VSCode, which I don't seem to understand fully.
My only formal education in coding was using matlab. I remember being able to define a variable or function in my code, run it, and then call the very same variable/function in the terminal, which would return what I had defined. There was also a workspace directory that showed all the variables I had stored. However, is VSCode, i cannot find anything like that - I even had to install a separate package to RUN my code. Is it possible to have VSCode do what I described above in matlab? It was a long process getting IT to install VSC so I really do not want to try to get a new interpreter unless I absolutely have to. If there is some significant difference in matlab and VSC that I am not grasping, I would appreciate if that could be explained because I feel very much in over my head right now.
testVar = 8
I would expect to be able to type testVar into the terminal, and have it return 8, but instead:
testVar : The term 'testVar' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify
that the path is correct and try again.
At line:1 char:1
+ testVar
+ ~~~~~~~
+ CategoryInfo : ObjectNotFound: (testVar:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException

As rioV8 mentioned in the comments to the OP's post, if you enter python in the terminal, you get the python REPL which is like the command window in Matlab. You could then try commands to display the list of variables (which I don't recall at the top of my head), but I don't think you can get the visual display like Matlab's workspace.
For that, one option is to set a breakpoint at the end of your code, and run the code in debug mode (F5 on Windows). Then you can see the variable workspace as well as play around with the values using the debug console (which acts like a command window during debugging).
However, for more frequent interactions between the code, workspace, and command window, I recommend using jupyter notebook instead. There you can run code and view the variable workspace (search variable in the command palette (ctrl + alt + P)) in the variable explorer. Hopefully your python setup includes that option; you can try creating a new file in VSCode with .ipynb extension.

Related

Intellij and vscode doesn't run a Hello World java program

like this the program seementer image description here
after i setup intellij i tried to run my first java program but it doesn't work and always shows the message of "Abnormal build process termination"
and i tried to work on vscode but it also doesn't work
Looks like from your output that you named a folder with a ? at the beginning (C:\Users\?...) and apparently Java doesn't like that. Try moving the project in another folder or try renaming it.
(Post the whole output if you can, it's filled with useful info)

VSCode Active Text Editor Doesn't Work Even When Focused On A Text Window

On my VS Code extension, I'm trying to get the path to the current workspace. I've tried what it says on the documentation: vscode.window.activeTextEditor But this is always returning undefined.
Am I doing something wrong?
Tried Code: vscode.window.activeTextEditor
So I actually found the answer after a bit of messing around.
It actually was working, I just wasn't doing pulling up a window correctly.
Go to the [Extension Development Host] window
Start your extension from the command pallet (CTRL + Shift + P)
In the [Extension Development Host] window, you have to open up a workspace or file.
It works like this because it only senses for workspaces and files open in the Extension Host window.

How can I run only single kotlin file in Intellij

I have a problem when i run Kotlin file in Intelij.
I want to run only one kotlin file that is AbstractVehicle.kt
under the image is code of AbstractVhicle.kt
However, I got an error. because always run with other Kotlin files when I run!!
I tried to run using variety way to run only AbstractVehicle.kt file (ex:for example control + shift + R or control + R... My laptop is Macbook )
please help me.. how can run only one kotlin file
First, Click file AbstractVhicle.kt. Second, right click. Third, click run AbstractVhicle main method.

CLion code navigation with C++ doesn't work

I've used AppCode (Intellij C++/ObjC IDE that replaces Xcode) for a while and really gotten used to being able to Ctrl+Click on any identifier to get to its definition/decleration.
Now on a new work place, I'm using CLion for a somewhat larger code base and Ctrl+Click hardly ever works. It only seem to work when the identifier is in the same file.
Is there anything I need to setup for this to work correctly? CLion seem to index the code successfully and doing text searches works fine.
You need to use import project functionality of CLion from File -> Import Project and give ok for CMakeLists.txt file automatic creation. Never mind the file is for CMake, you can build your project with other tools too, but CLion uses it for the dependencies.
Then append in the beginning of that file a line stating:
include_directories(.)
After that go to File -> Settings and there search for Keymap from the left and after that on right, right below the word "keymap" there is a selection element for taking for example Eclipse default keymapping in use and there you have at least (I tested only it) the ctrl + click functionality working like charm!!
kudos about the include_directories(.) goes to this question: CLion indexer does not resolve some includes in the project directory
You need to press ctrl + alt + shift + n.
And after pressing it a dialog box will appear to enter your variable/function name and click enter.
Tip: Filter the result for a better experience. Filter option is present on right side of the dialog box.
To get a quick peek of function/variable definition press ctrl + q while focusing on the variable or function.
To get the detailed or full definition of function press ctrl + shift + i while focusing on the variable or function.
I just looked at one of my more complicated teaching examples with multiple header/source files where this would come up.
What I see is that ctl-click (and the red/green arrows in the gutter) does work only in the same file. But I can right-click on a method from another file and choose to go to either the declaration (in header) or definition (in cpp).
The hotkeys to do this are not ctl-click. But you can remap hotkeys in IntelliJ ides, so you may be able to come up with hotkey combinations that don't seem too awkward to you.
What helped me was to run File > New CMake Project from Sources
Until that point, Ctrl+click in CLion would go to the definitions, but wouldn't find any usages.

Extract the contents of cmd.exe IDE to a text file using autohotkey scripts

I am trying to extract the contents of cmd.exe IDE to a text file using autohotkey scripts ie one test.ahk and its written as shown below:
WinGetText, text, "C:\WINDOWS\system32\cmd.exe"
FileAppend, %text%, C:\ThreePartition\ACTUAL.txt
I am not able to extract the contents. Can anyone please suggest the correct way to do the extraction?
The text retrieved is generally the same as what Window Spy shows for that window.
The Window Spy shows no text elements for CMD windows - what you see is not necessarily what you can get :)
What you can do is to simulate the Select All and Paste commands, and then use the clipboard contents.
I don't believe you can extract the contents of a cmd window without somehow using DllCall to read the process memory directly.
If you just want the output of a CLI command such as Grep or AWK, using stdout via the run command should work. Honestly though, I stopped relying on AHK because this sort of thing is just too clunky.
http://www.autohotkey.com/docs/commands/Run.htm.
Edit for comments:
What you want is doable, but the solution depends entirely on how your IDE works. What behavior does it have that's unique to building a project? If it makes temp files, you can overload your "build" button with an AHK subroutine that watches for the existence of those files, and then checks the modified date of the output executable to see if the build succeeded. The same kind of solution works if the IDE changes its window title when building. Be clever. :)
Failing that, you might have to install a message hook.