Crear variables / Create variables

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Post Reply
Mario Mansilla
Posts: 270
Joined: Wed Aug 13, 2008 2:35 pm
Location: Córdoba - Argentina

Crear variables / Create variables

Post by Mario Mansilla »

Hello friends :
                    I need to create as many variables with records as a database.
How can I include a registry value in the name of each variable.
For example the content of the database is as follows
001 0100
002 0101
003 0102
004 0103
005 0200

I need to create the variables: npv0100 = 100, npv0101 = 101, npv0102 = 102, npv0103 = 103, npv0200 = 200

How can I do this?

Hola Amigos :
necesito crear tantas variables con registros tenga una base de datos .
Como puedo hacer para incluir en el nombre de cada variable un valor del registro .
Por ejemplo el contenido de la base de datos es el siguiente
001 0100
002 0101
003 0102
004 0103
005 0200

Necesito crear las variables : npv0100 = 100 , npv0101 = 101 , npv0102 = 102 , npv0103 = 103 , npv0200 = 200

Como puedo hacer para realizar esto ?

Saludos
Mario Rafael Mansilla
User avatar
AUGE_OHR
Posts: 2093
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: Crear variables / Create variables

Post by AUGE_OHR »

hi,

Code: Select all

   cString := "nvp"+STRZERO(nValue,4)
   &cString := nValue
---

Macro are slow so i would think about Array :idea:
have fun
Jimmy
User avatar
andyglezl
Posts: 1461
Joined: Fri Oct 26, 2012 7:58 pm
Location: Guadalajara Jalisco, MX
Contact:

Re: Crear variables / Create variables

Post by andyglezl »

Code: Select all

FUNCTION Otro()
*Porque variables y no un Array ?
*Como sabras el nombre de una variable en especifico si el valor es variable ?  Y si hay valores duplicados ?
FOR  i = 1 TO 100
    cX := "npv"+STRZERO( i, 4 )
    &cX := i
NEXT
SAVE ALL LIKE npv* TO MyVars
MSGBox( "Termino..." )
var.png
var.png (152.86 KiB) Viewed 1703 times
Andrés González López
Desde Guadalajara, Jalisco. México.
User avatar
srvet_claudio
Posts: 2220
Joined: Thu Feb 25, 2010 8:43 pm
Location: Uruguay
Contact:

Re: Crear variables / Create variables

Post by srvet_claudio »

Hi,

Create var:
__MVPUBLIC( <cVarName> )
__MVPRIVATE( <cVarName> )

Set/get vale
__MVPUT( <cVarName> [, <xValue>] ) --> <xValue>
__MVGET( <cVarName> ) --> <xVar>

Check:
__MVEXIST( <cVarName> ) --> <lVariableExist>
Best regards.
Dr. Claudio Soto
(from Uruguay)
http://srvet.blogspot.com
User avatar
serge_girard
Posts: 3309
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Re: Crear variables / Create variables

Post by serge_girard »

Great to have you back, Claudio!
Serge
There's nothing you can do that can't be done...
Post Reply