SuperToolkit II: PARUSE(name) - is it a bug or feature?

Anything QL Software or Programming Related.
Post Reply
User avatar
ql_freak
Gold Card
Posts: 353
Joined: Sun Jan 18, 2015 1:29 am

SuperToolkit II: PARUSE(name) - is it a bug or feature?

Post by ql_freak »

It seems the PARUSE(name) function does never return 1 as stated in the manual:

Code: Select all

100 REMark Tests for PARUSE() FuNction from SuperToolkit II
140 :
180 PRINT '1: ';:PRINT testParuse(f,i,s)
220 PRINT '2: ';:PRINT testParuse()
260 PRINT '3: ';:PRINT testParuse(PI,1,'Hello')
300 PRINT '4: ';:PRINT testParuse(2.718282,1.414214,'')
340 f=PI:i%=8:s$='Hi!'
380 PRINT'5: ';:PRINT testParuse(f,i%,s$)
420 PRINT\'Did you expect this result?'
1000 :
1002 :
1040 DEFine FuNction testParuse(float,integer,string)
1080  :
1120  :
1160  PRINT PARTYP(float)!PARUSE(float)!float;' | ';
1200  PRINT PARTYP(integer)!PARUSE(integer)!integer;' | ';
1240  PRINT PARTYP(string)!PARUSE(string)!string;' | ';
1280  RETurn 0
1320  :
1360 END DEFine
Type NEW<ENTER> then LRUN the above program (on QPC2, but the result on Minerva is similar, albeit this program won't most probably run fully on Minerva).

Here the result is:

Code: Select all

1: 2 0 0 | 2 0 0 | 2 0 0 | 0
2: 2 0 0 | 2 0 0 | 2 0 0 | 0
3: 2 2 3.141593 | 2 2 1 | 1 2 Hello | 0
4: 2 2 2.718282 | 2 2 1.414214 | 1 2  | 0
5: 2 2 3.141593 | 3 2 8 | 1 2 Hi! | 0
At least for '5:' the result should IMHO be:

Code: Select all

5: 2 1 3.141593 | 3 1 8 | 1 1 Hi! | 0


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 :-)
RWAP
RWAP Master
Posts: 2834
Joined: Sun Nov 28, 2010 4:51 pm
Location: Stone, United Kingdom
Contact:

Re: SuperToolkit II: PARUSE(name) - is it a bug or feature?

Post by RWAP »

If you look at the best manual (SBASIC/SuperBASIC Reference Manual) you will see that this was an error in the Toolkit II manual from years ago -

https://superbasic-manual.readthedocs.i ... tml#paruse


User avatar
pjw
QL Wafer Drive
Posts: 1286
Joined: Fri Jul 11, 2014 8:44 am
Location: Norway
Contact:

Re: SuperToolkit II: PARUSE(name) - is it a bug or feature?

Post by pjw »

Good work, Rich. I always thought PARUSE was bugged, but now I see that the bug was in the documentation.


Per
dont be happy. worry
- ?
User avatar
ql_freak
Gold Card
Posts: 353
Joined: Sun Jan 18, 2015 1:29 am

Re: SuperToolkit II: PARUSE(name) - is it a bug or feature?

Post by ql_freak »

Thank You Rich. In fact I was on the Online SB Reference page and saw the hint for the error in the manual, but didn't check that the table there had the correct results. Only after your answer I did read the table again and checked it. PARUSE results are 0 (unset), 2 (variable) and 3 (array) and NOT (0, 1, 2 as in printed Toolkit-Manual or Goldcard manual).

BTW: These functions are mighty ones, as they allow at least a rudimentary "Reflection" as in more modern languages like Java, C# and Python.


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 :-)
User avatar
BSJR
Trump Card
Posts: 182
Joined: Sun Oct 18, 2015 12:53 pm
Location: Amsterdam
Contact:

Re: SuperToolkit II: PARUSE(name) - is it a bug or feature?

Post by BSJR »

ql_freak wrote:Thank You Rich. In fact I was on the Online SB Reference page and saw the hint for the error in the manual, but didn't check that the table there had the correct results. Only after your answer I did read the table again and checked it. PARUSE results are 0 (unset), 2 (variable) and 3 (array) and NOT (0, 1, 2 as in printed Toolkit-Manual or Goldcard manual).

BTW: These functions are mighty ones, as they allow at least a rudimentary "Reflection" as in more modern languages like Java, C# and Python.
Warning:
Although the type of the formal vars should be ignored and the type of the calling parameters used, this is not always the case with PARTYPE.
I used "m$" as a formal parameter, knowing that if it was used it was always a string. But PARTYPE never returned zero/unset, always 1 for string. When I changed it to "mess" PARTYPE correctly returned 0/unset or 1/string if present.

BSJR


RWAP
RWAP Master
Posts: 2834
Joined: Sun Nov 28, 2010 4:51 pm
Location: Stone, United Kingdom
Contact:

Re: SuperToolkit II: PARUSE(name) - is it a bug or feature?

Post by RWAP »

BSJR wrote: BTW: These functions are mighty ones, as they allow at least a rudimentary "Reflection" as in more modern languages like Java, C# and Python.
Warning:
Although the type of the formal vars should be ignored and the type of the calling parameters used, this is not always the case with PARTYPE.
I used "m$" as a formal parameter, knowing that if it was used it was always a string. But PARTYPE never returned zero/unset, always 1 for string. When I changed it to "mess" PARTYPE correctly returned 0/unset or 1/string if present.

BSJR[/quote]

Indeed - I believe that is also covered in the SBASIC/SuperBASIC Reference Manual - https://superbasic-manual.readthedocs.i ... tml#partyp


Post Reply