🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.atari.st
Article #39831

awk port for ST

#39831
From: Enartloc Nhoj
Date: Sun, 24 Dec 1989 17:53
69 lines
2200 bytes
I grabbed awk.ttp from the net many months back..
and have used it successfully for string matching
and manipulation...

Last night i wrote a couple of quick dot.g scripts
in gulam using awk to produce some quick reports
for my student records which included integer addition.
The scripts are very straight forward with a simple loop.
I am not sure if the problem is in the conditional or what.

Here are the two awk scripts:

due.awk
-------


BEGIN	{  FS = "\t"
	   printf("%-15s %4s \n\n", "STUDENT", "DUE")
	}
	{  printf("%-15s %4d \n", $1, $2)
	   total = total + $2
	}
END	{ printf("\n-%15s %4d \n", "TOTAL DUE" , total) }


owe.awk
-------


BEGIN	{  FS = "\t"
	   printf("%-15s %4s \n\n", "STUDENT", "OWED") }
	{
	   if ( $2 > $3 ) {
	     printf("%-15s %4d\n", $1, $2 - $3 )
	     total = total + ($2 - $3)
       	    }
	 }
END      {  printf("\n%-15s %4d \n", "TOTAL DUE", total) }


If I pass a file such as this to the awk scripts:


Abdul	125	0	15	60	weird
Nadily	100	0	15	72	gorgeous
Mark	125	0	15	12	no comment
....
etc


Where field $2 is the amount DUE and $3 is amount PAID...

I should get the same results with both due.awk and owe.awk.
On the ST, owe.awk yields a total that is greater by
a value equal to the first line $2 field.  I inserted 
print statements to find the error..  I thought i was
not understanding the way awk searches for patterns on
a line by line basis... but when i uploaded it to BSD..
it worked straight forward and gave correct results.

IS there a problem(s) with AWK.TTP , or am i misunderstanding
something in my code?  I'd much rather be able to write 
short dot.g scripts for quick things like this than have
to compile C code or open a spread sheet etc..  

Thanks ..

-kevin
ramsiri@blake.acs.washington.edu
Technical Details
Message-ID: <5152@blake.acs.washington.edu>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!usc!samsung!caesar.cs.montana.edu!ogicse!blake!ramsiri

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!usc!samsung!caesar.cs.montana.edu!ogicse!blake!ramsiri
From: ramsiri@blake.acs.washington.edu (Enartloc Nhoj)
Newsgroups: comp.sys.atari.st
Subject: awk port for ST
Message-ID: <5152@blake.acs.washington.edu>
Date: 24 Dec 89 17:53:01 GMT
Distribution: usa
Organization: Univ of Washington, Seattle
Lines: 69