vmsdcl

dcl verify specific lines in DCL


Using DCL, i have a .txt file with 3 lines

Line 1 test.
Line 2 test.
Line 3 test.

I'm trying to very that each contains exactly what is expected. I'm currently using the f@extract function which will give me the output of line 1 but i cannot figure out how to verify line 2 and 3. What function can i use to make sure lines 2 and 3 are correct?

$ OPEN read_test test.dat
$ READ/END_OF_FILE=ender read_test cc
$ line1 = f$extract(0,15,cc)
$ if line1.nes."Line 1 test."
$ then
$    WRITE SYS$OUTPUT "FALSE"
$ endif
$ line2 = f$extract(??,??,cc)  ! f$extract not possible for multiple lines?
$ if line2.nes."Line 2 test."
$ then
$    WRITE SYS$OUTPUT "FALSE"
$ endif

Solution

  • For exactly 3 line you might just want to do 3 reads and 3 compares...

    $ READ READ/END_OF_FILE=ender read_test cc
    $ if f$extract(0,15,cc).nes."Line 1 test." ...
    $ READ READ/END_OF_FILE=ender read_test cc
    $ if f$extract(0,15,cc).nes."Line 2 test." ...
    $ READ READ/END_OF_FILE=ender read_test cc
    $ if f$extract(0,15,cc).nes."Line 3 test." ...
    

    Any more and you want to be in a loop as replied. TO follow up on Chris's approach, you may want to first prepare an array of values and then loop reading and comparing as long as there are values. Untested:

    $ line_1 = "Line 1 test."
    $ line_2 = "Line 2 test."
    $ line_3 = "Line 3 test."
    $ line_num = 1
    $ReadNext:
    $   READ/END_OF_FILE=ender read_test cc
    $   if line_'line_num'.nes.cc then WRITE SYS$OUTPUT "Line ", line_num, " FALSE"
    $   line_num = line_num + 1
    $   if f$type(line_'line_num').NES."" then GOTO ReadNext
    $ WRITE SYS$OUTPUT "All provided lines checked out TRUE"
    $ GOTO end
    $Ender:
    $ WRITE SYS$OUTPUT "Ran out of lines too soon. FALSE"
    $end:
    $ close Read_Test
    

    hth, Hein.