Page 2 of 2

Re: Too many parameters/locals bug

Posted: Sun Jun 18, 2023 12:45 am
by ql_freak
Hi Steve,
stevepoole wrote: Sat Jun 17, 2023 9:15 pm ... Tested under QDOS on SGC, (but used to run ok on 128ko).

Define the main routine however you require !
Seems to be a nice trick! But it works because, SB-variables are different from C locals (see my example from c't magazine) and as Norman approved.

BTW: (At least) In Python it's possible, to achieve the same result, cause you can nest function definitions inside of function definitions. The inner functions have access to the local variables of the outer functions :-)

BUT YOU SHOULD USE THOSE TRICKS WITH CARE!

Re: Too many parameters/locals bug

Posted: Sun Jun 18, 2023 3:52 pm
by Derek_Stewart
Hi,

I am a little confused by this problem, are you not mixing global variables up with loczl variables.

Also wrote quick Superbasic program to pass 13 variables to a procedure, with 13 local variables defined with the procedure:

Code: Select all

10 a=100: b=110: c=120: d=130: e=140
15 f=150: g=160: h=170: i=180: j=190
16 k=200: l=210: m=220
21 test a,b,c,d,e,f,g,h,i,j,k,l,m
30 :
40 DEFine PROCedure test(a1,b1,c1,d1,e1,f1,g1,h1,i1,j1,k1,l1,m1)
50    LOCal a,b,c,d,e,f,g,h,i,j,k,l,m
60    a=0: b=1: c=2: d=3: e=4
61    f=5: g=6: h=7: i=8: j=9
62    k=10: l=11: m=12
70    PRINT a1,b1,c1,d1,e1,f1,g1,h1,i1,j1,k1,l1,m1
71    PRINT a,b,c,d,e,f,g,h,i,j,k,l,m
80 END DEFine
All serms to work as expected in JS, Minerva and SMSQ/E

Re: Too many parameters/locals bug

Posted: Sun Jun 18, 2023 11:44 pm
by stevepoole
Hi Derek,
No confusion in the program between Globals and Locals : Since Local variables are also local to ALL nested routines within the calling routine, (right down through the calling tree...).

The program worked ok under QDos on a 128ko JM. It is not needed at all with SMSQ/E, since the LOCals bug got fixed...
But the technique to return errors from deeply nested routines is still useful !

Regards, Steve.