Difference in execution between IDE and EXE

Just starting out? Need help? Post your questions and find answers here.
drahneir
Enthusiast
Enthusiast
Posts: 105
Joined: Tue Jul 18, 2006 4:18 pm
Location: JO42RM

Difference in execution between IDE and EXE

Post by drahneir »

Hello,

in my application I printout some data from a database on a printer. Additionally there are 2 images which should also be printed.
When I run the exe file, evererything is printed except the images. When I start the program from the IDE, all inclusive the images is printed.

Code: Select all

     UseTIFFImageDecoder()
     LoadImage(#Image_0, "XXX.tif")
     LoadImage(#Image_1, "YYY.tif")
     .
     ResizeImage(#Image_0, 120, 280)
     ResizeImage(#Image_1, 200, 200)
     .
     DrawImage(ImageID(#Image_0), x0, y0)
     DrawImage(ImageID(#Image_1), x1, y1)
What is the reason for this different behaviour?

Regards
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

Maybe the images can't be loaded if the current directory is different?
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

Any chance to have a small working snippet showing the problem ?
omit59
User
User
Posts: 63
Joined: Fri Mar 11, 2005 8:41 am
Location: Finland

Post by omit59 »

@drahneir

I had same of kind problem today, dont know if it has got anything to do with yours?

My program (made with PB) was moved to another computer which has NT4 system, and at the same time printing pictures was stopped, everything else prints ok, just pictures are missing.

Tried using drawimage and API StretchBlt, but neither prints pictures.
I have no idea what to do...

So anybody any tips?

Timo
drahneir
Enthusiast
Enthusiast
Posts: 105
Joined: Tue Jul 18, 2006 4:18 pm
Location: JO42RM

Post by drahneir »

Hello,

@ Trond: the PB files, the .exe file and the images are all in the same directory.


@ Fred: I will see, what I can do.
drahneir
Enthusiast
Enthusiast
Posts: 105
Joined: Tue Jul 18, 2006 4:18 pm
Location: JO42RM

Post by drahneir »

Gentlemen,

the problem isn't a problem any more. Thanks Trond, who mentioned the directory, I put in the full path of the image files into the LoadImage() commands, and now it works as it should do.
I didn' put in the full path before, because it is somewhat lengthy and, as I wrote before, it worked when I tested it from the IDE.
Thanks for your help.


Regards
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

drahneir wrote:Hello,
@ Trond: the PB files, the .exe file and the images are all in the same directory.
Exactly. The current directory has nothing to do with the executable directory. It could be something completely different, and then loading the images will fail, because all paths are relative to the current directory (not the exe directory).
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Post by ts-soft »

Code: Select all

GetPathPart(ProgramFilename())
or API GetModuleFileName works only with the exe, not in the IDE.
If you only compile in the IDE (no exe-creation) you should use this:

Code: Select all

GetCurrentDirectory()
The PBCompiler sets the correkt Path for this function.
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
Post Reply