.dll Runtime in Visual FoxPro
-
- Posts: 15
- Joined: Tue Oct 10, 2017 12:44 pm
.dll Runtime in Visual FoxPro
Has anyone implemented the .dll Runtime in a Visual FoxPro app? We^re working with it now, and would appreciate any code samples that you could give us.____Thanks,____Jeff Barefoot__InfiSoft Software
-
- Posts: 7
- Joined: Tue Oct 10, 2017 12:44 pm
=> RE: .dll Runtime in Visual FoxPro
I invested some time and got the .dll Runtime working in Vis FoxPro. Let me know if you^d like to see some code samples.
==> RE: .dll Runtime in Visual FoxPro
If you do have samples, we could add them to the next rev of the documentation. Also any hints you might have to other users who are just starting out would be great.____Kathleen__R&R Support
-
- Posts: 7
- Joined: Tue Oct 10, 2017 12:44 pm
===> RE: .dll Runtime in Visual FoxPro
Hi Kathleen,____Sorry to be so long in replying, I^ve been out of town.____To use R&R^s .dll functionality from Visual FoxPro, refer to the following samples.____*******************************************************__(1) First you^ll need to declare the functions. I do this as my app is being launched. Note that the "@" characters typically indicate that the parameter will be placed in an existing variable when the function is called. NOTE>>> I^m not sure that I have the syntax 100% "proper," but it seems to be correct enough to return the data that I need. Note that when declaring .dll functions the function names are case sensitive, and must match exactly the case found in the R&R documentation:____Declare Integer chooseReport in RrRpt32.dll string, string, integer , string, integer ____Declare Integer getMasterTableName in RrRpt32.dll integer, string @, integer____Declare Integer getFirstRelationInfo in RrRpt32.dll integer, string @, integer, string @, integer, string @, integer, string @, integer____Declare Integer getNextRelationInfo in RrRpt32.dll integer, string @, integer, string @, integer, string @, integer, string @, integer__*******************************************************__(2) To call a function, the common thread among most R&R Functions is the Report Handle. Find the report handle for a given report by calling the "chooseReport" function. I^m pulling the handle for a report that is named by lcReportFile, and the length of the Report Name is indicated by lnReportLength. Experimenting with the syntax a little will allow the user to browse and select a report from the disk, or from a named library:____hReport = chooseReport(.null.,.null.,1,lcReportFile,lnReportLength)__*******************************************************__(3) Other functions are called in a similar fashion. For example, you can determine the name of the Master Table for a given report (the report has already been analyzed by chooseReport() and the File Handle has been stored in hReport). Note that I set a standard size for my buffers (200 characters), and initialize the buffers into which data will be returned as 200 spaces. The following function looks at the report indicated by hReport, and puts the Master File name into lcMasterFile. The returned string is padded to 200 characters with null data characters.____Important Gotcha: The variable name into which you^re returning a value (i.e. the "buffer" ) must be declared and populated with a long enough string to accomodate the returning value. I just make it a long string of spaces.____lnBufferSize = 200____lcMasterFile = space(lnBufferSize)____lnMasterError = getMasterTableName( hReport , @lcMasterFile , lnBufferSize )____*******************************************************__(4) Since the data placed in the buffer location (variable lcMasterfile in this example) is right-padded to 200 characters with null characters (chr(0) in VFP) I strip out those characters:____lcMasterFile = iif(chr(0) $ lcMasterFile, ;___left(lcMasterFile,at(chr(0),lcMasterFile)-1), ;___alltrim(lcMasterFile))____*******************************************************__(5) Other functions can be used similarly. These are a couple that I^ve experimented with:____* first initialize your buffers__lcRelFile = _space(lnBufferSize)__lcRelIndex = _space(lnBufferSize)__lcRelTag = _space(lnBufferSize)__lcRelAlias = _space(lnBufferSize)____* then call the function__lnFirstRelError = getFirstRelationInfo(hReport, @lcRelFile, lnBufferSize, @lcRelIndex, lnBufferSize, @lcRelTag,lnBufferSize, @lcRelAlias,lnBufferSize)____* then strip out the chr(0) characters using the function in (4)____This function looks at the first related table for a report (i.e. the first table that is related to the Master Table) and puts the File Name, Index File Name, Index File Tag, and Alias Name into the specified fields.____*******************************************************__(6)____lcRelFile = _space(lnBufferSize)__lcRelIndex = _space(lnBufferSize)__lcRelTag = _space(lnBufferSize)__lcRelAlias = _space(lnBufferSize)____lnNextRelError = getNextRelationInfo(hReport, @lcRelFile, lnBufferSize, @lcRelIndex, lnBufferSize, @lcRelTag,lnBufferSize, @lcRelAlias,lnBufferSize)____This function looks at the "next" related table for a report (i.e. the second related table, then the third, then the fourth, etc. It increments to the next related table each successive time that it is called) and puts the File Name, Index File Name, Index File Tag, and Alias Name into the specified fields.____*******************************************************____That^s all I^ve got! I hope it helps someone out....____Jeff__