nab1382@dsacng1.UUCP (Dick Hauser) (04/21/88)
I purchased the book "The AWK Programming Language". Right now, I am working my way through the book. I have encountered problems with user-defined functions (Page 53). I am familiar with "C" and the bourne shell. I wrote a small AWK program which called a user-define function. Syntax errors keep occurring. { init_rpt() print $1, $2 $3 } function init_rpt { print " SAMPLE HEADER" } As a last resort, I wrote a small program like the one above, but still received errors (syntax error near xxx, bailing out near xxx). I read paragraph 2.3 (User-Defined Functions) quite a few times, and can locate the problem. Apparently, there is a syntax requirement I am not aware of. Finally, I you have a list of AWK "gotchas", I would appreciate receiving a copy. Thanks in advance - Dick Hauser D D D :
morrell@hpsal2.HP.COM (Michael Morrell) (04/23/88)
/ hpsal2:comp.unix.questions / nab1382@dsacng1.UUCP (Dick Hauser) / 6:06 am Apr 21, 1988 / I purchased the book "The AWK Programming Language". Right now, I am working my way through the book. I have encountered problems with user-defined functions (Page 53). I am familiar with "C" and the bourne shell. I wrote a small AWK program which called a user-define function. Syntax errors keep occurring. { init_rpt() print $1, $2 $3 } function init_rpt { print " SAMPLE HEADER" } As a last resort, I wrote a small program like the one above, but still received errors (syntax error near xxx, bailing out near xxx). I read paragraph 2.3 (User-Defined Functions) quite a few times, and can locate the problem. Apparently, there is a syntax requirement I am not aware of. Finally, I you have a list of AWK "gotchas", I would appreciate receiving a copy. Thanks in advance - Dick Hauser ---------- User-defined functions are only available in the 1985 version of awk (nawk). You need to get a copy of that version. Michael
wnp@dcs.UUCP (Wolf N. Paul) (04/23/88)
In article <307@dsacng1.UUCP> nab1382@dsacng1.UUCP (Dick Hauser) writes: >I purchased the book "The AWK Programming Language". Right now, >I am working my way through the book. I have encountered problems >with user-defined functions (Page 53). I am familiar with "C" ... > { init_rpt() > print $1, $2 $3 > } > function init_rpt { > print " SAMPLE HEADER" > } >As a last resort, I wrote a small program like the one above, but >still received errors (syntax error near xxx, bailing out near xxx). >I read paragraph 2.3 (User-Defined Functions) quite a few times, and >can locate the problem. Apparently, there is a syntax requirement The syntax requirement is to have the right version of AWK. The AWK distributed with most UNIX systems to date is not the latest version of AWK, and supports neither user-defined functions nor access to more than one file in a program. I believe that the latest version, as described in the book, is being distributed with System V/3 only; it is also available from the AT&T Toolchest, although I do not know quite what the requirements are for that. If you have a 286 running either Microport or Xenix System V, you can get a reverse-engineered workalike from Mortice Kern Systems in Waterloo, Ontario, UNIX mail address ihnp4!watmath!mks!toolkit. Cost for a package including AWK, KSH and CRYPT is ca. $99. Hope this saves some readers of the AWK book these same frustrations I went through until I discovered that I had the wrong version of awk. -- Wolf N. Paul * 3387 Sam Rayburn Run * Carrollton TX 75007 * (214) 306-9101 UUCP: ihnp4!killer!dcs!wnp ESL: 62832882 INTERNET: wnp@EESDES.DAS.NET or wnp@dcs.UUCP TLX: 910-280-0585 EES PLANO UD
wheels@mks.UUCP (Gerry Wheeler) (04/26/88)
In article <65@dcs.UUCP>, wnp@dcs.UUCP (Wolf N. Paul) writes: > If you have a 286 running either Microport or Xenix System V, you can get > a reverse-engineered workalike from Mortice Kern Systems in Waterloo, Ontario, > UNIX mail address ihnp4!watmath!mks!toolkit. Cost for a package including > AWK, KSH and CRYPT is ca. $99. The package Wolf is talking about is called MKS Trilogy. The list price is $119 (US dollars), but can be found for $99 from some of our dealers. It includes awk, the Korn shell, and crypt. We chose those three because they may be hard to get, and we already had most of the code here from our MS-DOS versions. This is the new version of awk, as Wolf noted, so it matches what is described in the book by Aho, et al. The crypt includes the standard Unix rotor machine and the DES algorithm. -- Gerry Wheeler Phone: (519)884-2251 Mortice Kern Systems Inc. UUCP: uunet!watmath!mks!wheels 35 King St. North BIX: join mks Waterloo, Ontario N2J 2W9 CompuServe: 73260,1043