0
Votes in Release
(breakdown)
FIELDTYPE() function

Description

This one originated from a typical customer's request: How do I get the type of a given tablefield programmatically?
Maybe just like that:

FUNCTION FieldType(cFieldName)
DIMENSION aInfo(1,1)
RETURN aInfo( ASCAN(aInfo, IIF("." $ cFieldName, JUSTEXT(cFieldName), cFieldName),1,  AFIELDS( aInfo, IIF("." $ cFieldName, JUSTSTEM(cFieldName), ALIAS())),1,9) ,2)

Ok, that one is a perfect candidate for the "How much code can I put in one line to make it unreadable but stil working" contest ;) But stil fascinating, that you can fill an array and immediately access it in the very same line of code. I'm returning the offset of an array, where the offset pointer is retrieved by ASCAN on that same array, which only then gets filled by AFIELDS, which is then used as parameter of ASCAN, which is then used as parameter for the Array access...
Confused? Complicated? Noo, just the joy of a dynamic language. Gotcha, you C# weenies! ;)

But maybe it's better comprehendable, if you write it like this:

FUNCTION FieldType(cFieldName)
LOCAL aInfo(1,1), cField, cAlias, nPos, nCount
cField = IIF("." $ cFieldName, JUSTEXT(cFieldName), cFieldName)
cAlias = IIF("." $ cFieldName, JUSTSTEM(cFieldName), ALIAS())
nCount = AFIELDS(aInfo,cAlias)
nPos   = ASCAN(aInfo,cField,1,nCount,1,9)
RETURN aInfo(nPos,2) 

But surely only half the fun.... :)


Files

There are no files associated with this release.


Work Items

Proposed

= Proposed

Active

= Active

Fixed

= Fixed

Closed

= Closed

There are no work items associated with this release.



Updating...
Page view tracker