06300410.txt 30-Jun-00


Subject: Code Block
From: bourdoux@my-deja.com

Hi all,

It seems that you can't use strong typed functions in a code
  block!
Here is part of my code :
cKeyValue := "(Usual2String("+aStruct[i,DBS_NAME]+"))"
cExp := "{||Usual2String(_FIELD->"+aStruct[i,DBS_NAME]+") "
bKeyValue := &(cExp)
to be used in the oServer:OrdCreate(.....) (in ClassMate)
Usual2String(uValue as usual) as string pascal
Has someone experience with this ?

JM Bourdoux
SMAP Belgium


Subject: Re: Code Block
From: "Phil McGuinness" <heyphil@sherlock.com.au>

There are two types of strong typing for codeblocks.
You have the ;
     LOCAL cbXXXX AS CODEBLOCK
and the ;
     LOCAL cbYYY AS _CODEBLOCK
The later offers roll your own code blocks at runtime..

Phil McGuinness


Subject: Re: Code Block
From: "Paul Piko" <paul@piko.com.au>

JM,

Macros require functions that are Clipper calling
  convention. However there are some special cases of common
  VO functions that are Pascal calling convention that are
  allowed in macros.

Paul


Subject: Re: Code Block
From: nswong@maxis.net.my (Wong)

Hi JM,

This is from the online-manual:
STRICT    Typing arguments forces STRICT calling convention.
  These two declarations are equivalent:
FUNCTION Test(p1 AS FLOAT, p2 AS FLOAT, p3 AS INT) ;
  AS FLOAT
FUNCTION Test(p1 AS FLOAT, p2 AS FLOAT, p3 AS INT) ;
  AS FLOAT STRICT
Using strong typing increases the performance and
  reliability of your application.  It also takes away all

  of the CLIPPER flexibility mentioned above:
n You must specify all arguments
n PCount() is not applicable
n You cannot call the function in a macro expression
n You must pass AS arguments by value and REF arguments by
  reference

Regards,
Wong


Subject: Re: Code Block
From: "George Smith" <georgenospam@tksoftware.com>

Hi Wong,

This isn't absolutely correct. You CAN in fact use strong
  typing and not pass all parameters. You must declare a
  default value in your function declaration for this to be
  possible. I believe this capability was put in in the
  2.0b-3 patch.

George


Subject: Re: Code Block
From: nswong@maxis.net.my (Wong)

Hi George,

Do you refer to this?
[Start]
To give PASCAL and STRICT functions some more flexibility,
  CA-Visual Objects now supports default values for
  parameters:
FUNC MyFunc(a:=5 AS INT, b:=8 AS DWORD) AS DWORD PASCAL
When calling MyFunc(), parameters can be skipped or omitted.
  In this case the compiler will automatically push the
  default value for the parameter before calling the
  function.
[End]
Please note:
"the compiler will automatically push the default value for
  the parameter before calling the function"
Since this is implemented by compiler, so when we use
  LoadLibrary() and PCALL(), the result will not be what you
  may expected.
Try this:
PROCEDURE Start()
  LOCAL ptrPtr AS PTR
  ptrPtr:=@MyFunc()
  MyFunc() //5
  PCALL(ptrPtr) //4233830
RETURN
FUNC MyFunc(a:=5 AS INT, b:=8 AS DWORD) AS DWORD PASCAL
  LOCAL cStr AS STRING
  cStr:=Str(a)
  MessageBox(NULL,String2Psz(cStr),String2Psz("MyFunc"),0)
RETURN (0)

Regards,
Wong


Subject: Re: Code Block
From: Paolo Cherubini <cherubiniNOchSPAM@ancitel.it.invalid>

You can write you own untyped function to buid the index.
Make a try with:
cKeyValue := "(MyUsual2String("+aStruct[i,DBS_NAME]+"))"
....
FUNCTION MyUsual2String(uValue)
RETURN Usual2String(uValue)

Regards
Paolo Cherubini


Subject: Code Block
From: bourdoux@my-deja.com

Hi all,

To all thanks for these infos. It helps.

JM Bourdoux
SMAP Belgium