Page 1 of 1

Aclone question

Posted: Fri May 18, 2018 7:10 am
by Massimo Linossi
Hi to all.
I have a little question about aclone command.
Now I make a test like this :

Code: Select all | Expand

do case
    case indice = 1
       arra_out = aclone(arra1)
    case indice = 2
       arra_out = aclone(arra2)
    case indice = 3
       arra_out = aclone(arra3)
    case indice = 4
       arra_out = aclone(arra4)
    case indice = 5
       arra_out = aclone(arra5)
endcase
 

If I have the variable indice that comes from a table, I have many situation and I prefer to
clone the array with a macro like :

Code: Select all | Expand

arra_out = aclone(&"arra" + str(indice,1))


but it doesn't work.
Is there a way to make this ?
Thans a lot
Massimo

Re: Aclone question

Posted: Fri May 18, 2018 7:28 am
by Mike Serra
Hello Massimo:

Try this:

Code: Select all | Expand


#include "FiveWin.ch"

FUNCTION Main()
   local i
   local aFinalArray
   local cVar
   public aArray1:={{"1","Hello"}},aArray2:={{"2","Hello"}}, aArray3:={{"3","Hello"}},aArray4:={{"4","Hello"}}
 
   for i = 1 to 4
    aFinalArray:=ACLONE(&("aArray" + str(i,1)))
    xBrowse(aFinalArray)
   next i
   release aArray1,aArray2,aArray3,aArray4
RETURN

 

Re: Aclone question

Posted: Fri May 18, 2018 7:41 am
by Massimo Linossi
Hi Mike.
Thanks for the reply but It gives this error : "Error BASE/1003 : variable does not exist aArray1"
Really strange.

Re: Aclone question

Posted: Fri May 18, 2018 9:04 am
by Enrico Maria Giordano
Can I see a reduced and self-contained sample showing the problem, please?

EMG

Re: Aclone question

Posted: Fri May 18, 2018 9:07 am
by byte-one
Maybe you must declare the variables aArray1,... with memvar !?

Re: Aclone question

Posted: Fri May 18, 2018 10:23 am
by Massimo Linossi
Hi Enrico
Here is a little test program

Code: Select all | Expand

#include "fivewin.ch"

**************************************************************************
Procedure test_array
LOCAL arra1, arra2, arra3, arra_out, nome_arra, indice

arra1 = { "A1","A2","A3","A4" }
arra2 = { "B1","B2","B3","B4" }
arra3 = { "C1","C2","C3","C4" }

indice = 1

arra_out = aclone(&("arra" + str(indice,1)))        // HERE GIVES ERROR

msginfo(arra_out[1], str(indice))

return
 


Thanks a lot
Massimo

Re: Aclone question

Posted: Fri May 18, 2018 10:45 am
by Enrico Maria Giordano
Gunther is right. You have to declare

Code: Select all | Expand

MEMVAR arra1, arra2, arra3


not LOCAL.

EMG

Re: Aclone question

Posted: Fri May 18, 2018 10:59 am
by Massimo Linossi
Great, it's working.
Thanks a lot Enrico & Gunther
Massimo