Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Set Dir and taking snapshots

Author
Message
Jediam
14
Years of Service
User Offline
Joined: 14th Apr 2012
Location:
Posted: 7th Jun 2012 02:41
Hello,

I can't figure out why the subject matter works when built and run within DBPro, but not when executed outside of it. Here's some code:
I call CreatePictureDirectory() before my main loop, and TakeScreenShot(ScreenFileVal) is called when the user presses a key. As mentioned before, the code runs fine within DBP and I'm able to get the directory created and pictures taken, but I get error messages when I try to run the standalone outside of DBP. If I run the standalone with or without images in the created Pictures folder, I get an images error message. If I delete the folder I get a path error message. Any help as always is appreciated.
enderleit
19
Years of Service
User Offline
Joined: 30th May 2007
Location: Denmark
Posted: 9th Jun 2012 05:08 Edited at: 9th Jun 2012 05:33
Not sure if this is why, but you seem to do the same thing if the file exists or not...
Also you ask if the file "Screenshot6.bmp" exists but reads/writes "Screenshot0.bmp". This might be fine for saving(since you may not want to overwrite), but when loading it is not.

You probably shouldn't use a global as a parameter to the function. Not sure how this works in DBPro, but there might be some local/global conflict causing the ScreenFileVal variable to have an unintended value.

I made something new for you.



Jediam
14
Years of Service
User Offline
Joined: 14th Apr 2012
Location:
Posted: 9th Jun 2012 22:34
Hello enderleit,

Thank you for getting back to me. I appreciate the time you have taken to write this code. I tested it as it's been written, and it produces the pictures folder but doesn't save the image for some reason. I'm not sure why, the code looks sound and I'm sure you have no problems on your end. I also implemented the suggestions you made for the code I wrote and posted. The reason I had set ScreenFileVal to 6 was to bypass the images already loaded (1 through 5). I don't mind for now if the images get overwritten, that can be fixed later (I imagine) using a Write/Read command to a .dat file, which would update ScreenFileVal (or its equivalent) every time TakeScreenShot() is called. The error message is "Unknown image error at line 'the particular line goes here'". The line mentioned is the save image line. Your code seems to work fine within DBPro when I transferred it to my program and disabled the functions I was using. However, I get the same problem with your function that I am having with my functions when I try to run the standalone. Thanks again for your interest and help with this problem.
enderleit
19
Years of Service
User Offline
Joined: 30th May 2007
Location: Denmark
Posted: 10th Jun 2012 08:11
Sounds like you may be trying to save an image that doesn't exist. Make sure that you have created the image that you want to save before calling the TakeScreenShot(img) function.

Also when calling the TakeScreenShot(img) function you have to put the image you want to save as the parameter to the function.

Ie. if you want to save image 51 you type TakeScreenShot(51).

Jediam
14
Years of Service
User Offline
Joined: 14th Apr 2012
Location:
Posted: 11th Jun 2012 23:23
I'm using the get image command to retrieve images. It works fine within DBP but not in the standalone, which leads me to believe that it is not the image but the path itself (the path works as well within DBP, but not the standalone). I also upgraded to the latest version 7.62, but still have the problem. I think this might be a bug, but haven't seen anyone report anything similar on the bug report thread. The bug (if it exists) would be setting the directory (Set Dir) not working properly when run in standalone applications. I say this because the path is not being found when the standalone is run. So if this the case, if I already have the destination folder created, the image is going to be invalid as well because the destination folder isn't being found first within the program. I hope this makes sense, because I'm not sure myself if this is definitely the problem. For instance, when you run your sample code both within DBP and as a standalone application, I'm sure they run fine. With me, however, the standalone will not work. Thanks again for your time and help.
Jediam
14
Years of Service
User Offline
Joined: 14th Apr 2012
Location:
Posted: 13th Jun 2012 14:42
Hello enderleit,

I apologize for my error; your code runs fine and produces pictures folder and the images as you intended, but only if executed within DBP, not as the standalone. I'm just wondering if the code you wrote works on your computer as a standalone. If it doesn't, I think it is worth mentioning because it works fine in DBP. If others try your code and experience the same problem, it must be a bug. There is no reason why something should compile and run properly within DBP and not as a standalone.
enderleit
19
Years of Service
User Offline
Joined: 30th May 2007
Location: Denmark
Posted: 13th Jun 2012 23:20
It works fine as a standalone for me also.

Which version of windows are you using?
There is a DBP v 7.7 release candidate which fixes some problems with Windows 7.

Jediam
14
Years of Service
User Offline
Joined: 14th Apr 2012
Location:
Posted: 14th Jun 2012 02:43
Hello again,

I wound up getting the code to work on the standalone as well. All it took was to run the executable as an Administrator. Don't know what made me think of it. To answer your question, I'm using Windows 7. I don't know if by downloading DBP v 7.7 if it would automatically create an executable which by default runs under Administrative privaleges. Thanks alot for your help. By the way, I had an idea of an enemy for ROFL. Let me know if you are interested. Seems like a cool game. Take Care

Login to post a reply

Server time is: 2026-07-07 17:08:26
Your offset time is: 2026-07-07 17:08:26