Hi Petri,

Thank you for your answer.
I haven't found a solution yet, but I am sure it is not the way the parameters are used in the function: The following example returns the same result as with the function you sent me in your answer.
10 print t('foo')  :pause
1000 def function t(a$)
1010 print a$
1020 ret 0
1030 end def

 So, line 210
210 DEFine FuNction TEST_PARAM (p$,l$,k,i%)
can be replaced with
210 DEFine FuNction TEST_PARAM (p,l,k$,i)
without  problems and without modifying the result.

Thank for your help.

Regards,
François Van Emelen
.
Petri Pellinen schreef op 29/11/2014 om 16:20:
Hi Francois,

having only recently started looking into TK2 I found your question
quite interesting. The documentation in the TK2 manual is rather
spartan on the subject but to me it seems that the PARTYP function
takes a name rather than a position parameter.

Parameter substitution seems to be "interesting" in SuperBasic.
Somewhat surprisingly this is legal:
10 print t('foo')
1000 def fn t(a)
1010 print a
1020 ret 0
1030 end def

will print "foo" even though the parameter a is not declared as a string

In this case PARTYP(a) inside fn t will actually return "1" because
parameter "a" of the function at call time was substituted with a
string.

If you call t(a) like this: "t(2)" PARTYP(a) will return "2".

Need to delve deeper... More questions than answers now. But a rather
fascinating aspect of TK2 and SuperBasic for sure.

Cheers,
Petri


On Sat, Nov 29, 2014 at 4:04 PM, François Van Emelen
<[email protected]> wrote:
Hi all,

(Is there still someone listening here?)

Three questions

1. Can someone tell me why the values printed for PARTYP and PARUSE in lines
240 to 350 are always 2?
  Is there something wrong with these functions or am I missing something?

100 :REMark  test return values of par_use,par_typ,parnam$
110 REMark string
120   pay$="Belgium"
130 REMark array
140  DIM
langue$(2,10):langue$(0)="Dutch":langue$(1)="French":langue$(2)="German":
150 REMark float
160  keyboardcode=32
170 REMark integer
180  a%=1
190 PRINT TEST_PARAM(pay$,langue$,keyboardcode,a%):PAUSE
200 :
210 DEFine FuNction TEST_PARAM (p$,l$,k,i%)
220 :
230 :
240 PRINT PARNAM$(1)  :REMark prints 'pay$' as expected
250 PRINT PARTYP(1)   :REMark prints 2  :shouldn't that be 1 ->string
260 PRINT PARUSE(1)   :REMark prints 2  :shouldn't that be 1 ->variable
270 PRINT PARNAM$(2)  :REMark prints 'langue$' as expected
280 PRINT PARTYP(2)   :REMark prints 2 :shouldn't that be 1 ->string
290 PRINT PARUSE(2)   :REMark prints 2 :shouldn't that be 2 ->langue$ is an
array
300 PRINT PARNAM$(3)  :REMark prints 'keyboardcode' as lexpected
310 PRINT PARTYP(3)   :REMark prints 2: correct -> keyboardcode is a float
320 PRINT PARUSE(3)   :REMark prints 2::shouldn'tthat  be be 1 ->string
330 PRINT PARNAM$(4)  :REMark prints 'a%' as expected
340 PRINT PARTYP(4)  : REMark prints 2 :shouldn't that be be 3 -> a% is an
integer
350 PRINT PARUSE(4)  : REMark prints 2 :shouldn't be be 1 ->variable
360 REMark the values for partyp and paruse are always 2:why?
370  RETurn "What's wrong?":
380  REMark the returned value is not important here
390 :
400 END DEFine TEST_PARAM
2. Is there a way to find out how many languages are supported
(English,French,..)?
3. Once we know which language is active (with language($), can we access
the strings containing the days of the week
and the string with the names of the months?

Some help would be appreciated.
François Van Emelen



_______________________________________________
QL-Users Mailing List
http://www.q-v-d.demon.co.uk/smsqe.htm
_______________________________________________
QL-Users Mailing List
http://www.q-v-d.demon.co.uk/smsqe.htm


_______________________________________________
QL-Users Mailing List
http://www.q-v-d.demon.co.uk/smsqe.htm

Reply via email to