home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / lang / icon / 529 < prev    next >
Encoding:
Text File  |  1992-11-18  |  1.1 KB  |  35 lines

  1. Newsgroups: comp.lang.icon
  2. Path: sparky!uunet!mercury.hsi.com!mlfarm!cs.arizona.edu!icon-group
  3. Date: Tue, 17 Nov 1992 13:25:11 MST
  4. From: "Clint Jeffery" <cjeffery@cs.arizona.edu>
  5. Message-ID: <199211172025.AA26141@chuckwalla.cs.arizona.edu>
  6. In-Reply-To: Paul_Abrahams@MTS.cc.Wayne.edu's message of Tue, 17 Nov 92 10:50:06 EST <528466@MTS.cc.Wayne.edu>
  7. Subject: Field names of a record type
  8. Lines: 25
  9.  
  10.    Paul Abrahams writes:
  11.    given the name of an Icon record type, is there a
  12.    straightforward way to list the names of its fields in the same order
  13.    as they appear in its definition?  So far I haven't found one.
  14.  
  15. While you are waiting for that built-in function, the following program
  16. demonstrates a technique that does what you ask.  Normally I wouldn't
  17. start from a *name* of a record type, but that's how you stated the problem.
  18. Folks who don't believe in semi-colon insertion, let me know if you have
  19. trouble reading this.
  20.  
  21. record r (alpha, beta, c)
  22.  
  23. procedure main()
  24.   every write(fieldnames("r"))
  25. end
  26.  
  27. procedure fieldnames(r)
  28.   R := r()
  29.   every i := 1 to *R do {
  30.     s := name(R[i])
  31.     suspend s[find(".",s)+1:0]
  32.   }
  33. end
  34.  
  35.