Jump to content

Reading Specific Fields in an External Data File


Recommended Posts

I have a job that has multiple external data files, which are all formatted the same.


       det1     det2     det3


I am having trouble getting FP Desktop to read the correct fields. Here is my code to get the data from the fields:

returnStr = (activeExDF.GetFieldValue(activeExDF.FindRecord, 'cpn1'), 'det1')
return returnStr;


Whatever I type where 'det1' is appears in the validation box. For example, I changed it to 'cat' even though there is no field called 'cat' in the data. The validation returns 'cat' instead of throwing an error.


Any help would be greatly appreciated. Thanks!

Link to comment
Share on other sites

The syntax is messed up. You're not actually calling the FindRecord function, and that extra string after the comma isn't a parameter to any function call. I think you want to do this:

return activeExDF.GetFieldValue(activeExDF.FindRecord(1, 'cpn1'), 'det1');

The "1" in there is to denote the first field, which appears to be unnamed from the sample data you posted. You could use the field name in there instead, if there is one.


You might also want to check the result of the FindRecord call to better handle a failure case; something like:

var recNum = activeExDF.FindRecord(1, 'cpn1');
if (recNum < 0)
   return "Record not found!";
return activeExDF.GetFieldValue(recNum, 'det1');

Link to comment
Share on other sites


This topic is now archived and is closed to further replies.

  • Create New...