field length, type,

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Post Reply
franco
Posts: 877
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Location: Canada

field length, type,

Post 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.
All The Best,
Franco
Canada
User avatar
SALINETAS24
Posts: 667
Joined: Tue Feb 27, 2018 3:06 am
DBs Used: DBF
Contact:

Re: field length, type,

Post 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,
Como dijo el gran pensador Hommer Simpson..., - En este mundo solo hay 3 tipos de personas, los que saben contar y los que no. :shock:
franco
Posts: 877
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Location: Canada

Re: field length, type,

Post 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
All The Best,
Franco
Canada
User avatar
SALINETAS24
Posts: 667
Joined: Tue Feb 27, 2018 3:06 am
DBs Used: DBF
Contact:

Re: field length, type,

Post 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 ..., :lol:

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
Como dijo el gran pensador Hommer Simpson..., - En este mundo solo hay 3 tipos de personas, los que saben contar y los que no. :shock:
franco
Posts: 877
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Location: Canada

Re: field length, type,

Post by franco »

Thanks SALINETAS24, I new it would be easy.
msgbox(valtype(fieldget(3)))
msgbox(valtype(desc)) field(2)
Franco
All The Best,
Franco
Canada
Post Reply