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.
` *** TEST CODE ***
for i=0 to 100
dot rnd(255), rnd(255), 0xffffffff
next i
get image 1, 0, 0, 256, 256
TakeScreenShot(1)
end
` *** TEST CODE ***
` img = The image number you want to save.
` imgFileNo = The number to append to the filename.
` found = A boolean that tells us if we have found a valid filename.
function TakeScreenShot(img as integer)
imgFileNo = 0
found as boolean
found = 0
` Create the Pictures directory if it doesn't exist already.
if path exist("Pictures") = 0
make directory "Pictures"
endif
` Find an available number for the screenshot file.
while found = 0
if file exist("Pictures/ScreenShot"+str$(imgFileNo)+".bmp") = 0
found = 1
else
inc imgFileNo, 1
endif
endwhile
` Save the screenshot.
save image "Pictures/ScreenShot"+str$(imgFileNo)+".bmp", img
endfunction