Compiling pascal program in Visual Studio Code for Linux - linux

Recently, I switched my OS to Ubuntu. I just started with collage and I have to learn pascal for my finals. But a problem occurred.
I installed Visual Studio Code and Pascal extension for it, but I am unable to run even a simple Hello World code. I wrote code, it saved automatically as .pas, but when I enter debug & run option in VSC it displays a message that says 'Open a file which can be debugged or run.', followed by 'debug' and 'run' buttons that I am unable to click and another message that says 'To further configure Debug and Run create a launch.json file.'
I am not even sure am I supposed to post questions such as this one on stackoverflow, but I sincerelly hope that someone could give me a hint on what to do. Solve this within Visual Studio Code or switch to another IDE (and which one would you recommend for Linux user) and pretend that nothing happened?
Thanks in advance.

I know this isn't an answer to "how to debug with pascal with vscode" but, perhaps you would find it easier to just use FPC / Lazarus (IDE) to do your work. While it doesn't have a dark theme, contrary to popular belief, that's not necessary to program.
The IDE is feature packed and allows for full code completion, debugging, etc... (everything you really need to do the work for school).
Additionally, you can use this open source tool to install everything you need for your platform in just a few button clicks (also allows for installing common library packages)
https://github.com/LongDirtyAnimAlf/fpcupdeluxe/releases
download release for your OS
under "FPC Version" & "Lazarus Version" select trunkgit (or stable for an older version)
click the "Install/Update FPC + Lazarus" button

Have you Installed Pascal extension which is available for code to smoothly run pascal code.
If you haven't then try installing this extension using,
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
ext install alefragnani.pascal
You can always check,
https://marketplace.visualstudio.com/items?itemName=alefragnani.pascal
to install and configure pascal in vscode.

I will direct you to the debugging page from the Visual Studio Code documentation that details how to use the debugger and configure a launch.json file. VSCode is a generic IDE so you need to give it some information about your project before it knows how to run the debugger. This is what launch.json is for.
If I could make a suggestion. When you're learning how to program, it's best to start with the basics. Write a small program in a text editor (VSCode is fine, or Vim, or Nano, or Notepad, or whatever). Save the file. Compile and run the program on the command line.
Once you put an IDE in the mix, you have to learn how to use that as well. If you're stuck on both parts, it can be hard to make progress. That said, it's good to learn how to use the IDE, and you should spend some time reading the documentation and working through some of the examples. It takes some time, but it will pay you back a thousand times when you can work more quickly.

Related

"Run|Debug" Buttons Not Appearing on Visual Studio Code Java Programs

A couple days ago I tried to initialize Visual Studio Code to be able to code in C++ using online instructions. They ended up not working at all, but I had edited some settings files (such as a .json file) in Visual Studio Code that I thought were all C++ specific. Afterwards, however, I no longer have the convenient "run | debug" buttons appearing above any "main" functions that I make in java files. In the past I used to be able to just click run and my program would run in the terminal at the bottom of the screen, as opposed to manually compiling and running the program using a terminal. I am running Windows 10. Does anyone know of any way to get these buttons back?
This is an example of what the two buttons look like, appearing above any main functions in a java program.
I also found on the Visual Studio Code website a description of how to begin debugging, attached here, that describes that you need Language Support for Java(TM) by Redhat in order to get these two buttons. I have this extension downloaded, but it is still not working. Please help if you recognize this issue!
What worked for me:
Make sure you have Java extensions, Java Debugger and other basic Java packages installed.
Then making sure the main function is formatted properly like below allowed the Run|Debug buttons to be seen.
public static void main(String[] args) {}
First of all, for troubleshooting, actually we need to have a reproduce steps which can understand what happened in your environment. So can you tell us what you have done to your settings first?
Second, there is a setting under common setting tab, that is Java>Debug>Settings>Enable Run Debug Code Lens. Please check whether this option has been unchecked. Although I think it should not be changed by you.

How to debug Android Studio Project (using NDK and JNI) line by line to see the workflow?

I was using Visual Studio and it's Debug mechanism is really useful to me. With many header and C files in 1 project, just a simple F10 it could take me a tour around from the beginning of the main() function so that I could see the sequence of the code being executed.
Now I'm jumping into Android Studio and start with a project using NDK, JNI (this project for example: https://github.com/googlesamples/android-ndk/tree/master/gles3jni), it makes me confused because there're many .java files and others C++ (native code) files and I don't know which code from which file is executed first and how it goes on.
My Question is: I'm looking for a way to debug in Android Studio line by line from the beginning to see its workflow likes how Visual Studio did but all I got from searching is how to start from a breakpoint when debugging.
I have tried putting the break point in the onCreate() method of the launcher activity and use F8 to Step Over and F7 to Step Into but it doesn't work as i expect. It keeps taking me to the super class Activity.java and GLSurafaceView.java instead of taking me to the C++ code. Is there any way to do so in Android Studio and how to do it?
I have tried with others project but the problem still remain the same. Hope someone could help.
This won't happen. Your app (the Java boilerplate code) is set to respond to many system events that happen when the user works with the app and the device on which the app is installed. If your c++ code is a piece of monolythic straightforward algorithm, you can set s breakpoint in the beginning and really follow step by step. But with Android Studio, even this process is not as easy as with Vusial Studio. To begin with, it's always remote debugging, dependent on delicate communication protocols.
This said, you can try to set up Microsoft Visual Studio as your IDE for debugging native Android code. It is surprisingly robust, and also may be more familiar to you.
Since you've asked about Android Studio, I will answer about that - I am not familiar with Visual Studio for Android and perhaps it is better for what you are asking.
In Android studio such debugging is very hard - although some people said they managed to get it to work, I wasn't able to. Especially in a complex environment. So, what I'm doing is extensive logging, with as many details as possible, and visual debugging - put some text view on the screen and update it with the info you need. This could be quite powerful in some cases. Or, alternatively, make some changes in your ui or your scene as a result of certain conditions you define - so you could see the visual effect. Again, much less useful than debugging, but can still be quite powerful.

Trying to get customization of Sublime Text 3 Build system to work

Does anyone know how automatic build systems work in 3083 right now? Because I am struggling to get it to do the right thing. (p.s. I am not an expert st3 customizer so I am probably just doing it wrong.)
My TypeScript.sublime-build file lives in ../Packages/User and contains:
{
"cmd": ["/usr/local/bin/tsc"],
"file_regex": "^(.+?) \\((\\d+),(\\d+)\\): (.+)$",
"selector": "source.TypeScript"
}
When I edit a .ts file the syntax highlighting is for TypeScript and that is also what is displayed in the bottom right corner. So from that I deduce that ST3 is correctly identifying the desired syntax for the file (although I am not sure where that happens.)
When I choose the TypeScript build system by hand and click CMD-B it runs the build and displays the output in the console, as I expected.
When I have "automatic" build system and I open a .ts file or change to a .ts file that was already open, ST3 again correctly identifies the syntax (bottom right in the window.) However when I click CMD-B it runs the last build method that I happened to have used.
I thought that the idea with automatic is that it would choose the build system based on the syntax identified via the file extension.
Does anyone understand this problem or correct my assumptions?
Never figured out the problem. But I fully uninstalled ST3 and reinstalled it, with the package control and typescript packages and nothing more, and now it seems to work. Oh well. I guess not all the bugs are out yet.

Python IDLE GUI not starting

I feel like I have been coming the internet for days with absolutely no result.
I have taken some web programming classes, and would like to learn some python, just because programming is wicked interesting altogether, and have run into a fairly large hurdle given my experience.
the problem is this: Python.exe (or is is more properly pythonw.exe?) v3.3.3, running on windows 8.1 used to launch fine. Typed up a simple program to roll various sided die, worked out well. Then I changed the key bindings for 'Run Module' from 'ctrl+f5' to 'crtl+alt+spacebar.'
As soon as I did this IDLE crashed and so did the shell. Now the process will not run AT ALL. I cannot access it through the desktop icon to go back and revert the settings. I also attempted to look at the .def files and change it from there but could not find the 'run module' command. It looked like all the key bindings in the .def files were for the shell.
When I double click, nothing, when I run as admin, nothing. run from the start menu, nothing. I uninstalled and re-installed, rebooted, everything low tech I can think of. Now i'm out of my element and could use one of you brilliant social programmers!!
I've found information about checking with some tool called 'Windows Process Manager' some stuff about what to do with the CMD prompt (something about a path problem ...it intuitivly sounds like I very well could have created a 'path problem' but I'm not 100% I know what that is exactly).
I'm sorry for the lack of links, the pages were farther back in my browsing history than I expected. Hopefully i'm not asking an instant many down vote question here, most of the resources online are for either an older version of windows, Lunix, or an older version of python (which is actually where the path problem hint came from)
Thanks any and all greatly for any time spend reading/answering.
Immensely appreciated.
Find file HOME/.idlerc/config-keys.cfg, where on Win7 HOME would be 'C:/Users/yourloginname', and delete the key binding or, if there is nothing else in the file or nothing you want to keep, the whole file.
If you were to run Idle from a console with python -m idlelib, you would probably see an error message. (Yes, you were probably running with pythonw, as when using the start menu or icon. This works better in 3.4.2 and I am working or more improvements.)
I do not know the specific reason for your crash. I set Zoom-height to --space, restarted, and it works, no problem.

Vim as Visual Studio IDE

I have spent lot of time doing research on VIM. I am Windows guy since last 6 yrs and was using VS.
Now started working on Linux. I want to make VIM as close as possible to VS.
I want features like
Project Navigation
Files in Different Tabs
Search in Project
AutoCompletion
I have found plugins for the above requirements
Project Pligin
MiniExplore
Taglist
OmniComplete
I am not able to correctly set vimrc script.
When I try to open file from Project it gets open in different tabs.I want to get it open in different buffers.
Also when I want to close file in buffer , complete window gets closed.
Open taglist and project window makes all mess.
Has any one done settings with these plugin..
Could you guys please post your vimrc files??
It will save lot of time for newbies like me..
Vim is a very different tool than Visual Studio. Plugins may help you get certain bits of functionality you desire, but do not expect them to work exactly like VS, work well together, or even work at all.
If you are looking for a programming environment more like Visual Studio, there are many good graphical IDE's you can use such as NetBeans, Eclipse, Code::Blocks, KDevelop, Anjuta, etc. Some of these tools are, IMHO, better heavyweight IDE's than Visual Studio, and all are available on Linux for free.
You should either learn to use Vim the way it was built to be used, or find a different tool that suits you better. Shoehorning Vim into a surrogate for Visual Studio will probably cause you more pain than it's worth.
Yes it's different to VS, but that doesn't mean it can't be used in the same way. It's just not as easy to do it :)
Personally I go the other way and use ViEmu to get VS to behave like VIM. But I'm not in the same situation as the author of this question.
Why not have a dig through some uploaded vimrc files on dotfiles.org?
You can use the following script, Trinity.
http://www.vim.org/scripts/script.php?script_id=2347
It will require 3 more scripts, and Vim will look like an IDE.
The TagList at left, a file exporer (NERDTree) at right, and Source Explorer at bottom.
Also, you can find some very useful blog entries at
http://kevin-berridge.blogspot.com/search/label/vim
The author, Kevin, explains how to compile solutions form inside Vim. He also shows interfacing and jumping between them which is very useful too.
Furhermore, there is the script vim-visual-studio which can be found at
http://code.google.com/p/vim-visual-studio/
This script is using Python extension. I have Python 2.5 installed in Windows. I am using Gvim 7.2 which is compiled with Python 2.4. So, I have replaced the executables of Gvim as explained here:
http://www.gooli.org/blog/gvim-72-with-python-2526-support-windows-binaries/
So, Gvim became compatible with Python 2.5 and raised no problems. Also, a menu entry "Visual Studio" has appeared as expected. It connects to Visual Studio itself, and it works perfectly. It does not just compiles a file, it can compile a solution containing more than one project as in Visual Studio. You can even use the Vim's 'quickfix' feature. Hope this helps.
If you really want to have vim as the front end, try Eclim. It uses Eclipse as a backend daemon for code completion and project management, and vim as the interface.
If you only like vim because of the vi key bindings, but want it to be more IDE like, you could try the latest MonoDevelop that has it built in.
These plugins used to exist long before vim had tabs. I'd be quite surprised there isn't a way to tune these plugins to split windows instead of opening tabs.
Now I can't help you much as I don't use these specific plugins but other ones. You should look at their help (:h project, :h taglist, etc)
PS: in vim terminology (it will help you browse the help files), what you call "buffer" is actually called "window", while a "buffer" is just the text you are working on, it may be associated to a file, or not. For a given buffer, there may be no or several window displaying parts of the buffer.
you can give a try to eXvim
http://code.google.com/p/exvim/

Resources