jump in a .KSH batch

hi everyone,
i need to know if is that possible insert in a batch KSH a "GO TO" sentence to jump at the top or at the end of the job.

e.g.

top:
step1
step2
go to top:

thanks in advance

perhaps

run=1
while [ $run -eq 1 ]
  do
  step1
  step2
done

and, at either/both step1 & step2, you could change the vaule of the run variable so the loop stops running.

great!

can i set the value of the run variabile via cobol program?

#

# - program execution-

CntlDebug AFG21002

if [ $? -gt 0 ] ; then

anim $preflnk/sgpdx3

else

cobrun $preflnk/sgpdx3

fi

if [ $? -gt 0 ] ; then

Exitko

return 1

fi

The "$?" is a special variable called "Error code" or "Error level". It is an (unsigned short) integer value. A value of "0" (which also happens to be a logical "TRUE" in "if"-conditions) is considered to mean "normally finished program", every code other than that means one of several erroneous conditions.

Try it yourself:

cat /some/existing/file >/dev/null ; echo $?        # will print "0"
cat /some/non-existing/file >/dev/null ; echo $?    # will print "1"

The output of "cat" is directed to /dev/null (the "black hole" of the OS) so you won't notice its operation. It still gives back an error code to the OS when it terminates and this is what you see with "echo $?". The "1" in the second case is because "cat" cannot find the file you are asking it to print.

Having said this: Yes, you can use this mechanism to pass messages to your calling program. As COBOL is a compiled language you will have to use the exit()-systemcall, which will take an (unsigned integer) value, which will be passed as error level.

You can NOT pass arbitrary messages (like text, etc.) via this mechanism, so the functionality is quite limited. If you want to pass longer output to other programs you should not use this mechanism anyway, but other means like writing to <stdout>. If you write to <stdout> you can use the pipeline construct to pass input to another program, which will read it from its <stdin>.

program1 | program2

Means simply that "program1" creates some output. This output could go into a file, a device, whatever. "program2" gets its input from <stdin>. Normally this will be you typing away, it could also be a file, a device, etc.. In this special case the OS is connecting <stdout> of "program1" with <stdin> of "program2" this way establishing a (one-way) communication. So in fact the pipeline can be thought of a shortcut to:

program1 > file
program2 < file

just without the intermediary file in between. Notice, btw., that the error code of a pipeline is always the error code of the last command. If in our example program1 returns "0" and program2 returns "1" then "$?" would yield "1". In the second example with the intermediary file you could separately get the the error codes of program1 and program2, but i get carried away....

I hope this helps.

bakunin

just what i'm looking for .... thanks a lot.