Aclone question

Aclone question

Postby Massimo Linossi » Fri May 18, 2018 7:10 am

Hi to all.
I have a little question about aclone command.
Now I make a test like this :

Code: Select all  Expand view
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 view
arra_out = aclone(&"arra" + str(indice,1))


but it doesn't work.
Is there a way to make this ?
Thans a lot
Massimo
User avatar
Massimo Linossi
 
Posts: 498
Joined: Mon Oct 17, 2005 10:38 am
Location: Italy

Re: Aclone question

Postby Mike Serra » Fri May 18, 2018 7:28 am

Hello Massimo:

Try this:

Code: Select all  Expand view

#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

 
Mike Serra
 
Posts: 297
Joined: Fri Apr 14, 2006 5:52 pm
Location: Córdoba (España)

Re: Aclone question

Postby Massimo Linossi » Fri May 18, 2018 7:41 am

Hi Mike.
Thanks for the reply but It gives this error : "Error BASE/1003 : variable does not exist aArray1"
Really strange.
User avatar
Massimo Linossi
 
Posts: 498
Joined: Mon Oct 17, 2005 10:38 am
Location: Italy

Re: Aclone question

Postby Enrico Maria Giordano » Fri May 18, 2018 9:04 am

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

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Aclone question

Postby byte-one » Fri May 18, 2018 9:07 am

Maybe you must declare the variables aArray1,... with memvar !?
Regards,
Günther
---------------------------------
office@byte-one.com
User avatar
byte-one
 
Posts: 1048
Joined: Mon Oct 24, 2005 9:54 am
Location: Austria

Re: Aclone question

Postby Massimo Linossi » Fri May 18, 2018 10:23 am

Hi Enrico
Here is a little test program

Code: Select all  Expand view
#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
Massimo Linossi
 
Posts: 498
Joined: Mon Oct 17, 2005 10:38 am
Location: Italy

Re: Aclone question

Postby Enrico Maria Giordano » Fri May 18, 2018 10:45 am

Gunther is right. You have to declare

Code: Select all  Expand view
MEMVAR arra1, arra2, arra3


not LOCAL.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Aclone question

Postby Massimo Linossi » Fri May 18, 2018 10:59 am

Great, it's working.
Thanks a lot Enrico & Gunther
Massimo
User avatar
Massimo Linossi
 
Posts: 498
Joined: Mon Oct 17, 2005 10:38 am
Location: Italy


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 46 guests