Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Report doesn't find image

Status
Not open for further replies.

jimstarr

Programmer
Feb 6, 2001
975
US
I have a report (VFP9) which contains an image (actually 12 of them) whose actual content is set at run time depending on what language the user chooses to run the report in. So, for example, if the language is Japanese the image is japan01.tif; if Korean it's korea01.tif, etc. The "Control source type" is set to "Expression or variable name" and the variable name is img01.

So the run time code right before calling the report is something like:

DO CASE
CASE languagex = 'japanese'
img01 = 'c:\amps\data\japan01.tif'
CASE languagex = 'korean'
img01 = 'c:\amps\data\korea01.tif'
.
.
.
ENDCASE

I am explicitly including these images in the project. However when running from an exe and the user chooses Preview or Print from the app's report screen the image is not found. If he chooses PDF (I'm using XFRX) the image is found and the report runs fine.

DEFAULT and PATH are set once in the main program and never explicitly changed.

Seems that img01 needs to be set differently, but to what?

Thanks!


Jim




 
I would try a couple of tests.

Firstly I would add a field text box to the report and make the control source img01 - run the report and make sure the value you want is presented C:\AMPS...

Next I would add another and use img01 as the parameter for a file exists check IIF(FILE(img01),"Exists","Not There")

Martin

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.
 
Jim,

What scope declaration do you use with img01?

In order for the report to see the variable name, it needs to be PUBLIC or PRIVATE. If it is local to the routine that calls the report, the report won't see it (although that doesn't completely explain the behaviour you are seeing).

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro tips, advice, training, consultancy
Custom software for your business
 
Mike, the app only goes through XFRX when the user selects PDF. Otherwise it's a straight REPORT FORM ... PREVIEW.

Jim
 
Jim

Have you tried my tests?

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.
 
Griff,

Tried your tests. Textbox shows c:\amps\data\japan01.tif, as expected, and file exists.

Jim
 
Hi, Jimstarr

In "Expression or variable name", put a function like Img2Print()

Function Img2Print
Do case
CASE languagex = 'japanese'
RETURN 'c:\amps\data\japan01.tif'
CASE languagex = 'korean'
RETURN 'c:\amps\data\korea01.tif'
...
ENDCASE
Sorry for my poor english

JPG
 
Hi JPG,

That function will return the same string I'm already using. Why do you think it would work better?

Jim
 
Jim,

Because usually I use XFRX and I shall always be so.
And it works fine even in preview
(XFRX => PDF)

JpG
 
JPG, I'm not using XFRX when the user selects PREVIEW or PRINT. -Jim
 
I think this is a path problem.

XFRX 'might' be using a different scope for the path to the image files.

VFP File() doesn't use the specified path, it uses the default first.

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.
 
Jim

My user may choice between "With XFRX" for generate PDF or without XFRX (REPORT ... TO PRINTER and REPORT .. To PRINTER PROMP PREVIEW)...
And my image is always OK (image=man, woman or child)

JPG
 
Could you try this udf instead of File()

Code:
FUNCTION MYFILE
	PARAMETER m.FILENAME
	PRIVATE m.FILENAME,m.FLG
	m.FLG = .F.
	IF !EMPTY(m.FILENAME)
		IF ADIR(TMPDIRFILES,m.FILENAME) > 0
			m.FLG = .T.
		ENDIF
	ENDIF
	RETURN(m.FLG)

It allways uses the specified path, and may produce a different result with img01

Code:
 IIF(MYFILE(img01),"Exists","Not There")

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.
 
The solution to this problem is likely to be simple, but I'm out of time. Am going with a workaround.

Thanks for all the replies!

Jim
 
I am explicitly including these images in the project. However when running from an exe and the user chooses Preview or Print from the app's report screen the image is not found.
Since this happens to users in the compiled exe only and the images are compiled into the exe, why not just remove the PATHs? (Unless that would make XFRX fail?)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top