Ded [ options ] Dl-program [ input-file.. ]
Ded [ options ] [ -f Dl-program-file ].. [ input-file.. ]
Ded is a Dl processor. It reads D-records from the input files and execute the given Dl program for eacvh input D-record. After execution, (possibly modified) the current record is written to the standard out unless the current record is null value.
After processing all records from the input file, Ded once again executes the Dl-program without any input record. This is called epilogue mode, and in this mode, no automatic output is made after the execution. Epilogue mode is usually used for the termination process like output of accumulated result. It is also useful for generating new D-file from the null input file. Use OUTPUT special variable to make an output in the eilogue mode. In the Dl program, epilogue mode can be tested by EPILOGUE special variable.
Adds a field "foocount" which holds the number of "foo" fields in the same record.
Ded foocount = COUNT foo
Delete "count" field when the field is not non negative integer.
Ded IF count UNLIKE "^[0-9]+$" THEN count = { } FI
Create D-file with 10 records of which field "seq" is 1 to 10.
Ded FOR i IN 1 .. 10 DO seq = VAR i ; OUTPUT DONE < NUL
Note that this program runs only in the epilogue mode, because no record comes in from NUL file (it should be /dev/null in the UNIX).
Read a D-file like:
title:Introduction to D
price:2400
title:D tutorial
price:2800
........
and appends a summary record with a field "price.sum" after the whole file.
Ded -f prog.dl input-file
where prog.dl file contains:
IF EPILOGUE THEN FIELD price.sum = STATIC sum ; OUTPUT FI ;
IF NR == 1 THEN STATIC sum = 0 FI ;
STATIC sum = STATIC sum + FIELD price
Note that Dmeans does more neat job for similar purpose.
See the manual of D_msg.
MIYAZAWA Akira