0 registered members (),
1,459
guests, and 9
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Problem copying BMP file from one folder to another
#225323
09/04/08 00:26
09/04/08 00:26
|
Joined: Feb 2002
Posts: 288 California, USA
jaknine
OP
Member
|
OP
Member
Joined: Feb 2002
Posts: 288
California, USA
|
In this current project I have it set up so F11 takes a screen shot. My SAVEDIR is set to "data" and all screen shots are automatically saved in there as that's how 3DGS works. Since I have other things in the data folder (settings files, etc.) that are also saved there by the engine, I want to have the screen shots in their own folder, like "screenshots". I am using the following code. Basically it takes a sequentially numbered screen shot, puts it in the data folder, then copies it into the screenshots folder (I haven't written the part to delete the original yet; that's coming). It all works great except that the resulting file in the screenshots folder is only 0k in file size. Something is going wrong somewhere and I can't seem to figure out where. Can anyone spot the problem? Thanks!
var shotfilehandle;
var shotfilehandle1;
var theShotNum;
STRING theScreenShot = "#64";
STRING theNewShot = "#64";
STRING theShotNumString ;
action take_shot(){
str_cpy(theScreenShot, "image_");
str_cpy(theNewShot, "screenshots\\");
shotfilehandle1 = file_open_read("shots.num");
theShotNum = file_var_read(shotfilehandle1);
file_close(shotfilehandle1);
theShotNum += 1;
wait(1);
snd_play(camera_click,100,0);
wait(1);
str_for_num(theShotNumString,theShotNum);
str_cat(theScreenShot, theShotNumString);
str_cat(theScreenShot, ".bmp");
str_cat(theNewShot, theScreenShot);
file_for_screen("image_.bmp",theShotNum); // saves a screenshot with a sequential suffix
shotfilehandle = file_open_write("shots.num");
file_var_write (shotfilehandle, theShotNum);
file_close(shotfilehandle);
file_cpy (theNewShot, theScreenShot);
str_cpy(theScreenShot, "image_");
str_cpy(theNewShot, "screenshots\\");
wait(1);
}
|
|
|
Re: Problem copying BMP file from one folder to another
[Re: jaknine]
#225400
09/04/08 11:54
09/04/08 11:54
|
Joined: Oct 2004
Posts: 1,655
testDummy
Serious User
|
Serious User
Joined: Oct 2004
Posts: 1,655
|
Perhaps, this will be of some help. (Probably not.) C-Script file copy; tested Use \\ as path separator and workdir (ifdef DEVELOP) and exedir (ifelse) respectively.
/************************************
filef_copy
*************************************/
var file_nFrom = 0;
var file_nTo = 0;
var file_nByte;
function filef_copy(_sFrom, _sTo) {
var ret1; ret1 = 0;
file_nByte = 0;
file_nFrom = 0;
file_nTo = 0;
if (_sFrom == 0) {
return(0);
}
if (_sTo == 0) {
return(0);
}
file_nFrom = file_open_read(_sFrom);
if (file_nFrom == 0) {
error("!error filef_copy: file from not found!");
return(0);
}
file_nTo = file_open_write(_sTo);
if (file_nTo == 0) {
error("!error filef_copy: file to not found!");
return(0);
}
while(1) {
file_nByte = file_asc_read(file_nFrom);
if (file_nByte != -1) {
file_asc_write(file_nTo, file_nByte);
ret1 += 1;
} else {
break;
}
}
file_close(file_nFrom);
file_close(file_nTo);
return(ret1);
}
|
|
|
|