RU/2: Форум. Общение пользователей и разработчиков OS/2 (eCS). : Ответить на сообщение
Имя:
e-mail:
FIDO:
Home page:
сохранить данные о вас
Тема:
> Thare are two books for this handling. A generel and best source for error handling in REXX is > > Charles Daney, Programming in REXX, > McGraw-Hill, 1992, ISBN 0-07-015305-1 > > and a special issue for exact handling the ERRORLEVEL conditions is > > Ronny Richardson, OS/2 Batch Files to Go, McGraw-Hill, 1994, ISBN 0070523703(paper) or 007052369X(hard) > > Both publications one can bay on ebay or abebooks.com after looking a while. > > Richardson writes:(Chapter 15 Errorlevel p.123-127) > > While a nice place for batch files, the environment(ENV) is a very inhospitable place for programs to store information so they can communicate with each other. Each program > is provided with a copy of the ENV when it's first loaded. > > When a program reads from or writes to the ENV, it's dealing with a copy of the > ENV and not with the original. When a program terminates, its copy of the ENV - along > with all teh changes the progarm made to it - are destroyed. > > The errorlevel (ERLV) value (also called a return code [of the batch program,GA] is > provided to overcome this problem. The ERLV is a single byte of memory that can contain > only a single character. Normally, the content of ERLV is referred to as an ASCII value > rather than a chracter representation. ASCII values 0-255 are therefore possible. > > How the ERLV works > > When a program terminates, it can store a number in the ERLV to indicate its status at > termination. When a program use the ERLV, thge usual rule is to set it to zero for a successful execution and to higher values for diffrent types of errors. > > The ERLV isn't stored in the ENV, so changes made to it aren't lost when a progarm terminates. Unlike the ENV, there's one one copy of the ERLV per session, and every program in a single session changes the same one. However, each different OS/2 session > has its own unique ERLV slot. > > The ERLV doesn't change unless a program chenges it, you start another program, or you > reboot, so you can perform multiple test on it. However, the ERLV is automatically reset > to zero by OS/2 each time you start a new program, so each time a program runs, the > prior ERLV value is lost. > > Under OS/2 you can reset the ERLV by running an internal command. This is not the case > under DOS and a few batch files migth not work properly as a result. > > !! > > Under OS/2, internal commands reset the ERLV to zero. This is not the case under DOS. As > a result, some batch files trnslated from DOS might need to be modified. > > You don't need the ERLV when running programs from the command line because you'll see any error messages. However, a batch file file won't "see" an error message, so the > ERLV gives it a way to respond to errors. > > OS/2 Errorlevel report > > OS/2 has eleven(11) commands that are documented to support the ERLV. They are BACKUP, CHKDSK, COMP, EAUTIL, FORMAT, GRAFTABL, RECOVER, REPLACE, RESTORE, UNAPCK, and XCOPY. [I will list only one part XCOPY. When another part is wanted, write it, GA] > > ERVL Meaning > > 0 Normal completion > 1 No files found to XCOPY > 2 Some files or directories weren't completed > 3 Ended by the user > 4 Ended beacuse of an errror > > OS/2 ha also a number of internal commands with undocumented ERLV supports. For example, the DIR command returns an ERLV of one if you use an invalid switch and an > ERLV of 18 if tit doesn't find the file you specify after the DIR command. .... > > To help you to experiment with the ERLV, os/2 includes a nice feature. Include a $R in > your prompt and your prompt will include the ERLV for the last command you issued. > Additionally, I've included a REXX programm called GET-ONE.CMD on the disk. This program > will take a single keystroke from the user and store its ASCII value in the ERLV. To turn > it from a batch file, use the command CALL GET-ONE and make sure teh program is either > in the current subdirectory or is in your path. > > Of course , it can also be run from the command line without the CALL command. > > /* Name: GET-ONE.CMD */ > /* PURPOSE: REXX Program To Get A Single Character From User */ > /* VERSION: 1.00 */ > /* DATE: May 30, 1993 */ > > CALL RxFuncAdd 'SysGetKey', 'RexxUtil', 'SysGetKey' > SAY "Enter A Single Character" > Character = SysGetKey(echo) > ASCII = C2D(Character) > Exit ASCII > > > > > >
_, _, _, _, _ _ _,_
(_ | / \ |\ | | |_/
, ) | , \ / | \| | | \
~ ~~~ ~ ~ ~ ~ ~ ~
Programmed by
Dmitri Maximovich
,
Dmitry I. Platonoff
,
Eugen Kuleshov
.
25.09.99 (c) 1999,
RU/2
. All rights reserved.
Rewritten by
Dmitry Ban
. All rights ignored.