Page 1 of 1
field length, type,
Posted: Wed Jan 06, 2021 6:48 pm
by franco
I am trying get the field structure form inside a program. I know it is easy but can not find.
use table
msgbox(field1(name))
msgbox(field1(type))
msgbox(field1(length))
msgbox(field2(name) and so on.
Re: field length, type,
Posted: Wed Jan 06, 2021 7:19 pm
by SALINETAS24
franco wrote: ↑Wed Jan 06, 2021 6:48 pm
I am trying get the field structure form inside a program. I know it is easy but can not find.
use table
msgbox(field1(name))
msgbox(field1(type))
msgbox(field1(length))
msgbox(field2(name) and so on.
Hola Franco. ¿Quieres leer la estructura de un DBF...?
aField:=Alias->(DBSTRUCT() )
aField[1]:= nombre
aField[1]:= tipo
aField[1]:= longitud
aField[1]:= decimales
Tambien puedes usar esta otra funcion
Alias-> AFIELDS(aNombre,aTipo,aLongitud,aDecimales)
Un saludo,
Re: field length, type,
Posted: Wed Jan 06, 2021 8:24 pm
by franco
SALINETAS24,
No I need to know the type of field1, field2 and so on
field 1 is 'ITEM' C
field 2 is DESC C
field 3 is PRICE N
in program
if ITEM(type) = 'C' // will index
index
endif
if PRICE(type) = 'C' //will not index
index
endif
Re: field length, type,
Posted: Wed Jan 06, 2021 8:41 pm
by SALINETAS24
franco wrote: ↑Wed Jan 06, 2021 8:24 pm
SALINETAS24,
No I need to know the type of field1, field2 and so on
field 1 is 'ITEM' C
field 2 is DESC C
field 3 is PRICE N
in program
if ITEM(type) = 'C' // will index
index
endif
if PRICE(type) = 'C' //will not index
index
endif
Ahora te he entendido ...,
necesitas VALTYPE()
Code: Select all
LOCAL nLen := Alias->( FCount() )
LOCAL aData:={}
FOR n = 1 TO nLen
AAdd( aData, FieldGet( n ) )
MSGBOX(aData[n])
MSGBOX(VALTYPE(aData[n])
NEXT
Salud amigo
Re: field length, type,
Posted: Wed Jan 06, 2021 10:58 pm
by franco
Thanks SALINETAS24, I new it would be easy.
msgbox(valtype(fieldget(3)))
msgbox(valtype(desc)) field(2)
Franco