Create variables on memory

Create variables on memory

Postby Silvio.Falconi » Mon May 02, 2022 11:19 am

I must create some variables as

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

from this array

Image

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 November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 6892
Joined: Thu Oct 18, 2012 7:17 pm

Re: Create variables on memory

Postby nageswaragunupudi » Mon May 02, 2022 12:14 pm

Should work.

This works for me:
Code: Select all  Expand view
  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
User avatar
nageswaragunupudi
 
Posts: 10465
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Create variables on memory

Postby Silvio.Falconi » Mon May 02, 2022 4:06 pm

nageswaragunupudi wrote:Should work.

This works for me:
Code: Select all  Expand view
  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: Select all  Expand view




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 November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 6892
Joined: Thu Oct 18, 2012 7:17 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 77 guests