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).
TK2 and file manipulation
Re: TK2 and file manipulation
http://peter-sulzer.bplaced.net
GERMAN! QL-Download page also available in English: GETLINE$() function, UNIX-like "ls" command, improved DIY-Toolkit function EDLINE$ - All with source. AND a good Python 3 Tutorial (German) for Win/UNIX
GERMAN! QL-Download page also available in English: GETLINE$() function, UNIX-like "ls" command, improved DIY-Toolkit function EDLINE$ - All with source. AND a good Python 3 Tutorial (German) for Win/UNIX

Re: TK2 and file manipulation
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.
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
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.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.
-
- QL Wafer Drive
- Posts: 1048
- Joined: Sat Oct 25, 2014 9:53 am
Re: TK2 and file manipulation
Hi Tinyfpga
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.
Correct, it is trying to convey that: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.
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.
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...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.
Re: TK2 and file manipulation
I don't understand this. Where might I find this later definition?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.
Is it in Lenerz's Outputr?
Is there an instruction for searching for a string within a file?
Re: TK2 and file manipulation
https://superbasic-manual.readthedocs.i ... /bget.htmlTinyfpga wrote: Fri Feb 14, 2025 11:46 am I don't understand this. Where might I find this later definition?
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!!