Jump to content

Resource as ExternalDataFileEx


RickG

Recommended Posts

Hey all,

 

I'm using an external tab-delimited file to house address information for a number of departments allowing the user to only have to provide a department name as input.

 

Snippet! (from OnRecordStart..."Department" is the user input)...

 

var addrList = new ExternalDataFileEx("C:\\<path>\\<to>\\mylist.txt", "\t");
dept    =   Trim(Field("Department"));
recNum  =   addrList.FindRecord("Department", dept);
addr1   =   ToUpper(Trim(addrList.GetFieldValue(recNum, "Address1")));

..and this works great!

 

I'd like to have MyList as a resource for no other reason than it looks like a more elegant solution over hard-coding file system paths. I've tried this...

 

var addrList = new ExternalDataFileEx(Resource("myList").content,"\t");
dept    =   Trim(Field("Department"));
recNum  =   addrList.FindRecord("Department", dept);
addr1   =   ToUpper(Trim(addrList.GetFieldValue(recNum, "Address1")));

...but it doesn't match up anything.

 

Is there another Resource attribute that I should be using, or can I just not use a Resource like this? Are there any advantages/disadvantages to using a Resource like this over hard-coding the path if this can be done?

 

Thanks in advance...

Link to comment
Share on other sites

  • 2 weeks later...
You don't need to hard-code the path. Simply put the external data file in the same directory as your job (template PDF), and specify only the file name in the ExternalDataFileEx call. If you do need to access the file from a different location, specify that other location in the Search Path on the Advanced tab of the Composition Settings dialog.
Link to comment
Share on other sites

Archived

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

×
×
  • Create New...