Login
Back to forumSee the full topicGo to last reply

Posted By

JamesC
on 2004-03-21
22:06:34
 Re: Another BASIC bug found ;)

I wondered why SVS was doing this, when I read his post over two months ago. Tonight I refreshed my memory of going through old Transactor magazine archives and found this bit of information: Transactor link

What SVS was attempting to do was insert two characters into a string, with those characters overwriting two other characters inside the string. If he tried a simple character it worked, but two or more did not without parenthesis or combining the characters (as shown by TPSH above).

The REASON it doesn't work the way SVS wished, is simple but not thought of. Commodore BASIC solves equations in a left-to-right fashion after the statement has been broken down to its lowest form (after parenthesis, multiplication and division, etc). The statement SVS wished to use was seen by BASIC as A$="PLUS4": MID$(A$,3,2)=CHR$(65), with the remainder discarded by BASIC because BASIC thinks that the equation has already been solved. BASIC is working in a straight left-to-right manner, as noted in the owner's manual for solving equations.

In other words, the characters on the right side of the = sign have to be "solved" before the MID$ can use them to complete the statement on the left side.

I realize that high-level programmers like Csabo probably realized this when the thread was started, but it has been bugging me for months now, and I wanted to say that I finally figured it out. happy



Back to top


Copyright © Plus/4 World Team, 2001-2024