Subscribe for automatic updates: RSS icon RSS

Login icon Sign in for full access | Help icon Help
Advanced search

Pages: [1]
  Reply  |  Print  
Author Topic: Passing an dynami array for a function reference  (Read 10989 times)
Lu?s T.
Posts: 39


« 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
  1. type myFuncType function( p dynamic array of string ) returns integer
  2.  
  3. define f myFuncType
  4. define callBackFuncs dictionary of myFuncType
  5. define arrVals dynamic array of string
  6. define x integer
  7.  
  8. main
  9.  
  10.    let arrVals[1] = "str1"
  11.  
  12.    let f = function f1
  13.    let callBackFuncs["funckey1"] = function f1
  14.  
  15.    call f1( arrVals ) returning x
  16.    call f( arrVals ) returning x
  17.    call callBackFuncs["funckey1"]( arrVals ) returning
  18.  
  19. end main
  20.  
  21. function f1( p dynamic array of string ) returns integer
  22.    return p.getLength()
  23. end function
  24.  
  25.  
Sebastien F.
Four Js
Posts: 545


« Reply #1 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
  1.   --call callBackFuncs["funckey1"]( arrVals ) returning x
  2.   let f = callBackFuncs["funckey1"]
  3.   call f( arrVals ) returning x
  4.  
Lu?s T.
Posts: 39


« Reply #2 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.
Sebastien F.
Four Js
Posts: 545


« Reply #3 on: February 05, 2021, 10:57:29 am »

Bug reference: FGL-5531
Seb
Pages: [1]
  Reply  |  Print  
 
Jump to:  

Powered by SMF 1.1.21 | SMF © 2015, Simple Machines