Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
3 registered members (AndrewAMD, Ayumi, NewbieZorro), 14,141 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
Script Crash!!! :P #411107
11/13/12 10:36
11/13/12 10:36
Joined: Nov 2011
Posts: 139
India
Yashas Offline OP
Member
Yashas  Offline OP
Member

Joined: Nov 2011
Posts: 139
India
Code:
int WriteProfileToFile(STRING * ProfileFile,UserProfile* profile)
{
	STRING * ResultString;
	var filehandle = file_open_write(ProfileFile);
	
	file_str_write(filehandle,profile->Password);
	file_str_write(filehandle,",");
	
	file_str_write(filehandle,profile->Name);
	file_str_write(filehandle,",");
	
	str_for_num(ResultString,profile->DOB.day);
	error(ResultString);
	file_str_write(filehandle,ResultString);
	file_str_write(filehandle,",");
	str_for_num(ResultString,profile->DOB.month);
	file_str_write(filehandle,ResultString);
	file_str_write(filehandle,",");
	str_for_num(ResultString,profile->DOB.year);
	file_str_write(filehandle,ResultString);
	file_str_write(filehandle,",");

	str_for_num(ResultString,profile->DOC.day);
	file_str_write(filehandle,ResultString);
	file_str_write(filehandle,",");
	str_for_num(ResultString,profile->DOC.month);
	file_str_write(filehandle,ResultString);
	file_str_write(filehandle,",");
	str_for_num(ResultString,profile->DOC.year);
	file_str_write(filehandle,ResultString);
	file_str_write(filehandle,",");
	

	
	file_close(filehandle);
	return 0;
}


The above code is causing Script Crash , error gives "Script Crash in WriteProfileToFile."


This how I submit the arguments and call WriteProfileToFile.
Code:
void RegisterUser ()
{
	STRING * ProfileFile = str_cat(str_cat(str_create("Accounts\\"),((LoginPrompt_Name->pstring)[0])),".ini");
	if(file_exists(ProfileFile))
	{
		snd_play(ErrorSound,MenuVolume,MenuBalance);
		(LoginStatus_Message->pstring)[0] = "Username already in use(Choose another Username)";
		LoginStatus_Message->red = 255;
		LoginStatus_Message->blue = 0;
		LoginStatus_Message->green = 0;
		return;	
	}
	else
	{
		ActiveProfile.DOC.day = sys_day;
		ActiveProfile.DOC.month = sys_month;
		ActiveProfile.DOC.year = sys_year;
		ActiveProfile.DOB.day = 0;
		ActiveProfile.DOB.month = 0;
		ActiveProfile.DOB.year = 0;
		
		ActiveProfile.BPI = 0;
		ActiveProfile.XP = 10;
		
		ActiveProfile.RegionSpeed = 0;
		ActiveProfile.RegionMemory = 0;
		ActiveProfile.RegionAttentition = 0; 
		ActiveProfile.RegionFlexibility = 0;
		ActiveProfile.RegionLogic = 0;
		ActiveProfile.MostCommonRegion = 0;
		ActiveProfile.SelectedRegion = 0;
		ActiveProfile.BestRegion = 0;
		
		ActiveProfile.Name = (LoginPrompt_Name->pstring)[0];
		ActiveProfile.Password = (LoginPrompt_Pass->pstring)[0];
		WriteProfileToFile(ProfileFile,&ActiveProfile);
		(LoginStatus_Message->pstring)[0] = "User Profile Registered";
		LoginStatus_Message->red = 160;
		LoginStatus_Message->blue = 160;
		LoginStatus_Message->green = 160;
		LoginUser();
	}
}


Just want to know whats causing the script crash.


Thanks and Regards!


Keep smiling laugh
http://translation.babylon.com/ - Translate many languages
Re: Script Crash!!! :P [Re: Yashas] #411109
11/13/12 10:41
11/13/12 10:41
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
Remember our discussion about intializing pointers?


Always learn from history, to be sure you make the same mistakes again...
Re: Script Crash!!! :P [Re: Uhrwerk] #411118
11/13/12 11:36
11/13/12 11:36
Joined: Nov 2011
Posts: 139
India
Yashas Offline OP
Member
Yashas  Offline OP
Member

Joined: Nov 2011
Posts: 139
India
Where is the uninitialized pointer??
I have initilized all I feel.


Keep smiling laugh
http://translation.babylon.com/ - Translate many languages
Re: Script Crash!!! :P [Re: Yashas] #411120
11/13/12 11:59
11/13/12 11:59
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
It almost slaps in your face. First line in WriteProfileToFile. ^^

And RegisterUser again contains a memory leak. tongue


Always learn from history, to be sure you make the same mistakes again...
Re: Script Crash!!! :P [Re: Uhrwerk] #411125
11/13/12 13:32
11/13/12 13:32
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Kartoffel Offline
Expert
Kartoffel  Offline
Expert

Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Originally Posted By: Uhrwerk
And RegisterUser again contains a memory leak. tongue

It's STRING * ProfileFile = "[...]";, isn't it?
( I'm just asking because I'm not sure whether I am right or not. smile )

Last edited by Kartoffel; 11/13/12 13:39.

POTATO-MAN saves the day! - Random
Re: Script Crash!!! :P [Re: Kartoffel] #411126
11/13/12 13:39
11/13/12 13:39
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
You are. :-)


Always learn from history, to be sure you make the same mistakes again...
Re: Script Crash!!! :P [Re: Uhrwerk] #411127
11/13/12 13:43
11/13/12 13:43
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Kartoffel Offline
Expert
Kartoffel  Offline
Expert

Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
thanks.
again what learned grin


POTATO-MAN saves the day! - Random
Re: Script Crash!!! :P [Re: Kartoffel] #411141
11/13/12 16:51
11/13/12 16:51
Joined: Nov 2011
Posts: 139
India
Yashas Offline OP
Member
Yashas  Offline OP
Member

Joined: Nov 2011
Posts: 139
India
Someone ban me for a day else I will not learn :'(
I think I am REALLY STUPID.

btw Thanks


Keep smiling laugh
http://translation.babylon.com/ - Translate many languages
Re: Script Crash!!! :P [Re: Yashas] #411142
11/13/12 17:18
11/13/12 17:18
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Kartoffel Offline
Expert
Kartoffel  Offline
Expert

Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Quote:
Someone ban me for a day else I will not learn :'(
I think I am REALLY STUPID.

btw Thanks
lol, what?

is this related to the memory leak?


POTATO-MAN saves the day! - Random
Re: Script Crash!!! :P [Re: Yashas] #411147
11/13/12 18:49
11/13/12 18:49
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
Originally Posted By: Yashas
I think I am REALLY STUPID.

Relax. You just overlooked something. Happens to everyone sometimes.

@Kartoffel: I guess it's related to the unitialized pointer. We had exactly this topic a few days ago.


Always learn from history, to be sure you make the same mistakes again...
Page 1 of 2 1 2

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

Gamestudio download | 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