Page 1 of 1

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

Posted: Mon Dec 03, 2018 8:52 pm
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

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

Posted: Tue Dec 04, 2018 5:33 am
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

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

Posted: Tue Dec 04, 2018 10:52 am
by pjw
Good work, Rich. I always thought PARUSE was bugged, but now I see that the bug was in the documentation.

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

Posted: Wed Dec 05, 2018 12:12 am
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.

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

Posted: Wed Dec 05, 2018 4:09 pm
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

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

Posted: Wed Dec 05, 2018 7:38 pm
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