Page 2 of 2

Re: TK2 and file manipulation

Posted: Thu Feb 13, 2025 12:55 am
by ql_freak
tofro wrote: Wed Feb 12, 2025 10:41 pm that will work on all possible data types
I love Python, "the Interpreter for C++", but I hate this feature (Python supports it and you need it!). In C++, C#/Java you can overload functions which is unfortunately not possible in Python).

Re: TK2 and file manipulation

Posted: Thu Feb 13, 2025 7:20 pm
by Tinyfpga
As is a common side effect of posting on this forum this thread has gone AWOL and my last question is lost in the haze of
Tubo vs Liberator.

Thus, I will rephrase my question as follows:-

from "Read the docs"
BGET [#ch\position,] [item *[,item]*..]

Does -
"Each item to be fetched must therefore be either an integer or a floating point variable."

Mean -
Each item fetched must be either and integer or a floating point variable depending on whether the item is
stored as va% or va. The result looks same except that the variable va% is stored internally as an
integer and the variable va is stored as a floating point number both in the range 0..255.

I assume floating point numbers take up more space in memory and are slower to manipulate.

Re: TK2 and file manipulation

Posted: Thu Feb 13, 2025 8:37 pm
by M68008
Tinyfpga wrote: Thu Feb 13, 2025 7:20 pm I assume floating point numbers take up more space in memory and are slower to manipulate.
About this part, integers are faster to use in compiled programs and probably SBasic, but are slower in the original SuperBASIC, since QDOS converts them to/from floating point when they are used.

Re: TK2 and file manipulation

Posted: Thu Feb 13, 2025 9:10 pm
by martyn_hill
Hi Tinyfpga
Tinyfpga wrote: Thu Feb 13, 2025 7:20 pm from "Read the docs"
BGET [#ch\position,] [item *[,item]*..]

Does -
"Each item to be fetched must therefore be either an integer or a floating point variable."

Mean -
Each item fetched must be either and integer or a floating point variable depending on whether the item is
stored as va% or va.
The result looks same except that the variable va% is stored internally as an
integer and the variable va is stored as a floating point number both in the range 0..255.
Correct, it is trying to convey that:
a) A single byte will be read from the channel for each named variable, thus a cardinal value, in the range 0-255.
b) If more than one variable is provided, more than one byte will be read.
c) The byte value will be 'coerced' in to its target variable type, % or FP.

Compare that to the definition of the later version of BGET under SMSQe, which will also accept a 'sub-string of a string array' as the destination variable (i.e. with an implicit or explicit range), such that multiple bytes - up to the length of the substring - will be collated into that substring.

Whether or not the earlier 'pre SMSQe' TK2 BGET supported substring slices, I cant say.

Note that, if you're using Marcel's v2.32 or later update to TK2 (i.e. long after that TK2 Manual was written), you may well be using the SMSQe variant anyway, so the SMSQe manual definition is relevant.
Tinyfpga wrote: Thu Feb 13, 2025 7:20 pm I assume floating point numbers take up more space in memory and are slower to manipulate.
Yes, your assumption is (mostly) correct, but as mentioned below, % variables in interpreted SuperBASIC under QDOS often prove as slow to process as FP. To get the full benefit of % variables, you need to either compile or run Minerva or SMSQe...

Re: TK2 and file manipulation

Posted: Fri Feb 14, 2025 11:46 am
by Tinyfpga
Compare that to the definition of the later version of BGET under SMSQe, which will also accept a 'sub-string of a string array' as the destination variable (i.e. with an implicit or explicit range), such that multiple bytes - up to the length of the substring - will be collated into that substring.
I don't understand this. Where might I find this later definition?
Is it in Lenerz's Outputr?
Is there an instruction for searching for a string within a file?

Re: TK2 and file manipulation

Posted: Fri Feb 14, 2025 12:00 pm
by Andrew
Tinyfpga wrote: Fri Feb 14, 2025 11:46 am I don't understand this. Where might I find this later definition?
https://superbasic-manual.readthedocs.i ... /bget.html

SMS NOTE

BGET will accept a parameter which is a sub-string of a string array to read in several bytes at once. For example:

DIM a$(10):a$=FILL$(’ ‘,10):BGET #3,a$(4 to 7)

This will read 4 bytes from channel #3 into the middle of a$.

Please note that a$ cannot be an empty string if this is to work since the sub-string would not be valid!!