From: utzoo!decvax!harpo!npois!ucbvax!C70:info-cpm Newsgroups: fa.info-cpm Title: Pascal Programming problem Article-I.D.: ucb.1112 Posted: Tue May 18 23:49:19 1982 Received: Thu May 20 02:20:19 1982 >From POURNE@Mit-Mc Tue May 18 23:48:59 1982 Delete this if you've no interest in Pascal. I would like an ELEGANT Pascal solution to a problem that is very easy in CBASIC and CB-80 Compiled Basic. One often must ask a program user questions, and you want to know if the answer was "yes" or "Yes"; in fact, you want to know only if the first letter was "Y" or "y" and you don't care how long the answer was. You will also want to give a prompt of some kind (the question to be asked). In CBASIC and CB80 this is done with wht I call FN.YES% which is a function. The % indicates that the answer is an integer; a boolean would do, but there are no proper booleans in CBASIC. The function is: DEF FN.YES%(Jive$) Input Jive$;Stuff$ Stuff$ = LEFT$(Stuff$,1) Stuff$ = UCASE$(Stuff$) IF Stuff$ = "Y" OR Stuff$ = "y" THEN \ FN.YES% = TRUE% ELSE \ FN.YES% = FALSE% Return FN.END which uses its formal parameter as the input prompt, g ets an input, and determines if the first letter is "y" or "Y" and returns true% or false% (integers, usually 1 and 0). It is thus legal to say IF FN.YES%("Are you awake") = true% then Print "FOO" \ ELSE Print "BAR" and other stuff like that. The \ characxters mean "line continued"; CBASIC and CB-80 assume that a cr-lf pair terminates a statement unless there is a \ at the end of line (I like that better than Pascal's ;'s but maybe it's what you're used to). Anyway, I would like to do a couple of Pascal programs, and I have not seen a t really elegant way to do the FN yes. remember that the input can be a single letter or several, and that we want the input buffer cleared after the operation. There must be a simple way to do thiss, and I expect I could get Alex to give me one but he's not available just this evening. Any help appreciated. JEP