Aclone question

Post Reply
User avatar
Massimo Linossi
Posts: 508
Joined: Mon Oct 17, 2005 10:38 am
Location: Italy

Aclone question

Post 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
Mike Serra
Posts: 297
Joined: Fri Apr 14, 2006 5:52 pm
Location: Córdoba (España)

Re: Aclone question

Post 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

 
User avatar
Massimo Linossi
Posts: 508
Joined: Mon Oct 17, 2005 10:38 am
Location: Italy

Re: Aclone question

Post by Massimo Linossi »

Hi Mike.
Thanks for the reply but It gives this error : "Error BASE/1003 : variable does not exist aArray1"
Really strange.
User avatar
Enrico Maria Giordano
Posts: 8767
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Has thanked: 1 time
Been thanked: 5 times
Contact:

Re: Aclone question

Post by Enrico Maria Giordano »

Can I see a reduced and self-contained sample showing the problem, please?

EMG
User avatar
byte-one
Posts: 1048
Joined: Mon Oct 24, 2005 9:54 am
Location: Austria
Contact:

Re: Aclone question

Post by byte-one »

Maybe you must declare the variables aArray1,... with memvar !?
Regards,
Günther
---------------------------------
office@byte-one.com
User avatar
Massimo Linossi
Posts: 508
Joined: Mon Oct 17, 2005 10:38 am
Location: Italy

Re: Aclone question

Post 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
User avatar
Enrico Maria Giordano
Posts: 8767
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Has thanked: 1 time
Been thanked: 5 times
Contact:

Re: Aclone question

Post by Enrico Maria Giordano »

Gunther is right. You have to declare

Code: Select all | Expand

MEMVAR arra1, arra2, arra3


not LOCAL.

EMG
User avatar
Massimo Linossi
Posts: 508
Joined: Mon Oct 17, 2005 10:38 am
Location: Italy

Re: Aclone question

Post by Massimo Linossi »

Great, it's working.
Thanks a lot Enrico & Gunther
Massimo
Post Reply