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



The information in this article 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

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

    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 "prtscrn.jpg"                                                              
    
    CommandClauses.File = C:\TEMP\TESTMETADATA.FRX
    
    REC  frx.PICTURE                                                                
    --- --------------------------------
      6 "..\prtscrn.jpg"                                                           
    
    REC  fullpath(frx.PICTURE, commandClauses.File)
    --- --------------------------------
      6 C:\PRTSCRN.JPG
    
    REC  fullpath(frx.PICTURE, ADDBS(SYS(2023)))
    --- --------------------------------
      6 C:\TEMP\PRTSCRN.JPG
  6. 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.
  7. Return your environment to the standard Report Builder environment by using the following code:
    _REPORTBUILDER = HOME() + "REPORTBUILDER.APP"

STATUS

This behavior is by design.

REFERENCES


Modification Type:MajorLast Reviewed:7/3/2006
Keywords:kbprb kbReportWriter KB914965 kbAudDeveloper