Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (ozgur, degenerate_762, 7th_zorro), 1,075 guests, and 0 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
function to save string to file #212130
06/20/08 15:02
06/20/08 15:02
Joined: Nov 2003
Posts: 433
The Netherlands
T
Toon Offline OP
Senior Member
Toon  Offline OP
Senior Member
T

Joined: Nov 2003
Posts: 433
The Netherlands
I've written a function to save a certain string to a file but it says that when it tries to write the string the string is an invalid pointer

here is the code i use

Code:
string temp_save_str1[100];
string temp_save_str2[100];

var_nsave save_handle;

function save_str(string_,dir_,number_)
{
	str_cpy(temp_save_str1,dir_);
	str_cat(temp_save_str1,"\\");
	str_cat(temp_save_str1,"\\");
	
	if(number_ < 10)
	{
		str_cat(temp_save_str1,"0");
	}
	str_for_num(temp_save_str2,number_);
	
	str_cat(temp_save_str1,temp_save_str2);
	
	str_cat(temp_save_str1,".txt");
	
	wait(1);
	str_cpy(temp_save_str2,string_);
	
	sleep(1);
	
	save_handle = file_open_write(temp_save_str1);
	
	file_str_write(save_handle,temp_save_str2);

	//file_close(save_handle);
}

function test()
{
	save_str("save this data in text file","gamedata",1);
}

on_z = test();


Re: function to save string to file [Re: Toon] #212138
06/20/08 15:48
06/20/08 15:48
Joined: Jan 2004
Posts: 3,023
The Netherlands
Helghast Offline
Expert
Helghast  Offline
Expert

Joined: Jan 2004
Posts: 3,023
The Netherlands
have you checked your output of the string?

it seems you create a string called:

"gamedir\\\\01.txt"

you sure that "\\\\" is correct?

and yes, close the handle again wink

otherwise it looks fine to me...
I'm just not sure if you can access folder from there too, have you tried it without creating the directory string too?

regards,


Formerly known as dennis_fantasy
Portfolio - http://www.designorhea.com/
Project - http://randomchance.cherrygames.org/
Re: function to save string to file [Re: Toon] #212346
06/21/08 17:40
06/21/08 17:40
Joined: Aug 2002
Posts: 673
Las Cruces, NM
JimFox Offline
User
JimFox  Offline
User

Joined: Aug 2002
Posts: 673
Las Cruces, NM
Hi,
This is a wild guess, but perhaps the compiler does not like the sequence \". Change your characters being saved to see if that is your problem. Try something like 99 instead of \\ and see if that works.
Blessings.........
Jim


Jim

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