Re: [Ql-Users] bug in String handling
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
Re: [Ql-Users] bug in String handling
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) will return the value 5, as will PRINT LEN(a$(1)). If a$ is undimensioned and a$=’Hello World’, PRINT a$(0) does not generally work and will result in an ‘Out of Range’ error, except under SMS v2.60+ and Minerva where PRINT a$(0) is the same as PRINT LEN(a$). John On Fri, 12 Jan 2024 at 17:04, Jan Bredenbeek via Ql-Users < ql-users@lists.q-v-d.com> wrote: > 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. > > > > Cheers, > > Norm. > > > > Page 46 of the Concepts section mentions that 'under certain > circumstances' it is possible to refer to more than one element in an > array (i.e. slice the array), and that the term 'array' in this context > can include a numerical array, a string array or a simple string. It > also mentions that the slice (0 TO) means the full range of elements. > > Whilst it is indeed possible to slice an array (which includes element > 0), this is not true for simple strings. Using slice (0 TO) of a simple > string always produces an 'out of range' error. > Under Minerva and SMSQ/E, a$(0) indeed returns the length of a$. At > least version JS returns an error when trying to access element 0 of a > simple string. > > -- > Jan Bredenbeek | Hilversum, NL | j...@bredenbeek.net > > ___ > QL-Users Mailing List > ___ QL-Users Mailing List
Re: [Ql-Users] bug in String handling
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. Cheers, Norm. Page 46 of the Concepts section mentions that 'under certain circumstances' it is possible to refer to more than one element in an array (i.e. slice the array), and that the term 'array' in this context can include a numerical array, a string array or a simple string. It also mentions that the slice (0 TO) means the full range of elements. Whilst it is indeed possible to slice an array (which includes element 0), this is not true for simple strings. Using slice (0 TO) of a simple string always produces an 'out of range' error. Under Minerva and SMSQ/E, a$(0) indeed returns the length of a$. At least version JS returns an error when trying to access element 0 of a simple string. -- Jan Bredenbeek | Hilversum, NL | j...@bredenbeek.net ___ QL-Users Mailing List
Re: [Ql-Users] bug in String handling
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 > 125 pause:stop 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. If it's by design, it it actually documented anywhere? I do not recall it being in the QL Manual, as supplied with new QLs back in the day, and I don't recall Jan Jones mentioning it either. My QL Manual is packed away ready for a house move---which fell through---Just checked with Jan Jones (the QUANTA version), she doesn't mention how this works (or doesn't!) It also makes sense as there would be no other way to represent a string slice of null. I'm wondering though, why you would need to get a "string slice of null"? If I want to obtain a an empty string, just assigne on A$="" for example. To get a slice that is null, I need to determine that this is exactly what I need, and then make sure that my slicing parameters are specified with the end being exactly one less than the start? Too much faffing around, just assign an empty string (as above!) Line 115: I guess a$( to 0) is read as a$(1 to 0) which fits the criteria above. I agree with your observation. Jan Jones states that when slicing a string variable, the zeroth elephant cannot be accessed. (Page 28.) Line 120: a$(0) should be fine also. It represents the string length. Assignment to this location is also acceptable: Jan Jones documents this in her QL SuperBASIC Handbook, page 23. I still think that returning "" for a specific string slice from (a to a-1) is a bug! Bite me!!! ;-) Cheers, Norm. -- Norman Dunbar. ___ QL-Users Mailing List
Re: [Ql-Users] bug in String handling
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 behaviour, it's no wonder Qlib balks at it. 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. Cheers, Norm. -- Norman Dunbar. ___ QL-Users Mailing List
Re: [Ql-Users] Sinclair QL 40th anniversary 2024-01-12! QL-is-40
Op 12/01/2024 om 10:00 schreef Urs Koenig (QL) via Ql-Users: https://youtube.com/shorts/4qxf66zTu9s?si=_dnRFNWczFK5iu-m Von meinem iPhone gesendet ___ QL-Users Mailing List Hi, I do remember my first QL. My late brother-in-law wrote his first novel using Quill. Those were the days :) François Van Emelen ___ QL-Users Mailing List
[Ql-Users] Sinclair QL 40th anniversary 2024-01-12! QL-is-40
https://youtube.com/shorts/4qxf66zTu9s?si=_dnRFNWczFK5iu-m Von meinem iPhone gesendet ___ QL-Users Mailing List