brianw@microsoft.UUCP (Brian Willoughby) (08/15/89)
In article <8908102100.AA27334@trout.nosc.mil> pete@pro-europa.cts.com (Peter Creath) writes: >Okay, here's the problem: I'm using AppleSoft & I need it to solve >non-constant equations. > >for instance: 10 input a$ > 20 print a$" = " [answer] > > RUN > > ?3*4-2 > 3*4-2 = 10 > >In this case, the equation could be ANYTHING. How would I get AppleSoft to >solve it? (Short of writing massive code) >_____________________________________________________________________________ >Peter Creath | UUCP: crash!pro-europa!pete >13319 Conifer | ARPA: crash!pro-europa!pete@nosc.mil >Houston, Tx 77079 | INET: pete@pro-europa.cts.com Applesoft doesn't have a built in provision for user (i.e. non-programmer) input of expressions. But you can use DOS to fool basic into accepting a text file as new program lines. I have not verified the following, but it should work if you tweak it. 5 d$ = chr$(4) 10 input a$ 20 print d$"OPEN EXPRESSION" 30 print d$"WRITE EXPRESSION" 40 print "100 I = "a$ 50 print "GOTO 100" 60 print d$"CLOSE EXPRESSION" 70 print d$"EXEC EXPRESSION" 100 I = 0 110 print I 120 end I'm not sure that everything will work smoothly when transferring control between the EXEC file and the BASIC program, but you could alternatively have the EXEC file SAVE the modified program to disk and the RUN it from disk. In the latter case, expression input would have to be under user selection, or else the program would always start by modifying itself (endless loop). Another potential problem: the user would have to input Applesoft valid expressions (obviously), because Applesoft doesn't understand general equations. Hope this helps... Brian Willoughby UUCP: ...!{tikal, sun, uunet, elwood}!microsoft!brianw InterNet: microsoft!brianw@uunet.UU.NET or: microsoft!brianw@Sun.COM Bitnet brianw@microsoft.UUCP