Struct - Saving Strings


Status
Not open for further replies.

ruckage

Certified Guru
Joined
Oct 15, 2006
Messages
659
Hi all, I'm at the part in my game now where I need to think about Hiscores and just need to know if the problem still exists where the system crashes when saving strings. If it does is there a workaround?
 
Why should the system crash when saving/loading strings? To it, they are just binary data, just like executable code.

Unless of course your doing something daft like saving a pointer to the string, and then expecting the string to still be there when you load the pointer back in again... in which case, the "workaround" is don't save the pointer, but the string itself :)
 
Well there are a lot of posts stating that there is a bug in fenix that causes it to crash when saving arrays/structures that contain strings. The Fenixonfire site also says that it is unable to save an array which contains strings. I just need to know if this bug is still present in the latest runtime.
 
Sorted now. Decided to only allow 3 initials to be entered for hi scores which will be stored in the structure as ascii values.
 
Maybe I should check the forum name before replying - I thought you were coding in C :wacko:

Damn "View New Posts" feature ;)

In which case, I'd say the problem is created by whoever converted Fenix to the gp2x. A quick google suggests the PC version doesn't suffer the same problem.
 
Squidge posted on Dec 23 2006 at 01:07 PM said:
Maybe I should check the forum name before replying - I thought you were coding in C :wacko:

Damn "View New Posts" feature ;)

In which case, I'd say the problem is created by whoever converted Fenix to the gp2x. A quick google suggests the PC version doesn't suffer the same problem.
I does however work if you store the strings in int arrays.
 
Last edited by a moderator:
I had exactly this problem with Myriad crashing when loading strings in structs. If you need a hand at all let me know as you're quite welcome to use my scores load/save/reset routines. They allow 10 scores with names up to 10 characters.

Clare.
 
WarmFluffyUK posted on Dec 23 2006 at 04:30 PM said:
I had exactly this problem with Myriad crashing when loading strings in structs. If you need a hand at all let me know as you're quite welcome to use my scores load/save/reset routines. They allow 10 scores with names up to 10 characters.

Clare.

Thanks for the offer of help, got mine working in the end so I'm OK at the moment. I think my new years resolution will be to organise my programs better as blingo is like spagheti junction now (it did start off quite tidy) and is a nightmare to find bugs. getting there now though.
 
Last edited by a moderator:
Easiest way would be not to save the character but save the actual ascii code in an int struct along with the highscores.
 
Quiest posted on Dec 31 2006 at 01:50 PM said:
Easiest way would be not to save the character but save the actual ascii code in an int struct along with the highscores.
And that's exactly what I did :)
 
Last edited by a moderator:
WarmFluffyUK posted on Dec 31 2006 at 04:06 PM said:
Quiest posted on Dec 31 2006 at 01:50 PM said:
Easiest way would be not to save the character but save the actual ascii code in an int struct along with the highscores.
And that's exactly what I did :)

And me too. :p Blingo is proof. Thanks for the reply anyway Quiest.
 
Last edited by a moderator:
WarmFluffyUK posted on Dec 31 2006 at 04:06 PM said:
Quiest posted on Dec 31 2006 at 01:50 PM said:
Easiest way would be not to save the character but save the actual ascii code in an int struct along with the highscores.
And that's exactly what I did :)
Why were you taking so long "writing routines" when I want to bung something in an int instead of a char, I pass an int variable instead of a char.....
 
Last edited by a moderator:
WarmFluffyUK posted on Dec 31 2006 at 04:06 PM said:
Quiest posted on Dec 31 2006 at 01:50 PM said:
Easiest way would be not to save the character but save the actual ascii code in an int struct along with the highscores.
And that's exactly what I did :)
Why were you taking so long "writing routines" when I want to bung something in an int instead of a char, I pass an int variable instead of a char.....
Okay so you have a struct that has strings, things like "Fred", "Dave", "Harry" etc. And you can't just save that struct as it crashes, so you have to convert the strings to integers, i.e. convert each asci char in each name to ints in a new struct and save that. Or you could store them all as ints to begin with and convert them back to asci for displaying, either way, you will have to convert them at some point. And that's what my little functions do!

So how would you do it in fenix? And don't just say "Oh I pass it as an int instead of a char" as that means nothing, lets see your code to save the following:

A struct with the following:

HighScores[1].Name="Fred"
HighScores[2].Name="Harry"
HighScores[3].Name="Oswald"
HighScores[1].Score=100
HighScores[2].Score=6578
HighScores[3].Score=76895

Now save that, your code please!
 
Last edited by a moderator:
WarmFluffyUK posted on Dec 31 2006 at 04:06 PM said:
Quiest posted on Dec 31 2006 at 01:50 PM said:
Easiest way would be not to save the character but save the actual ascii code in an int struct along with the highscores.
And that's exactly what I did :)
Why were you taking so long "writing routines" when I want to bung something in an int instead of a char, I pass an int variable instead of a char.....
Okay so you have a struct that has strings, things like "Fred", "Dave", "Harry" etc. And you can't just save that struct as it crashes, so you have to convert the strings to integers, i.e. convert each asci char in each name to ints in a new struct and save that. Or you could store them all as ints to begin with and convert them back to asci for displaying, either way, you will have to convert them at some point. And that's what my little functions do!

So how would you do it in fenix? And don't just say "Oh I pass it as an int instead of a char" as that means nothing, lets see your code to save the following:

A struct with the following:

HighScores[1].Name="Fred"
HighScores[2].Name="Harry"
HighScores[3].Name="Oswald"
HighScores[1].Score=100
HighScores[2].Score=6578
HighScores[3].Score=76895

Now save that, your code please!
I have no idea how to use structs in fenix, but for gods sake just cast the variables you get the input into as ints. Surely you can just pass an integer array to be printed as asci in fenix? Char's are just 4byte ints, they can be 0 - 255 in value. an unsigned, or signed, int allows all those possible values to be stored in it, so why are you converting?
 
Last edited by a moderator:
WarmFluffyUK posted on Dec 31 2006 at 04:06 PM said:
Quiest posted on Dec 31 2006 at 01:50 PM said:
Easiest way would be not to save the character but save the actual ascii code in an int struct along with the highscores.
And that's exactly what I did :)
Why were you taking so long "writing routines" when I want to bung something in an int instead of a char, I pass an int variable instead of a char.....
Okay so you have a struct that has strings, things like "Fred", "Dave", "Harry" etc. And you can't just save that struct as it crashes, so you have to convert the strings to integers, i.e. convert each asci char in each name to ints in a new struct and save that. Or you could store them all as ints to begin with and convert them back to asci for displaying, either way, you will have to convert them at some point. And that's what my little functions do!

So how would you do it in fenix? And don't just say "Oh I pass it as an int instead of a char" as that means nothing, lets see your code to save the following:

A struct with the following:

HighScores[1].Name="Fred"
HighScores[2].Name="Harry"
HighScores[3].Name="Oswald"
HighScores[1].Score=100
HighScores[2].Score=6578
HighScores[3].Score=76895

Now save that, your code please!
I have no idea how to use structs in fenix, but for gods sake just cast the variables you get the input into as ints. Surely you can just pass an integer array to be printed as asci in fenix? Char's are just 4byte ints, they can be 0 - 255 in value. an unsigned, or signed, int allows all those possible values to be stored in it, so why are you converting?
Forget it, I have explained perfectly well, and you have no idea why we need to do it. You don't understand fenix so what is the point of me telling you. I get the feeling you're on your C trip again.

CLOSED
 
Last edited by a moderator:
Status
Not open for further replies.
Back
Top