Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/19/24 18:45
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
4 registered members (AndrewAMD, Ayumi, kzhao, 7th_zorro), 739 guests, and 7 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
[A6.60] Random problem with str_for_num #269635
06/03/09 21:30
06/03/09 21:30
Joined: Feb 2006
Posts: 2,185
mpdeveloper_B Offline OP
Expert
mpdeveloper_B  Offline OP
Expert

Joined: Feb 2006
Posts: 2,185
I've tested, and tested, and tested some more....this is really starting to get to me. Another odd, random bug.

I have a string 'dipswtxt' which is used to write out text on the screen, and shows things like volumes and other things. I use a Text to show it on the screen, there are multiple lines, dipswtxt is defined like this:

string dipswtxt[9999];

which is fine, that means that dipswtxt has 9999 characters it can hold.

Now, sample code:

Code:
str_cat(dipswtxt, "\n               Sound Volume ->            ");
////put sound volume code here
str_for_num(tmp_str3, sfx_volume);
str_cat(dipswtxt, tmp_str3);


simple enough, right? It should output something like this:

Code:
Sound Volume ->            25


'25' being the number of the sfx_volume. Well here's the thing, most of the time it shows up like that, but sometimes it shows up like this:

Code:
Sound Volume ->            T


.....T? Where the hell did T come from?

Before you ask, yes sfx_volume is a number, no it is not a vector, and yes this is the only code partaining to turning that particular variable into a string. I have no idea why there is a problem. This bug is soooo random, and it doesn't only happen on one system, on another system instead of a 'T', there is a '\'.

How do I fix this? It's random and I have no way of testing it, I've noticed this problem with str_for_num or multiple occasions, is there a way to fix it? (don't say get A7)


- aka Manslayer101
Re: [A6.60] Random problem with str_for_num [Re: mpdeveloper_B] #269683
06/04/09 07:20
06/04/09 07:20
Joined: Jan 2004
Posts: 3,023
The Netherlands
Helghast Offline
Expert
Helghast  Offline
Expert

Joined: Jan 2004
Posts: 3,023
The Netherlands
could tmp_str3 somehow get filled with the letter T on the same frame as your str_for_num?
try clearing the string before using it otherwise.

This has alwasy worked for me under A6, never had that random error.

regards,


PS: get A7 :P


Formerly known as dennis_fantasy
Portfolio - http://www.designorhea.com/
Project - http://randomchance.cherrygames.org/
Re: [A6.60] Random problem with str_for_num [Re: Helghast] #269704
06/04/09 09:01
06/04/09 09:01
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
We had indeed some rare reports by other users for wrong strings on A6, but could never reproduce the problem. We assumed that some other parts of the scripts were overwriting string memory, maybe through loading a damaged file or using a wrong array index. Under A7, strings have some protection against overwriting, but not under A6.

Try to trace down the problem with a test script that only contains the string function, but not the rest of your code. If that test script works, the problem lies elsewhere. You can then move in the rest of your code until the problem reappears.

Re: [A6.60] Random problem with str_for_num [Re: jcl] #269790
06/04/09 16:13
06/04/09 16:13
Joined: Feb 2006
Posts: 2,185
mpdeveloper_B Offline OP
Expert
mpdeveloper_B  Offline OP
Expert

Joined: Feb 2006
Posts: 2,185
Well see here's the thing.

@Helghast: I made tmp_str3 specifically for these lines of code. The reason I made a new string is because I thought this might be it. Believe me, there is no way that the string is being rewritten before it shows on screen.

@jcl: I'm not so sure, the bug just randomly popped up one day. Then it went away for a few months, and now it's back...magically. See, not all my strings mess up, just a few of them. Originally the problem was only with a timer, I tried to fix it by making a new string that is specifically for that timer and a new variable that held the proper number. It worked for a while, but that can't be the problem because it changed again.

I also thought it might be a plugin we were using, but I removed it and there was no change. I also don't think it's a corrupt file because if it were any of the files we use, models, levels, images, or scripts, the engine would crash. As of now, these are the only files being used in the game.

See the thing is that like I said, not all the functions that use str_to_num do it. I had a similar problem with another str_ function recently, although I cannot remember the function. Once I made my own variation of the function it worked perfectly.

By the way, I tested copying the actual text to a txt file, and i tested it with a TrueType font, the characters it's actually giving me is a T and two odd symbols.

The only thing I can think of is that while it's trying to convert the number to a string, the string becomes corrupt and inputs the wrong string info.


- aka Manslayer101
Re: [A6.60] Random problem with str_for_num [Re: mpdeveloper_B] #269805
06/04/09 18:14
06/04/09 18:14
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Is there any way you can "booby-trap" the code so you can find out the
actual value of sfx_volume when the output goes wonky?
The actual value mayt give us a clue...


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: [A6.60] Random problem with str_for_num [Re: EvilSOB] #269832
06/04/09 19:46
06/04/09 19:46
Joined: Feb 2006
Posts: 2,185
mpdeveloper_B Offline OP
Expert
mpdeveloper_B  Offline OP
Expert

Joined: Feb 2006
Posts: 2,185
the actual value is between 10 and 100. I am 100% sure the variable is outputting correctly. The problem is not in the variable. I have a slider for adjusting the volume, which is then set to the actual variable (sfx_volume = int(sfx_volume);) so that the variable is set to an absolute number, and the number does not have decimals, and is not set into a vector.

I can set the variable exactly, using the console and would get the same problem.

I think that something is causing the str_for_num function to go crazy, but only in specific things.

For instance, recently I was setting a variable for a level to load, once you finish a game it loads the next level. The levels are named level01.wmb - level10.wmb . Now, the level loading worked perfect until it got to level 10, which, when i checked the code, was something like this:

level-----.wmb

the ----- being odd symbols that don't make any sense. there was no number or anything, and the problem is not the variable or the actual string...the problem lies somewhere in the str_for_num turnover. I'm not blaming this on the function, but there is something that is causing it to go awry.

And also, I've checked my list of functions and variables, there is no variable or function that i named str_for_num, so that's not it.

Believe me, I've tested this many times, I know for sure that the variables and actual strings are not the cause.

I have thought of one thing that may lead to it. Is there a limit to the amount of strings that you can have defined? I think if this is possible than it may be the culprit, I may have too many strings defined. ( I have around 180 or so defined )

edit: to confirm that the variables are correct, I used a watch and debug mode. They are set properly.

edit2: I'm starting to debate about writing a function that copies the variable to a text file and copies that to a string, it would possibly eliminate the problem, but I don't want to have to do that to fix it :P

Last edited by mpdeveloper_B; 06/04/09 20:00.

- aka Manslayer101
Re: [A6.60] Random problem with str_for_num [Re: mpdeveloper_B] #269932
06/05/09 09:25
06/05/09 09:25
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
str_for_num is unlikely to contain a random bug because that's a very simple function. It's probably something else.

Can you do the test script that I suggested, and if the problem then still happens, send it to Support? We'll then look into this.

Re: [A6.60] Random problem with str_for_num [Re: jcl] #270021
06/05/09 15:25
06/05/09 15:25
Joined: Feb 2006
Posts: 2,185
mpdeveloper_B Offline OP
Expert
mpdeveloper_B  Offline OP
Expert

Joined: Feb 2006
Posts: 2,185
It doesn't. That's what's so odd about it.


- aka Manslayer101
Re: [A6.60] Random problem with str_for_num [Re: mpdeveloper_B] #270597
06/08/09 22:43
06/08/09 22:43
Joined: Feb 2006
Posts: 2,185
mpdeveloper_B Offline OP
Expert
mpdeveloper_B  Offline OP
Expert

Joined: Feb 2006
Posts: 2,185
I never found what the problem was so I just made my own function for converting variables to strings :P.

You can close the thread.


- aka Manslayer101

Moderated by  old_bill, Tobias 

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