Microsoft KB Archive/914965

= The Picture field contains file path information relative to the temporary file location when you use ReportBuilder hook methods in Visual FoxPro =

Article ID: 914965

Article Last Modified on 11/22/2007

-

APPLIES TO


 * Microsoft Visual FoxPro 9.0 Professional Edition

-



SUMMARY
If you write Report Builder extensions or code to be run during Report Designer hook events, the image file information appears in the Picture field for image layout controls. However, the path information is relative to the Visual FoxPro temporary file location instead of relative to the .frx file or .lbx file that is being edited in the Report Designer.



SYMPTOMS
When you use the ReportBuilder hook methods in Visual FoxPro 9.0 and later versions, the Visual FoxPro native Report Designer provides a read/write copy of the report or label definition table (that is, the FRX or LBX definition table). This copy should exactly match the data in the FRX table or the LBX table that is currently open in the Report Designer window. However, image file information in this copy is provided relative to a temporary file location, the Report Designer's buffer, instead of relative to the actual .frx file or .lbx file that is being edited. When the Report Designer saves the relative path information at the end of a design session, the path is saved correctly. That is, the path is saved relative to the actual .frx file or .lbx file.



RESOLUTION
To resolve this problem, the Visual FoxPro code that reads the data from the FRX copy during a ReportBuilder event must extrapolate the full path of the file name by using the user's temporary file location instead of by using the true location of the .frx file or .lbx file. The user's temporary file location is provided in the SYS(2023) function. The following code shows how to extrapolate the path correctly: local cPicture, cFRXFileName cFRXFileName = this.CommandClauses.File && actual location of FRX cPicture = alltrim(FRX.PICTURE) && location of the image filename cPicture = lower(fullpath(m.cPicture, addbs(sys(2023))))
 * do not use:
 * cPicture = lower(fullpath(m.cPicture, justpath(cFRXFileName)



MORE INFORMATION
This issue affects users who write Visual FoxPro Report Builder add-ons.

Steps to reproduce the behavior
 Create a report in the Report Designer. Add an image layout control that specifies an image file on the disk as the source. Save this report.  Create a program that contains the following code: lparameters p1,p2,p3,p4 outfile = outroot+ version(4)+ &quot;.txt&quot; if pcount=0 if file(outfile) erase (outfile) endif set alternate to (outfile) additive set alternate on   cFrxFile = getfile('frx',&quot;Report&quot;) if not empty( m.cFrxFile ) clear ? &quot;Build: &quot;+vers(1) ? &quot;FRX File: &quot; + m.cFrxFile ? &quot;CURDIR: &quot; + set(&quot;DIRECTORY&quot;) ? &quot;TEMPFILES: &quot; + sys(2023) ?       use (m.cFrxFile) alias FrxOnDisk shared noupdate locate for OBJTYPE=17 ? 'REC '+padr('FrxOnDisk.PICTURE',75) ? '--- '       ? str(recno,3)+&quot; &quot; + padr(trim(picture),75) use in FrxOnDisk _reportbuilder = program modi report (m.cFrxFile) endif set alternate off return endif if p2 = 7 set alternate on   ? ? &quot;CommandClauses.File = &quot; + p3.file ?   select frx locate for OBJTYPE=17 ? 'REC '+padr('frx.PICTURE',75) ? '--- '   ? str(recno,3)+&quot; &quot; + padr(trim(picture),75) ?   select frx ? 'REC '+'fullpath(frx.PICTURE, commandClauses.File)' ? '--- '   ? str(recno,3)+&quot; &quot; + fullpath(picture, p3.file) ?   ? 'REC  '+'fullpath(frx.PICTURE, addbs(sys(2023)))' ? '--- '   ? str(recno,3)+&quot; &quot; + fullpath(picture, addbs(sys(2023))) endif if p2 = 8 set alternate off set alternate to   modify command (outfile) endif return  Run the program. When you are prompted, select the report form that you created in step 1.  Close the report by clicking the close box in the Report Designer.
 * 1) define outroot &quot;c:\temp\text&quot;

The program creates a text file. The file might resemble the following: Build: Visual FoxPro 09.00.0000.3504 for Windows [Nov 4 2005 17:39:44] Product ID 76683-120-0006224-18453 FRX File: C:\TEMP\TESTMETADATA.FRX CURDIR: C:\WORK\CODE\VFP\VFP9 TEMPFILES: C:\TEMP\FOX

REC FrxOnDisk.PICTURE ---  6 &quot;prtscrn.jpg&quot;

CommandClauses.File = C:\TEMP\TESTMETADATA.FRX

REC frx.PICTURE ---  6 &quot;..\prtscrn.jpg&quot;

REC fullpath(frx.PICTURE, commandClauses.File) ---  6 C:\PRTSCRN.JPG

REC fullpath(frx.PICTURE, ADDBS(SYS(2023))) ---  6 C:\TEMP\PRTSCRN.JPG  Notice that the .frx file on the disk shows the correct location. In this example, the image file is in the same directory as the .frx file. Therefore, no relative path exists. By contrast, the contents of the FRX.Picture column in the copy that is available to the Report Builder is relative to the temporary file location instead of relative to the actual .frx file.</li>  Return your environment to the standard Report Builder environment by using the following code: _REPORTBUILDER = HOME + &quot;REPORTBUILDER.APP&quot; </li></ol>

<div class="status_section">

STATUS
This behavior is by design.

<div class="references_section">