cobol "hello world" get error when using visual code with terminal - visual-studio-code

So I'm starting to learn COBOL, tried my first "hello world" program, and got an error that I can't solve.
this is the code:
*hello
IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO.
ENVIRONMENT DIVISION.
PROCEDURE DIVISION.
DISPLAY 'HELLO'.
STOP RUN.
I'm using vs code with extensions that talk with gnucobol(openCobol), did that with the help of this video (using windows). When I'm running the code, I get this message:
hello.cbl:1: error: PROGRAM-ID header missing
I've tried to copy the code from a few other sources that have an example code but still got this message.
I would appreciate any help.

It might help you to see what your code looks like in a purpose-made IDE for COBOL. Here is a direct copy & paste of your code in OpenCobolIDE:
The main issue is the position of the code on lines 2 through 5. COBOL generally will require your code to be very specifically formatted, as you can see from the red lines above, there are limits to where data should exist. This can be changed, but I recommend keeping with it as this may increase your comfort in working with the legacy code that runs the world. Here is an example of how this should be written. I will share both a picture and the code itself so you can see where it is in relation to those red lines.
Code with errors still to show as an example:
IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO.
DATA DIVISION.
FILE SECTION.
WORKING-STORAGE SECTION.
PROCEDURE DIVISION.
*this is a comment
*this is not a comment
MAIN-PROCEDURE.
DISPLAY "Hello world!"
DISPLAY "This display line is too long, creating the same issue but on the other side"
*STOP RUN has an error because the above line was cut off inappropriately
STOP RUN.
END PROGRAM HELLO.
Working code with no errors:
IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO.
PROCEDURE DIVISION.
*this is a comment
MAIN-PROCEDURE.
DISPLAY "Hello world!"
STOP RUN.
END PROGRAM HELLO.
Definitely check out OpenCobolIDE which is a great free IDE for getting started with COBOL and getting the basics down! It helped me to get a better handle on formatting when I was new.

Related

netbeans outputs the results my code incorrectly

So I downloaded and installed netbeans because my community college used to require it and now I am most comfortable using it rather than other programs.
But whenever I run a program, in the output box, it shows something like
PID=50
TTY=/dev/pt y0
PSID=50
NBMAGIC=49
and then show the output of my program.
And often, it doesn't completely show the output at all.
Like if the output is "Hello World,"
sometimes it just outputs "H" (even when my code is correct)
then after running program again (no change in the code) it shows "Hello World"
Does anyone know how to fix this?

How to execute functions in Live editor in MATLAB

I recently started using Live editor in MATLAB and I inserted a function inside it. But, apparently, I cannot execute that particular section of code where I type function. Even the section break disappears.
Is it that using function is not suitable for live editor?
Apparently the MATLAB parser did not join the 20th century until partway through 2016, and could not interpret function definitions in scripts (live or otherwise) until R2016b. In the web-based docs, there is a notice at Add Functions to Scripts, but it took me a while to find this out because the builtin docs in R2016a or earlier do not explicitly contain this information. It is implied by the tutorials that tell you to create a new file for each function (which to me, a python programmer, sounds more like strange advice than a restriction).
Trying to define a function in a live script gives confusing errors. For example, if you create a cell with this content:
function y = myfunc(x)
y = 2*x;
end
It will underline the keyword function with a popup error that reads:
Parse error at FUNCTION: usage might be invalid MATLAB syntax.
Might be? Whom shall I ask? Upon running the cell, it prints an error after the first line:
All functions in a script must be closed with an end.
I eventually made this discovery myself thanks to a helpful message if the first thing you happen to do in a new empty live script is to start typing function on the first line; as soon as you hit the spacebar a message pops up at the top saying:
Functions and classes are not supported in the Live Editor. To continue, save the file as a plain text code file (.m).
It should work as when you add a function inside a script. For example, like this:
What function are you exactly trying to code?

Trouble Understanding eval with base64 obfuscation in Perl

I'm doing my first CTF and I've come across unfamiliar territory. I've never used Perl and after about 5 hours doing this, I'm a little burnt.
Code here:
https://gist.github.com/anonymous/8d738e7d83c42c758de6514ce258327a
So far, I've gone through and figured out what input is needed for each if statement. I have commented the inputs with the sections they're used in. Ultimately, when I run the program with these inputs it is fine until line 191. When I get to that final answer block, I'm just stuck with a blinking cursor. When I enter any text, I hit the final else block and exit the program.
I believe that I need further input and that there may be further evaluation happening in eval(), but I'm not sure.

Execute Commands in the Linux Commandline [Lazarus / Free Pascal]

I have a problem. I want to execute some commands in the Commandline of linux. I tested TProcess (So i am using Lazarus) but now when i am starting the programm, there is nothing, wich the Program do.
Here is my Code:
uses [...], unix, process;
[...]
var LE_Path: TLabeledEdit;
[...]
Pro1:=TProcess.Create(nil);
Pro1.CommandLine:=(('sudo open'+LE_Path.Text));
Pro1.Options := Pro1.Options; //Here i used Options before
Pro1.Execute;
With this Program, i want to open Files with sudo (The Programm is running on the User Interface)
->Sorry for my Bad English; Sorry for fails in the Question: I am using StackOverflow the first time.
I guess the solution was a missing space char?
Change
Pro1.CommandLine:=(('sudo open'+LE_Path.Text));
to
Pro1.CommandLine:=(('sudo open '+LE_Path.Text));
# ----------------------------^--- added this space char.
But if you're a beginner programmer, my other comments are still worth considering:
trying to use sudo in your first bit of code may be adding a whole extra set of problems. SO... Get something easier to work first, maybe
/bin/ls -l /path/to/some/dir/that/has/only/a/few/files.
find out how to print a statement that will be executed. This is the most basic form of debugging and any language should support that.
Your english communicated your problem well enough, and by including sample code and reasonable (not perfect) problem description "we" were able to help you. In general, a good question contains the fewest number of steps to re-create the problem. OR, if you're trying to manipulate data,
a. small sample input,
b. sample output from that same input
c. your "best" code you have tried
d. your current output
e. your thoughts about why it is not working
AND comments to indicate generally other things you have tried.

Is it possible to figure out which if statements are being fufilled in matlab

I have a lot of if statements throughout my code and was wondering if there is anyway in Matlab to see which if statements are being used when I run my code. I know I could put variables throughout my code and see which ones are being triggered, but I was wondering if there is an easier way. Maybe a built in MATLAB function or something.
Thanks
Type profile viewer in the command line of matlab and execute your code from there. There you can see in the profile report how many times each line is called as well as how long it takes executing the line of code.
More information:
http://www.mathworks.nl/help/matlab/ref/profile.html
http://www.mathworks.nl/help/matlab/matlab_prog/profiling-for-improving-performance.html
To answer precesely to your question, there is a command to log every line the execution is going through. And if you're familiar with unix-like platform, it is the same command: echo. See the Matlab help of echo to see how you can use it. For example, echo on all sets echoing on for all function files.
Besides that, I advise you two things better than analysing the output of echoing a whole script:
look at every warning in the code editor, and apply meaningful corrections.
use the profiler of matlab, as stated in the answer from EJG89, it is indeed a powerful tool!