FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Aclone question
Posts: 512
Joined: Mon Oct 17, 2005 10:38 AM
Aclone question
Posted: Fri May 18, 2018 07:10 AM
Hi to all.
I have a little question about aclone command.
Now I make a test like this :

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


but it doesn't work.
Is there a way to make this ?
Thans a lot
Massimo
Posts: 297
Joined: Fri Apr 14, 2006 05:52 PM
Re: Aclone question
Posted: Fri May 18, 2018 07:28 AM
Hello Massimo:

Try this:

Code (fw): Select all Collapse
#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
Posts: 512
Joined: Mon Oct 17, 2005 10:38 AM
Re: Aclone question
Posted: Fri May 18, 2018 07:41 AM

Hi Mike.
Thanks for the reply but It gives this error : "Error BASE/1003 : variable does not exist aArray1"
Really strange.

Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Aclone question
Posted: Fri May 18, 2018 09:04 AM

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

EMG

Posts: 1048
Joined: Mon Oct 24, 2005 09:54 AM
Re: Aclone question
Posted: Fri May 18, 2018 09:07 AM

Maybe you must declare the variables aArray1,... with memvar !?

Regards,
Günther
---------------------------------
office@byte-one.com
Posts: 512
Joined: Mon Oct 17, 2005 10:38 AM
Re: Aclone question
Posted: Fri May 18, 2018 10:23 AM
Hi Enrico
Here is a little test program

Code (fw): Select all Collapse
#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
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Aclone question
Posted: Fri May 18, 2018 10:45 AM
Gunther is right. You have to declare

Code (fw): Select all Collapse
MEMVAR arra1, arra2, arra3


not LOCAL.

EMG
Posts: 512
Joined: Mon Oct 17, 2005 10:38 AM
Re: Aclone question
Posted: Fri May 18, 2018 10:59 AM

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

Continue the discussion