Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!uunet!sjsca4!annapurna!grimesg From: grimesg@annapurna (George Grimes) Newsgroups: comp.lang.pascal Subject: Re: Another various question about TP 5.0 Message-ID: <1989Dec6.211845.23824@sj.ate.slb.com> Date: 6 Dec 89 21:18:45 GMT References: <303@usna.MIL> <1017@dutrun.UUCP> Reply-To: grimesg@annapurna.UUCP (George Grimes) Organization: Schlumberger ATE, San Jose, CA Lines: 52 >In article <303@usna.MIL> baldwin@cad.usna.mil (J.D. Baldwin) writes: >Is there a good, clean way to convert the value of an enumerated ordinal >type to a string value? > >That is, what does the function ConverterFunction(somevalue:sometype) : string >look like in this fragment: > > type veggies = (carrots, limabeans, beets, toadstools); . . . > var whatveg : veggies; . . . > > whatveg := carrots; > . . . > writeln(ConverterFunction(whatveg)); > >so that the writeln statement will output the string "carrots"? This question >is not exactly mission-critical to me, but an answer would be nice. If >replies are by e-mail, I'll summarize. On the VAX you can just do writeln(whatveg); and VAX Pascal will take care of the conversion to a string automatically. Likewise, if you have readln(whatveg); your user can enter "carrot" and conversion to the proper ordinal is automatic. When I first bought Microsoft Pascal in 1982, the manual showed an example like this. After I bought it and got it home I found the obscure reference in an appendix that said that this feature was not implemented yet. When I called and asked about it, they said that this feature would be available very soon. The last time I called and asked about this (about the fourth call I think) a year or two ago, I was still assured that this would happen 'real soon now'. It's a nice feature and I'd love to have it on my PC. George ******************************************************************************* Any similarity between my opinion and my employer's is purely coincidental and subject to immediate review if you bring it to my attention! +-------------------------------------------------------------------+ | DOMAIN: grimesg@sj.ate.slb.com | George Grimes | | UUCP: {decwrl,uunet}!sjsca4!grimesg | Schlumberger Technologies | | INTERNET: grimesg%sjs@sdr.slb.com | 1601 Technology Drive | | PHONE:(408)437-5305/Fax:(408)453-0137 | San Jose, Ca. 95115 | +-------------------------------------------------------------------+