FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Create variables on memory
Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM
Create variables on memory
Posted: Mon May 02, 2022 11:19 AM
I must create some variables as

c1:= "0102"
c2:= "0103"
c3:= "0104"

from this array



I tried with

For n=1 to Len(atemp)
c:= atemp[n][1]
cStringa:=ltrim(str(atemp[n][2]))+ltrim(str(atemp[n][3]))
&c:= cStringa
next

but not work

How I can resolve ?
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Create variables on memory
Posted: Mon May 02, 2022 12:14 PM
Should work.

This works for me:
Code (fw): Select all Collapse
   local aTemp := { { "C1", 1, 1 }, { "C2", 1, 2 }, { "C3", 1, 3 } }
   local cVarName := "ONE"
   local n

   for n := 1 to 3
      cVarName := aTemp[ n, 1 ]
      &cVarName := STRZERO( aTemp[ n, 2 ], 2 ) + STRZERO( aTemp[ n, 3 ], 2 )
   next

   ? M->C1, M->C2, M->C3

result:
0101
0102
0103
Regards



G. N. Rao.

Hyderabad, India
Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM
Re: Create variables on memory
Posted: Mon May 02, 2022 04:06 PM
nageswaragunupudi wrote:Should work.

This works for me:
Code (fw): Select all Collapse
   local aTemp := { { "C1", 1, 1 }, { "C2", 1, 2 }, { "C3", 1, 3 } }
   local cVarName := "ONE"
   local n

   for n := 1 to 3
      cVarName := aTemp[ n, 1 ]
      &cVarName := STRZERO( aTemp[ n, 2 ], 2 ) + STRZERO( aTemp[ n, 3 ], 2 )
   next

   ? M->C1, M->C2, M->C3

result:
0101
0102
0103



Nages,
I'm creating the array in this mode:

I explain you

crea_lista(ncapofila,lCapofila)

sample :
crea_lista(1,.f.)


if lCapofila is false the function creates me an array with two numbers of which the first is the leader

if lCapofila is true
the function creates me an array with two numbers from 1 to 89/90
the problem in the second case is that it creates about 4097 records
how do i intercept the same ones?


Code (fw): Select all Collapse
Function crea_lista(ncapofila,lCapofila)
Local adata:={}
Local num1
local num2:=2
local nContatore:=1
IF !lCapofila
   num1:=1
   do while ((num1) < 90)
         do while ((num2) <= 90)
              aadd(adata,{"C"+ltrim(str(nContatore)),num1,num2})
              num2:= num2 + 1
              ncontatore:=nContatore+1
          enddo
          *ncontatore:=nContatore+1
              num1:= num1 + 1
              num2:= num1 + 1
           Enddo

        else
           num1:=ncapofila
    do while ((num2) <= 90)
              aadd(adata,{"C"+ltrim(str(nContatore)),num1,num2})
              num2:= num2 + 1
              ncontatore:=nContatore+1
          enddo
 Endif
return adata
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com

Continue the discussion