4d-database4d

4D expecting a variable with pointers and array


Here is the snippet:

C_TEXT($1;$text)
C_POINTER($2)

$text:=$1
$vlElem:=Size of array($2->)
Repeat 
    $vlElem:=$vlElem+1
    INSERT IN ARRAY($2->;$vlElem)
    $vlPos:=Position(Char(Carriage return);$1)
    If ($vlPos>0)
        $2->{$vlElem}:=Substring($1;1;$vlPos-1)
        $1:=Substring($1;$vlPos+1)
    Else 
        $2->{$vlElem}:=$1
    End if 
Until ($1="")

And I tried to to initiate the method with the following snippet:

ARRAY TEXT($vtextarr;0)
C_TEXT($vtext)
$vtext:="lorem" + char(Carriage return) + "ipsum" + char(Carriage return) + "lorem"
finv_split_free_text($vtext; $vtextarr)

It reported "4D was expecting a variable" message. What did I do wrong?


Solution

  • The problem is in the second parameter: if you declare it as pointer, you have tu call the method passing a pointer:

    finv_split_free_text($vtext; ->$vtextarr)