Gamestudio Links
Zorro Links
Newest Posts
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AbrahamR, 1 invisible), 858 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
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
J
jaknine Offline OP
Member
jaknine  Offline OP
Member
J

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!

Code:
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
T
testDummy Offline
Serious User
testDummy  Offline
Serious User
T

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.
Code:
/************************************
	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);
}


Re: Problem copying BMP file from one folder to another [Re: testDummy] #225782
09/05/08 23:23
09/05/08 23:23
Joined: Feb 2002
Posts: 288
California, USA
J
jaknine Offline OP
Member
jaknine  Offline OP
Member
J

Joined: Feb 2002
Posts: 288
California, USA
Thanks for trying. The code still didn't work for me but I figured out a solution to my problem anyway.

The manual implies that the screen shots can only be saved into the SAVEDIR folder, but I found out that you can add a path with no problem. So instead of copying the file out of "data" and into "screenshots" I just save it to "screenshots" to begin with.

The manual also says that file_cpy only works within the SAVEDIR folder but it turns out you can use paths with that one also.

Anyway, thanks again. Problem solved.

Re: Problem copying BMP file from one folder to another [Re: jaknine] #225879
09/06/08 14:46
09/06/08 14:46
Joined: Oct 2004
Posts: 1,655
T
testDummy Offline
Serious User
testDummy  Offline
Serious User
T

Joined: Oct 2004
Posts: 1,655
It's good that the problem is solved.

Indeed, file_cpy seems to copy correctly from and to paths other than the save_dir.




Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1