From 377a5875a09abed9ee7a64237f666d838f8bbd01 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Sat, 24 Sep 2016 07:56:27 -0700 Subject: awk macro: add orec variable. * share/txr/stdlib/awk.tl (sys:awk-state): New slot, orig-rec. (sys:awk-state loop): Initialize orig-rec after reading each record. (sys:awk-let): Provide orec symbol macro. * txr.1: Document orec variable. --- txr.1 | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'txr.1') diff --git a/txr.1 b/txr.1 index 11f23cec..fef7e0a4 100644 --- a/txr.1 +++ b/txr.1 @@ -38346,7 +38346,7 @@ switches to the next input source. When there are no more input sources, the macro terminates. .RE -.coNP Variable @ rec +.coNP Variables @ rec and @ orec .desc The awk variable .code rec @@ -38368,6 +38368,33 @@ and these fields are assigned to the field list At the same time, the .code nf variable is updated to reflect the new number of fields. +Likewise, modification of these variables causes +.code rec +to be reconstructed by a catenation of the textual representation +of the fields in +.code f +separated by copies of the output field separator +.codn ofs . + +The +.code orec +variable ("original record") also holds the current record. It is automatically +updated prior to the processing of the condition-clauses at the same time as +.code rec +with the same contents. Like +.codn rec , +it is initially +.code nil +before the first record is read. The +.code orec +variable is unaffected by modification of +the variables +.codn rec , +.code f +and +.codn nf . +It may be assigned. Doing so has no effect on any other +variable. .coNP Variable @ f .desc -- cgit v1.2.3