home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.icon
- Path: sparky!uunet!mercury.hsi.com!mlfarm!cs.arizona.edu!icon-group
- Date: Tue, 17 Nov 1992 13:25:11 MST
- From: "Clint Jeffery" <cjeffery@cs.arizona.edu>
- Message-ID: <199211172025.AA26141@chuckwalla.cs.arizona.edu>
- 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>
- Subject: Field names of a record type
- Lines: 25
-
- Paul Abrahams writes:
- given the name of an Icon record type, is there a
- straightforward way to list the names of its fields in the same order
- as they appear in its definition? So far I haven't found one.
-
- While you are waiting for that built-in function, the following program
- demonstrates a technique that does what you ask. Normally I wouldn't
- start from a *name* of a record type, but that's how you stated the problem.
- Folks who don't believe in semi-colon insertion, let me know if you have
- trouble reading this.
-
- record r (alpha, beta, c)
-
- procedure main()
- every write(fieldnames("r"))
- end
-
- procedure fieldnames(r)
- R := r()
- every i := 1 to *R do {
- s := name(R[i])
- suspend s[find(".",s)+1:0]
- }
- end
-
-