1748074 Members
5227 Online
108758 Solutions
New Discussion юеВ

Vms DCL Code

 
SOLVED
Go to solution
Steve ward_3
Advisor

Vms DCL Code

I have a com file that prompts user to put in # of day to generate a speicific report. The problem is when a user puts in 500 days the code loops.

Ex. Enter # of Days >

How can I limit the number of days requested to a maximum value of 31 or 365 or whatever.

What would the DCL code be for this?
15 REPLIES 15
Steven Schweda
Honored Contributor
Solution

Re: Vms DCL Code

> The problem is when a user puts in 500
> days the code loops.

What code? I see no code. Perhaps someone
with psychic powers greater than mine could
tell you why "the code loops".

HELP IF
Hein van den Heuvel
Honored Contributor

Re: Vms DCL Code

It would help if you had showed us how the input is being aquired in teh first place.
Command line argument? From terminal?

Here is an example of a value checking read loop:

$MIN_DAYS = 31
$MAX_DAYS = 365
$read_days_loop:
$READ/END=done/PROMPT="Enter # of Days > " SYS$COMMAND days
$IF F$TYPE(days).NES."INTEGER" -
.OR. days.LT.MIN_DAYS -
.OR. days.GT.MAX_DAYS
$THEN
$ WRITE SYS$OUTPUT "Please enter a NUMBER from ''MIN_DAYS' to ''MAX_DAYS'"
$ GOTO read_days_loop
$ENDIF
$
$ WRITE SYS$OUTPUT "Processing ''days' days."
$ GOTO read_days_loop
$
$done:
$ WRITE SYS$OUTPUT "Bye now."

hth,
Hein.


Andy Bustamante
Honored Contributor

Re: Vms DCL Code


You might consider the book, "Writing Real Programs in DCL." http://www.alibris.com/search/books/qwork/8739673/used/Writing%20Real%20Programs%20in%20DCL

Although out of print, it can still be found.

Andy
If you don't have time to do it right, when will you have time to do it over? Reach me at first_name + "." + last_name at sysmanager net
Robert Gezelter
Honored Contributor

Re: Vms DCL Code

Steve,

There are two questions here.

First, the syntax of an IF statement in DCL. This is covered in the "DCL Dictionary", in the standard documentation library, available on the HP OpenVMS www site at http://www.hp.com/go/openvms , and is documented in the online HELP text.

The short answer to that question is something along the lines of:

$ IF (days .ge. 500) then $ xxx

There are several variants that may be appropriate, depending on what is written in the command file already.

There is a second question, namely, WHY is the command file failing? Also, "At what point does the command file fail?". This, IMHO, is a more serious problem. Generally, I recommend careful investigation of this type of question, as it often uncovers far more serious problems.

I hope that the above is helpful.

- Bob Gezelter, http://www.rlgsc.com
Steve ward_3
Advisor

Re: Vms DCL Code

Here is the code
Barry Alford
Frequent Advisor

Re: Vms DCL Code

(Simple solution)
After the line:

$ if f$type(date) .nes. "INTEGER" then goto detail

insert a line:
$ if date .gt. then goto detail

...where is the desired maximum days
jf Marchal
Senior Member

Re: Vms DCL Code

Having replaced the search instructions by a search in a dummy file, I have tested your procedure with no loop occuring.

Maybe you could "set verify" your code and attach the output of the run ?

Jean-Francois
Wim Van den Wyngaert
Honored Contributor

Re: Vms DCL Code

It's when you enter a number bigger than 9999 that it will go wrong.

f$cvtime("-''date'-00",...
will display errors for values bigger than 9999 and this will look like it's looping on an error.

fwiw

Wim
Wim
Steve ward_3
Advisor

Re: Vms DCL Code

(Simple solution)
After the line:

$ if f$type(date) .nes. "INTEGER" then goto detail

insert a line:
$ if date .gt. then goto detail

...where is the desired maximum days

Yes, When I put in 31 days for the max and type in 32 it just hangs there? Shouldn't it just exit or prompt me to put in the right # of days again?