Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!b-tech!m-net!muaddib From: muaddib@m-net.UUCP (David Pieczkiewicz) Newsgroups: comp.sys.apple Subject: Trouble with Applesoft's DEF FN Summary: How do I create a function during a run? Message-ID: <3038@m2-net.UUCP> Date: 1 Apr 89 00:46:53 GMT Reply-To: muaddib@m-net.UUCP (David Pieczkiewicz) Organization: M-Net public-access Unix system, Ann Arbor, Michigan Lines: 45 I never thought I'd be programming in Applesoft BASIC again, but here I am... I recently ran across a BASIC program that utilizes the DEF FN statement to graph a function. The user of the program enters his equation, and the program graphs it. In an attempt to update it for ProDOS and 80-columns, I ran across some interesting code within the program. When the user enters his function (as a string), the input is added to "170 DEF FN R(Q) " to form an Applesoft statement. This new string is placed into a text file along with a RUN command on another line. The program STOPs and the text file is EXECed, in effect placing a new line 170 into the program, changing the function to the input given by the user. My question is this: how can I make this process more efficient? I've tried making a statement to the effect of DEF FN R(Q) = EQ$ (The equation string entered by the user), but the function is then defined *as a string*, and cannot be used properly within the program. I would rather not mess with EXECing text files again, but I do not know of a way for a program to change one of its own lines during a run. If anyone knows of a way to accomplish this, in either BASIC or a machine language call, please let me know, either here or by mail. My other question is this: Recently, I ran across a program called LIFELIKE that I found while bumming around in FTP. This program, a ProDOS binary file, was a full-featured implementation of the "Life" game, including double-hi-res graphics, saves of scenarios, and even the ability to change the growth and death "rules". Unfortunately, when I EXECed the files (it came in two parts), both crashed into the monitor just before saving their binaries. I am a Life freak, and would desperately like to get a hold of a working copy of this program. If anyone knows about this program, or has it, or knows about similar programs, again, please let me know. A few mintues ago, I read a query about the Apple keys (actually, a response without a reference to the original; we haven't gotten the original yet, it seems...). From what I know about them, the Apple keys are simply hardwires of the paddle buttons, and their condition can be read by PEEK(49249), or PEEK(-16287) in the case of pre-IIe's, for button #0 (AKA the Open-Apple key), and PEEK(49250) (PEEK(-16286) for early Apples) for button #1, also known as the Closed-Apple on the IIe/IIc and the Option key on the GS. If the returned value is > 127, the key is being pressed. (Curiously, the source of this info, Beagle Bros.' indispensable Peeks, Pokes and Pointers chart, lists a third button (#2) under 49251 (-16285). Anyone know anything about this?) Thanks for your time... David Pieczkiewicz, muaddib@m-net.ann-arbor.mi.us, "Kwisatz Haderach of M-Net"