Four Js Development Tools Forum

Discussions by product => Genero BDL => Topic started by: Luís Trindade on February 04, 2021, 04:32:06 PM

Title: Passing an dynami array for a function reference
Post by: Luís Trindade on February 04, 2021, 04:32:06 PM
When I compile the following code, the compiler gives an error in line 17:

| The variable 'arrVals' is too complex a type to be used in an expression.
| See error number -4340.

I am using Genero 3.1! What am I doing wrong? How can I get around of it?
I need to implement a callback scheme and this is important to do it.

Code (genero) Select

type myFuncType function( p dynamic array of string ) returns integer

define f myFuncType
define callBackFuncs dictionary of myFuncType
define arrVals dynamic array of string
define x integer

main

    let arrVals[1] = "str1"

    let f = function f1
    let callBackFuncs["funckey1"] = function f1

    call f1( arrVals ) returning x
    call f( arrVals ) returning x
    call callBackFuncs["funckey1"]( arrVals ) returning

end main

function f1( p dynamic array of string ) returns integer
    return p.getLength()
end function

Title: Re: Passing an dynami array for a function reference
Post by: Sebastien FLAESCH on February 04, 2021, 05:41:59 PM
Hello,

The x variable is missing in the line

    call callBackFuncs["funckey1"]( arrVals ) returning x

Just tested with 3.20.12, same issue.

Not sure yet it's a bug of feature.

Try this workaround:

Code (genero) Select
   --call callBackFuncs["funckey1"]( arrVals ) returning x
   let f = callBackFuncs["funckey1"]
   call f( arrVals ) returning x
Title: Re: Passing an dynami array for a function reference
Post by: Luís Trindade on February 04, 2021, 06:32:25 PM
Thanks Sebastien,

The workaround works.
I any case I thing this is an bug.
I have other similar situations where it works to call directly the array cell.
The only difference are the type of the arguments of the function.
I couldn't find anything in the documentation that restrict this.
Title: Re: Passing an dynami array for a function reference
Post by: Sebastien FLAESCH on February 05, 2021, 10:57:29 AM
Bug reference: FGL-5531
Seb