Sorry if this is the wrong forum but I wanted to execute a cobol program based on input from the cmd process. Included in the cmd stream was set /P to obtain the name of the program. When I enter the info & press enter the cmd exits.
Simple example:
echo off
setactn=d
echo actn is %actn%set/Pactn="Enter letter "echo actn now %actn%
I expected that running this would allow me to enter a letter & press enter then display it, instead it simply terminates after pressing enter without the subsequent display of the entered letter.
Last edit: Simon Sobisch 2021-07-21
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
That's likely the wrong forum, I've moved that to the more general help forum.
It simply terminates because there is nothing in that prevents that. You may use a pause at the end for tests like this - or directly execute it from the cmd.exe to see the result - the display is just too fast.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks Simon. Your explanation is obvious once I think about it, just didn't see it for what it, in retrospective, obviously is.
Thanks also for moving it. I'm new to the forum & am having some difficulty finding my way round -- I'm an old machine code man from the early 60s and find these modern new-fangled machines difficult!
Alan Darlington
Last edit: Simon Sobisch 2021-07-21
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Simon,
Can you help me? When I log on to sourceforge I go to https://sourceforge.net/. How do I get from there to post or view a
discussion thread or to change from one forum to another? (I somehow
managed to post the one discussion you answered but I've no idea how I
got there).
I have another item I'd like to post on General (though you could answer
it here to avoid my embarrassment): Why does this not work:
the problem is the if statement but I don't know what is wrong with it.
Without the if it produces the expected step1, step 2 & step6 displays,
with the if it doesn't reach the pause so just flashes the a screen at
me (like my previous question).
Thanks
Alan Darlington
Last edit: Simon Sobisch 2021-07-22
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Note: when answering to items on SF that you've subscribed to (you can turn that globally / per item on/off) those get posted to the item as answer - and each of those mails have a link to the item in it, so you can get there fast.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
You could have a look at two samples from GC on how to write cmd scripts if you want to, while those aren't written as tutorials they may still give you some hints:
Found the answer -- the problem is the if statement. the action to be taken (echo step 2) must appear on the same line as the if (though one could use just an open bracket on that line & closing after the echo step 2 on the next). (The changes made by anonymous still cause failure - at least on my system.) (If you type it in one line at a time into cmd you get a syntax error when you type in the if %actn%==1.)
I still have not found out how to change forums or to add a new discussion -- help please.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
No idea why you are getting syntax errors.
What OS are you using.
This language dates back to the old PC-DOS days, and is rarely used now days.
It is really just a poor attempt to implement a UNIX like shell language, such as BASH, on DOS.
On the menu at the top (below the logo) you can access the different "tools"; some of those have multiple sub-tools like the tickets.
On the left you find the menu for the current "tool", in this case the different forums to browse, and also the option to search all forums and to create a new topic.
In one of the responses Simon moved my question to the general forum. But I don't see a 'general' forum listed in the left hand panel -- how do I access it?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
There are only four forums that I know of, and they are named "Help Getting Started", "GnuCOBOL", "Contributions", and "The Lounge".
I'm not sure which one Simon means by "general", but it's easy to check all four forums. "Help Getting Started" and "Contributions" seem to have fairly specific purposes.
Sorry if this is the wrong forum but I wanted to execute a cobol program based on input from the cmd process. Included in the cmd stream was set /P to obtain the name of the program. When I enter the info & press enter the cmd exits.
Simple example:
I expected that running this would allow me to enter a letter & press enter then display it, instead it simply terminates after pressing enter without the subsequent display of the entered letter.
Last edit: Simon Sobisch 2021-07-21
That's likely the wrong forum, I've moved that to the more general help forum.
It simply terminates because there is nothing in that prevents that. You may use a
pauseat the end for tests like this - or directly execute it from the cmd.exe to see the result - the display is just too fast.Thanks Simon. Your explanation is obvious once I think about it, just didn't see it for what it, in retrospective, obviously is.
Thanks also for moving it. I'm new to the forum & am having some difficulty finding my way round -- I'm an old machine code man from the early 60s and find these modern new-fangled machines difficult!
Alan Darlington
Last edit: Simon Sobisch 2021-07-21
Simon,
Can you help me? When I log on to sourceforge I go to
https://sourceforge.net/. How do I get from there to post or view a
discussion thread or to change from one forum to another? (I somehow
managed to post the one discussion you answered but I've no idea how I
got there).
I have another item I'd like to post on General (though you could answer
it here to avoid my embarrassment): Why does this not work:
the problem is the if statement but I don't know what is wrong with it.
Without the if it produces the expected step1, step 2 & step6 displays,
with the if it doesn't reach the pause so just flashes the a screen at
me (like my previous question).
Thanks
Alan Darlington
Last edit: Simon Sobisch 2021-07-22
Looks like you want to go to https://sourceforge.net/p/gnucobol/discussion/
Note: when answering to items on SF that you've subscribed to (you can turn that globally / per item on/off) those get posted to the item as answer - and each of those mails have a link to the item in it, so you can get there fast.
Some minor changes :
CMD script is crude and cumbersome, on Win rarely used now days.
I would recommend you try busybox-w32.
This gives you the power of BASH, a UNIX shell script, on the Win platform.
You could have a look at two samples from GC on how to write cmd scripts if you want to, while those aren't written as tutorials they may still give you some hints:
Found the answer -- the problem is the if statement. the action to be taken (echo step 2) must appear on the same line as the if (though one could use just an open bracket on that line & closing after the echo step 2 on the next). (The changes made by anonymous still cause failure - at least on my system.) (If you type it in one line at a time into cmd you get a syntax error when you type in the if %actn%==1.)
I still have not found out how to change forums or to add a new discussion -- help please.
Using WINE, I did a test run without any errors.
New code :
Your original code with echo on :
No idea why you are getting syntax errors.
What OS are you using.
This language dates back to the old PC-DOS days, and is rarely used now days.
It is really just a poor attempt to implement a UNIX like shell language, such as BASH, on DOS.
A web search on 'dos command tutorial' yields Topic: MS-DOS Tutorial among others.
On the menu at the top (below the logo) you can access the different "tools"; some of those have multiple sub-tools like the tickets.
On the left you find the menu for the current "tool", in this case the different forums to browse, and also the option to search all forums and to create a new topic.
In one of the responses Simon moved my question to the general forum. But I don't see a 'general' forum listed in the left hand panel -- how do I access it?
There are only four forums that I know of, and they are named "Help Getting Started", "GnuCOBOL", "Contributions", and "The Lounge".
I'm not sure which one Simon means by "general", but it's easy to check all four forums. "Help Getting Started" and "Contributions" seem to have fairly specific purposes.
The "general help" forum I've referenced is the "Help getting started" one.