Page 2 of 2
Re: Weird string stuff
Posted: Mon Jan 13, 2025 4:05 pm
by Andrew
Derek_Stewart wrote: Mon Jan 13, 2025 12:31 pm
Hi,
I have been reading, Artificial Intelligenence on the QL, after I made single page and OCR.
Texamples in the book and the programme at the end of the of the book "Computer_SalesMan_bas", use arrays to store the data and use array element 0 as a data element, string or integer.
Consulting many QL manuals and books, they say that the length of the string is the last element in the array, as detailed in the QL User Guide and many books.
Only the Online Supebasic Manual, The Definitive Superbasic Guide by Jan Jones, gives array element 0 as the lenth of the string.
This has I expected, but thd more interesting question is why are so many manuals and books including the QL User Guide saying incorrectly that the length of the array is held at the end of the array.
That said how many programmes do not work in SMSQ/E or Minerva based on incorrect asumpions on the array storage details.
Needless to say, the programme: "Computer_Saleman_bas" needs correcti g.
I think I should stick to assembler programming, it is alot easier.
At first glance I do not spot any errors in array handling in the program.
However, line 16040 is fishy and needs correcting.
I only OCRed the first 5 pages of the program, and have 9 pages more to do ...
Re: Weird string stuff
Posted: Mon Jan 13, 2025 6:07 pm
by tofro
Derek_Stewart wrote: Mon Jan 13, 2025 12:31 pm
Hi,
I have been reading, Artificial Intelligenence on the QL, after I made single page and OCR.
Texamples in the book and the programme at the end of the of the book "Computer_SalesMan_bas", use arrays to store the data and use array element 0 as a data element, string or integer.
Consulting many QL manuals and books, they say that the length of the string is the last element in the array, as detailed in the QL User Guide and many books.
Only the Online Supebasic Manual, The Definitive Superbasic Guide by Jan Jones, gives array element 0 as the lenth of the string.
This has I expected, but thd more interesting question is why are so many manuals and books including the QL User Guide saying incorrectly that the length of the array is held at the end of the array.
That said how many programmes do not work in SMSQ/E or Minerva based on incorrect asumpions on the array storage details.
Needless to say, the programme: "Computer_Saleman_bas" needs correcti g.
I think I should stick to assembler programming, it is alot easier.
Well, you can basically store nearly anything in a DIMensioned array, as long as you don't exceed the array bounds.
String length in both QDOSSMSQ and S*BASIC (including Minerva) is always stored in the element 0. I have yet to see any claim that string length is stored at the end (well, maybe at the "near" one, but never at the "far one"

) of an array. Where did you find those? Note that if you have a multi-dimensional string array (like DIM a$(10,100)), only access to the second index with 0 touches a string length. A$(0) returns the complete string at index 0 of the array. A$(0,0) returns the length of that first string as a character.
I had a quick glance through your mentioned salesman program and cannot find access to a string length at the end. Can you point me to that?
Re: Weird string stuff
Posted: Mon Jan 13, 2025 6:45 pm
by Derek_Stewart
Andrew wrote: Mon Jan 13, 2025 4:05 pm
At first glance I do not spot any errors in array handling in the program.
However, line 16040 is fishy and needs correcting.
I only OCRed the first 5 pages of the program, and have 9 pages more to do ...
no need to OCR thd book I have done the whole book, into a Libreoffice file and PDF.
Just git to proof read the final document.
I extracted the Computer_Saleman basic code, wwhich I am tryi g to grt working.
The problem with the array length storage seems to be in conficit with the QL User Guide:
https://dilwyn.theqlforum.com/docs/ebook ... ds.htm#dim
DIM
Arrays
Defines an array to SuperBASIC. String, integer and floating point arrays can be defined. String arrays handle fixed length strings and the final index is taken to be the string length.
Re: Weird string stuff
Posted: Mon Jan 13, 2025 6:58 pm
by tofro
Derek_Stewart wrote: Mon Jan 13, 2025 6:45 pm
The problem with the array length storage seems to be in conficit with the QL User Guide:
https://dilwyn.theqlforum.com/docs/ebook ... ds.htm#dim
DIM
Arrays
Defines an array to SuperBASIC. String, integer and floating point arrays can be defined. String arrays handle fixed length strings and the final index is taken to be the string length.
That's just what I was saying above. Seems to be a misunderstanding of the manual. This is trying to say that
For
the
final index (100) is the [maximum usable] string length of an array of 10 strings. Has nothing to do with the string length encoded in the string itself. That's still in A$(x, 0).
Re: Weird string stuff
Posted: Mon Jan 13, 2025 8:03 pm
by Derek_Stewart
Hi,
Thank you for the clarification.
Looks like I misunderstood the description.
Re: Weird string stuff
Posted: Mon Jan 13, 2025 8:40 pm
by pjw
Derek_Stewart wrote: Mon Jan 13, 2025 8:03 pm
Hi,
Thank you for the clarification.
Looks like I misunderstood the description.
It wasnt very clear, I agree. We probably lost a couple of dozen brothers there..