VAX VMS DCL CODE


$! o All files MUST end in ".COM"
$! o All lines START with DOLLAR
$! o Comment lines have EXCLAMATION(!) immediately AFTER
$!   the DOLLAR (as with these first ELEVEN lines)
$!#d# Comment lines are for Self Documenting only
$!#d# those lines having "$!#d#"
$! o Paragraph names start IMMEDIATELY after the dollar
$!   AND end with a colon, as follows
$!            $PARA_NAME:
$! o Code MUST have a space between dollar and 1st digit
$!            $ SYMBOL1 = "value1"

$! o Next says IF there IS a FIRST parameter, then SET
$!   the value to the symbol PID
$!   (If this was run as     NAME.COM test
$!    then P1 is "test", so set PID to "test")
$ IF P1.NES."" THEN PID = P1

$! If user presses  goto paragraph ABEND
$ ON CONTRL_Y THEN GOTO ABEND

$! If an error occurs, goto paragraph "ERRORON"
$ ON ERROR THEN GOTO ERROR_ON

$! Initiate symbol SHOWME to "AbCdEfG"
$ SHOWME = "AbCdEfG"

$! Extract 1st 2 digits of SHOWME into EX1
$! (
$ EX1 = F$EXTRACT(0,2,SHOWME)

$! o Next removes symbol SYS
$ DELETE/SYMBOL SYS

$! o Next extracts first 11 digits from the system date
$!   into symbol RDTE
$ RDTE = F$EXTRACT(0,11,F$TIME())

$! o Shorten code used to output to screen
$ WSO := WRITE SYS$OUTPUT

$! o Ask for/put into symbol GETTY
$ INQUIRE GETTY "What is your name"
$! o Display it on screen 
$ WRITE SYS$OUTPUT "Hello, ''GETTY', how are you?"
$! o Display it on screen using WSO as described earlier
$ WSO "Hello, ''GETTY', how are you?"

$! Geting length of a symbol GETTY contents
$! LNAM=F$LENGTH(GETTY)

$! --- READING A FILE --------------------------------------------------
$! o Get the name of an existing  file to read
$ INQUIRE FTR "Enter the FILE to examine"

$! o Set a counter to zero
$ CTR=0
$! o OPen the file for read access (IFILE is user defined name)
$ OPEN/READ IFILE 'FTR'
$! o Define a paragraph to return to after each line is READ
$READFIL1:
$! o Next says to read file IFILE putting each line read into symbol
$!   INLINE, and at end of file goto paragraph named CLOSEFILE
$ READ/END_OF_FILE=CLOSEFILE IFILE INLINE
$! o If NOT end ogf file, add 1 to CTR 
$ CTR=CTR+1
$ GOTO READFIL1

$! o Next is the close file paragraph, followed by the actual
$!   command to close the file, followed by printing to the screen
$!   how many lines were in the file
$CLOSEFILE:
$ CLOSE IFILE
$ WSO "   ]]] FYI: File ''FTR' has ''CTR" lines in it"
$! ---------------------------------------------------------------------
$! To open a file to write to use   OPEN/WRITE NEWFILE 'FILESPEC'


$! o Examples of STRING comparison "EQUAL TO"
$ IF P2.EQS."6"
$    THEN
$    GOTO DO_OPCO
$ ENDIF

$! o Examples of STRING comparison "NOT EQUAL TO"
$ IF RCDE.NES.ACDE THEN GOTO OPEN_PLANT

$! o Example of "OR" with STRING COMPARISONS
$ IF ((P2.EQS."4").OR.(P2.EQS."5").OR.(P2.EQS."1").OR.(P2.EQS."2"))
$    THEN
$    GOTO ALL_OK
$ ENDIF

$! o Examples of NUMERIC comparison EQUAL TO
$ IF ACTR.EQ.1 THEN GOTO OPEN_PLANT
$!   Others are   .LT.   LessThan      .LE.   LessThanOrEqualTo
$!                .GT.   GreaterThan   .GE.   GreaterThanOrEqualTo

$! o Example of going to a subroutine named POUT
$ GOSUB POUT
$ GOTO BYPASSIT

$! --- EXAMPLE OF A SUBROUTINE ---------------------------------------
$POUT:
$ LCTR = LCTR + 1
$ WRITE DECFILE PLINE
$ RETURN
$! -------------------------------------------------------------------

$BYPASSIT:
$! o Next gets characters 0-25 from MEMLINE into CH25
$ CH25 = F$EXTRACT(0,25,MEMLINE)
$! o Next removes leading/trailing spaces from CH25 into PNAM
$ PNAM = F$EDIT(CH25,"TRIM)

$! o Next does SAME as ABOVE but in ONE line with one LESS symbol
$ PNAM = F$EDIT(F$EXTRACT(0,25,MEMLINE),"TRIM")

Return to Randys HOME PAGE
Created Mar 18, 1996 ~ Updated: Aug 09, 1996
© 1996 R.D.RISHER