Posted By
SVS on 2003-04-12
| Maybe I have found a BASIC bug
Try this statement:
A$="*123*": ? INSTR(A$,"*",INSTR(A$,"*")+1)
The result should be 5, but I receive 0 or sometimes, ?FORMULA TOO COMPLEX ERROR What are your opinions?
|
|
Posted By
JamesC on 2003-04-12
| SVS -->
I was able to obtain 5 or ?FORMULA TOO COMPLEX but not a zero. I suspect that the system isn't releasing stack space from nesting the INSTR function inside itself.
I received the ?FORMULA error on the third attempt and every attempt afterward, even by changing the definition of A$.
|
|
Posted By
Csabo on 2003-04-13
| Re: Bug
I tried it today on my PAL Plus/4, and got the same results as James. Gives 5 first, then after the 3rd try it's ?Formula too complex. Although if at that point I deleted the "2" out of A$'s value, it gave me 4, then 4 again, the the error. Strange!
It even sounds like a common question, though, finding the SECOND match of a character inside a string. Writing it into separate INSTR's works well, and it does not give the error.
A$ = "*123" : P = INSTR ( A$, "*" ) : ? INSTR ( A$, "*", P + 1 )
But you could be right about this being a bug.
|
|
Posted By
SVS on 2003-04-14
| I obtained 0 as result, when I run a statement like this,
inside a BASIC prog, then in running mode. Maybe it gave me zero, instead of error message (0 from INSTR means NOT FOUND).
|
|
Posted By
Ulysses777 on 2003-04-14
| C128
Just tried this on the C128 VICE emulator (as the C128 also uses INSTR) and it does the exact same thing after the same number of tries.
|
|
Posted By
JamesC on 2003-04-14
| As official an answer as we might get
without calling Leonard and getting an answering machine:
From the Plus/4 PRG: "25 FORMULA TOO COMPLEX - current calculation is too long or contains too many expressions in parenthesis."
In short, it'll have to be broken into two statements. Find the first occurance, assign it to a variable, then use the variable in the search for the second occurance:
10 A$="*123*" 15 A1=INSTR(A$,"*") 20 A2=INSTR(A$,"*",A1+1)
By using LEN(A$) and a DO:LOOP sequence we can search for even more instances.
|
|
Posted By
SVS on 2003-04-15
| OK, but I think this statement does not require
so much stack depth. I well remember having written other lines with much more complex calculus levels. For this reason I think it's a bug, or a bad written subroutine on INSTR code.
|
|
Posted By
TCFS on 2003-07-09
| Re: Maybe I have found a BASIC bug
another bug:
print 1+"2"+-3
but save all of your work before try this
|
|
Posted By
JamesC on 2003-07-09
| Re: Maybe I have found a BASIC bug
This threw me into MONITOR but X returned to BASIC with no problems.
Adding 1+-3 gives -2 properly. Obviously you're trying to 'break' the system by putting the 2 in quotes.
|
|