From ???@??? Mon Mar 23 23:34:52 1998
Return-Path: <pool@commerce.uq.edu.au>
Received: from cssun.mathcs.emory.edu (cssun.mathcs.emory.edu [170.140.150.1])
	by bmx.netvision.net.il (8.8.6/8.8.6) with ESMTP id OAA28665
	for <arobbins@netvision.net.il>; Sun, 22 Mar 1998 14:57:45 +0300 (IDT)
Received: from mescaline.gnu.org (we-refuse-to-spy-on-our-users@mescaline.gnu.org [158.121.106.21]) by cssun.mathcs.emory.edu (8.7.5/8.6.9-940818.01cssun) with ESMTP id HAA23168 for <arnold@mathcs.emory.edu>; Sun, 22 Mar 1998 07:01:57 -0500 (EST)
Received: from valinor.commerce.uq.edu.au by mescaline.gnu.org (8.8.5/8.6.12GNU) with ESMTP id HAA17270 for <arnold@gnu.ai.mit.edu>; Sun, 22 Mar 1998 07:06:11 -0500
Received: from MeierPC (meierpc.cc.uq.edu.au [130.102.190.29])
	by valinor.commerce.uq.edu.au (8.8.8/8.8.8/tony) with SMTP id WAA22756;
	Sun, 22 Mar 1998 22:01:49 +1000 (EST)
Date: Sun, 22 Mar 1998 22:01:49 +1000 (EST)
Message-Id: <199803221201.WAA22756@valinor.commerce.uq.edu.au>
X-Sender: pool@commerce.uq.edu.au (Unverified)
X-Mailer: Windows Eudora Light Version 1.5.2
Mime-Version: 1.0
Content-Type: multipart/mixed; boundary="=====================_890632923==_"
To: Arnold Robbins <arnold@gnu.org>, Arnold Robbins <arnold@gnu.org>
From: Arthur Pool <pool@commerce.uq.edu.au>
Subject: 98-03-17 - StepMode.awk - primitive single-step mode function
  for `gawk'
X-Attachments: C:\TOOLS\OS2\STEPMODE.AWK;
X-UIDL: 33aa33967fe48325b65edac71ffbb6bb
Status: RO

Arnold,

I'm a long-time (approx 18 years) user of REXX (ie, almost from the
very start). I've been using GNU awk quite a bit lately, under OS/2
Warp.
Why?
1) For some tasks, especially those involving large files, it's
   significantly faster.
2) Also, where relevant, the record-processing-cycle model requires
   significantly less code than doing the same job in a procedural
   language.
3) An additional bonus is the neat way that awk integrates pipes (a
   legacy of its Unix origins, I suppose), but more on that in the
   future - I'm formulating a bug report.

There are however a few things I really miss.
The most frustrating is the absence of good interactive debug
facilities - REXX's are excellent (well, pretty good).
Before you see a red haze, I'm not suggesting any changes to gawk - and
I'm not asking you for help in debugging my awk code, either.

Now the kind of situation where I really notice the lack of interactive
debug is (for example) the following:

1) I have a large file (well, large for a PC, anyway), about 19 MB,
   184,000 records.
2) I extract a subset for testing my awk code.
3) When my code appears to be OK, I test it against the full file.
4) Of course, it doesn't work properly (it never works first time, does
   it?). Problems appear at about record 150,000, so I extract a sample
   set of records from say 145,000 for 10,000.
5) I run my code against that, but it works OK.
6) So I figure that there's some `ripple' (or cascade) effect, caused
   by some combination of earlier records and the record where the
   problem becomes apparent (150,000).
7) At this stage, I begin to implant `print' statements in my code to
   display stuff as it executes.
8) This is where it gets really messy - I've got to make the `print'
   statements selective (on, say, NR), to avoid being swamped by debug
   printout - I've got to edit the code (repeatedly) to define the
   records which cause the problems. By contrast, in REXX, I'd say
   `trace -100,000' (or something like that) to tell REXX to execute
   100,000 instructions without debug output, then revert to
   interactive debug.

After a bit of this, I wrote some (primitive) awk code to try to
provide some of that function. It's not great, and it's crude, but it's
been helpful. But I can't be the first person to have been through
this, can I?

Anyway, I'll attach my `StepMode.awk', and I'd appreciate some feedback
from you (brief - I don't want to take a lot of your time):

1) Is there some obviously better way of doing this?
2) How do you do it?
3) If `StepMode.awk' looks like it might be useful to others, I'd have
   no problems with contributing it - with improvements, if necessary.
4) I really wanted to include a way of printing out ANY variable. What
   I needed was a way of printing a variable whose NAME is in a
   string variable - but I couldn't figure a way of doing that. Is
   there a way?
   What I had in mind was something like:
     a = "Fred"         # `Fred' is the variable I want to print.
     print Symbol(a)
     -or just-
     print Symbol("Fred")
   I suppose, ideally, some sort of mechanism for accessing the symbol
   table was what I was looking for.

That's all! Thanks for reading this far.
If any of the above is unclear, please let me know.

Regards .. Arthur

Attachment Converted: C:\STEPMODE.AWK
--------------------------------------------------------------------
Arthur Pool  <pool@commerce.uq.edu.au>
Phone:  <61>-7-3378-8471
-------------------------------------------------------------------- 

