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
1 registered members (AbrahamR), 717 guests, and 4 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
Cant write into files #338116
08/15/10 21:34
08/15/10 21:34
Joined: Feb 2005
Posts: 3,687
Hessen, Germany
T
Tempelbauer Offline OP
Expert
Tempelbauer  Offline OP
Expert
T

Joined: Feb 2005
Posts: 3,687
Hessen, Germany
hi
maybe i get stupid, but i cant write a string in a file. this is my code:
Code:
int foo(STRING* file)
{	
	int f = file_open_write(file);
	if(f!=0)
	{
		STRING* out = "test";
		file_str_write(f,out);
		file_close(f);
	}
	
}



i call this function in main using
Code:
foo("E:\\Dokumente\\out.txt");



i get "Crash in foo: SYS" (Error E1513)
the exception is thrown by the file_str_write-function (i´ve debugged it)

the file is created on disk
the directory is a normal dir. other programs can write files in it without restrictions


where is the problem?? this is driving me insane...

Re: Cant write into files [Re: Tempelbauer] #338117
08/15/10 21:38
08/15/10 21:38
Joined: Apr 2007
Posts: 3,751
Canada
WretchedSid Offline
Expert
WretchedSid  Offline
Expert

Joined: Apr 2007
Posts: 3,751
Canada
Code:
STRING* out = "test";



This is not an initialized string object. It's a STRING pointer pointing to a CString. What you need is str_create or just pass a pointer to a STRING object to the function.


Shitlord by trade and passion. Graphics programmer at Laminar Research.
I write blog posts at feresignum.com
Re: Cant write into files [Re: Tempelbauer] #338120
08/15/10 21:39
08/15/10 21:39
Joined: Sep 2009
Posts: 993
Budapest
Aku_Aku Offline
User
Aku_Aku  Offline
User

Joined: Sep 2009
Posts: 993
Budapest
Perhaps not int but var.
var f = file_open_write(file);
In the manual:
file_str_write (var handle, STRING* string)

Last edited by Aku_Aku; 08/15/10 21:58.
Re: Cant write into files [Re: Tempelbauer] #338121
08/15/10 21:39
08/15/10 21:39
Joined: May 2007
Posts: 2,043
Germany
Lukas Offline

Programmer
Lukas  Offline

Programmer

Joined: May 2007
Posts: 2,043
Germany
STRING* out = "test";

This is wrong and I think in the most recent A7/A8 version this should return a sytax error. Define your string outside a function, or like this:

STRING* out = str_create("test");

EDIT: Damn, two people were faster than me. The var thing could also be an issue, because the var that is returned gets an implicit int cast.

Last edited by Lukas; 08/15/10 21:41.
Re: Cant write into files [Re: WretchedSid] #338122
08/15/10 21:40
08/15/10 21:40
Joined: Feb 2005
Posts: 3,687
Hessen, Germany
T
Tempelbauer Offline OP
Expert
Tempelbauer  Offline OP
Expert
T

Joined: Feb 2005
Posts: 3,687
Hessen, Germany
now:
Code:
int foo(STRING* file)
{	
	var f = file_open_write(file);
	if(f!=0)
	{
		STRING* out = str_create("test");
		file_str_write(f,out);
		file_close(f);
	}
	
}



edit: aku is right. the problem is the int var

thanks fpr the help

Last edited by Tempelbauer; 08/15/10 21:52.

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