Data Access Worldwide Knowledge Base
Article ID 2265 Article Title EXAMPLE: Alternative for Field_Map command Article URL http://www.dataaccess.com/kbasepublic/KBPrint.asp?ArticleID=2265 KBase Category VDF11 Date Created 11/25/2006 Last Edit Date 11/28/2006
Article Text
QUESTION:
DataFlex has a command called FIELD_MAP to find a column at runtime based on the name of the column. I would like to have my own control over this. How can I do this?
ANSWER:
You can use the following code:
Function FieldMap Integer iTableNumber String sColumnName Returns Integer
Integer iColumns iColumn iStartColumn
Boolean bIsRecnumTable
String sTableColumnName
Get_Attribute DF_FILE_NUMBER_FIELDS Of iTableNumber To iColumns
Get_Attribute DF_FILE_RECNUM_TABLE Of iTableNumber To bIsRecnumTable
If (bIsRecnumTable) Begin
Move 0 To iStartColumn
End
Else Begin
Move 1 To iStartColumn
End
Move (Lowercase (sColumnName)) To sColumnName
For iColumn From iStartColumn To iColumns
Get_Attribute DF_FIELD_NAME Of iTableNumber iColumn To sTableColumnName
If (Lowercase (sTableColumnName) = sColumnName) Begin
Function_Return iColumn
End
Loop
Function_Return -1
End_Function
The code above works only for Visual DataFlex 11 and higher because it uses the DF_FILE_RECNUM_TABLE attribute to find out if column 0 should be skipped in the enumeration.
Contributed By:
Vincent Oorsprong
Company: Data Access Worldwide
email: vincent.oorsprong@dataaccess.eu
Web Site: http://www.dataaccess.eu
Email this Article
Email this Article to a Colleague
Send Feedback on this Article to Data Access Worldwide
Copyright ©2010 Data Access Corporation. All rights reserved.
The information provided in the Data Access Technical Knowledge Base is provided "as is" without warranty of any kind. Data Access Corporation disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. In no event shall Data Access Corporation or its suppliers be liable for any damages whatsoever including direct, indirect, incidental, consequential, loss of business profits or special damages, even if Data Access Corporation or its suppliers have been advised of the possibility of such damages. Some states do not allow the exclusion or limitation of liability for consequential or incidental damages so the foregoing limitation may not apply.