Well, whatever you guys choose to believe, please no one try to "fix"
it as this behaviour appears to be consistent across the board - at
least as far as JS, Minerva and SMSQ/E are concerned. If programmers
keep their indices in order the issue should never arise anyway.
Per
On 13/01/2024
I wonder if part of the reason that this arose is that some BASICs
from that era just returned a null string "" if string slicing errors
arose, without an error message and people remembered that?
While that was probably convenient for the casual programmer, it must
have made debugging difficult
Norman Dunbar wrote:
I still think that returning "" for a specific string slice from (a to
a-1) is a bug!
I tend to agree. x$ (a to b) where b is smaller than a should rise an
error.The only way that would make any kind of sense to me would be if
this returned the array contents in the
Morning Jan,
That matches with Jan Jones. Arrays index from zero, but simple strings from 1.
Cheers,
Norm.
--
Author of "Arduino Software Internals" and "Arduino Interrupts".
___
QL-Users Mailing List
Could the reference be the SBASIC/SuperBASIC reference manual?
That says
When a string array is set up with DIM, each entry is set to a nul string
(“”). The zero’th element of each string array
contains the actual length of that string, for example:
DIM a$(10,10): a$(1)='Hello': PRINT a$(1,0)
On 12-01-2024 16:20, Norman Dunbar via Ql-Users wrote:
If I remember correctly, all the way back to 1984-85, I'm almost
certain that the supplied QL manual, in the large, heavy, A$ folder,
mentioned that string lengths are indeed stored in a$(0)---or at
least, can be accessed from there.
On 08/01/2024 18:46, pjw via Ql-Users wrote:
> 100 a$ = "1234567890"
> 105 b$ = a$(4 to 3): REMark This works
> 110 REMark c$ = a$(4 to 2): REMark This fails with an error.
> 115 c$ = a$( to 0) : REMark no error returned
> 120 c$ = a$(0):: REMark no error returned BUT ERROR IF QLIBERATED
On 08/01/2024 16:51, Wolfgang Lenerz via Ql-Users wrote:
Line 120 is due to the fast that strings are not 0 based index. So what
would a$(0) be?
Under SMSQ/E at least, print a$(0) in the above example would give "10"
- which is the length of the string... Since this seems to be an
unorthodox
Line 105: The construct a$(n to n - 1) represents the empty string
(even when n = 1). Since it is replicated in JS, Minerva and SMSQ/E Im
assuming it is by design. It also makes sense as there would be no
other way to represent a string slice of null.
Line 115: I guess a$( to 0) is read as
Hi,
Line 120 is due to the fast that strings are not 0 based index. So what
would a$(0) be?
Under SMSQ/E at least, print a$(0) in the above example would give "10"
- which is the length of the string... Since this seems to be an
unorthodox behaviour, it's no wonder Qlib balks at it.
Line
Hi,
Some other anomalies
100 a$ = "1234567890"
105 b$ = a$(4 to 3): REMark This works
110 REMark c$ = a$(4 to 2): REMark This fails with an error.
115 c$ = a$( to 0) : REMark no error returned
120 c$ = a$(0): : REMark no error returned BUT ERROR IF QLIBERATED
125 pause:stop
The problem
11 matches
Mail list logo