Page 1 of 1

Crear variables / Create variables

Posted: Tue May 26, 2020 2:28 am
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

Re: Crear variables / Create variables

Posted: Tue May 26, 2020 3:29 am
by AUGE_OHR
hi,

Code: Select all

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

Macro are slow so i would think about Array :idea:

Re: Crear variables / Create variables

Posted: Tue May 26, 2020 4:17 am
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 1706 times

Re: Crear variables / Create variables

Posted: Wed Jul 01, 2020 7:12 pm
by srvet_claudio
Hi,

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

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

Check:
__MVEXIST( <cVarName> ) --> <lVariableExist>

Re: Crear variables / Create variables

Posted: Wed Jul 01, 2020 8:33 pm
by serge_girard
Great to have you back, Claudio!
Serge