Raised This Month: $51 Target: $400
 12% 

[bug] format is acting VERY wierd


  
 
 
Thread Tools Display Modes
Author Message
karlos
Veteran Member
Join Date: Apr 2004
Location: Germany/Poland
Old 08-06-2005 , 14:40   [bug] format is acting VERY wierd
#1

i have this line
Code:
					len += format(menuBody[len], 511-len,"Gives you bonuses when you kill an enemy, these bonuses last for the specified time.^n^nRequires: Blood Lust , Level %d, %d point%s.^n^nNext level [%d] Lasts %.2f second%s, gain is %d%% of maxhealth upon kill, effects of primalscream upon kill, speed increases by %d%% upon kill.^n^n2. Buy %s^n^n0. Exit", HUNGERLEVEL, pointcost, pointcost > 1 ? "s" : "", upgrlevel, hungermaxtime, hungermaxtime == 1.0 ? "" : "s", HUNGERHEALTH, hungerspeed, upgrade_names[upgrade_choice[id]])
(5 tabs at the front)

upgrade_names is max 20 chars long

NOW the problem:
it get this error:
Code:
// F:\extralevels2_reworkdummy.sma(736) : error 075: input line too long (after substitutions)
// F:\extralevels2_reworkdummy.sma(737) : error 017: undefined symbol "upgrade_cho"
// F:\extralevels2_reworkdummy.sma(738) : warning 217: loose indentation
// F:\extralevels2_reworkdummy.sma(738) : error 017: undefined symbol "ice"
// F:\extralevels2_reworkdummy.sma(738) : warning 215: expression has no effect
// F:\extralevels2_reworkdummy.sma(738) : error 001: expected token: ";", but found "]"
// F:\extralevels2_reworkdummy.sma(738) : error 029: invalid expression, assumed zero
// F:\extralevels2_reworkdummy.sma(738) : fatal error 107: too many error messages on one line
the format above is line 737
736 is correct and when i comment that line he says 735...
738 is a closing "}" inside an IF

WHAT IS HAPPENING:
format starts at the very beginning of that line and counts 511 chars forward (1 tab = 1 space)
he ends at "upgrade_names[upgrade_cho" the "o" is char 510 and stops

but why is he counting variable name lenght ?

BUT NOW A MORE WIERD thing:
when i change string lenght to 1024 (inside format 1023)
i only get this error:
Code:
// F:\extralevels2_reworkdummy.sma(736) : error 075: input line too long (after substitutions)
any help ?
__________________
alias White Panther
karlos is offline
Johnny got his gun
Veteran Member
Join Date: Jan 2004
Location: Tokyo
Old 08-07-2005 , 13:46  
#2

You should read the error/warnings as they come and sort them out.
It states that the input line is too long. Actually it is 514 bytes, that's very long, I recommend using shorter ones, not only to make the compiler swallow it but also to make your code legible.

You can rewrite it like this:

Code:
new menuBody[512], HUNGERLEVEL, len, pointcost, id, upgrade_choice[32], upgrlevel, hungermaxtime, HUNGERHEALTH, hungerspeed, upgrade_names[32] new const THEFORMAT[] = "Gives you bonuses when you kill an enemy, these bonuses last for the specified time.^n\ ^n\ Requires: Blood Lust , Level %d, %d point%s.^n\ ^n\ Next level [%d] Lasts %.2f second%s, gain is %d%% of maxhealth upon kill, effects of primalscream upon kill, speed increases by %d%% upon kill.^n\ ^n\ 2. Buy %s^n\ ^n\ 0. Exit" len += format(menuBody[len], 511-len, THEFORMAT, HUNGERLEVEL, pointcost, pointcost > 1 ? "s" : "", upgrlevel, hungermaxtime, hungermaxtime == 1.0 ? "" : "s", HUNGERHEALTH, hungerspeed, upgrade_names[upgrade_choice[id]])

The string containing the format is placed into its own const array and then used, thus splitting the one row into two.
I have also split up lines using backslashes so it's easier to read the menu (I'm guessing that code is used in a menu). It helps the coder get a better preview of how the menu will look like.

I can't really answer to how the compiler calculates the actual length of the line, but you can be sure it has its limits when parsing lines and if it finds a line too long, you just have to shorten it.
Johnny got his gun is offline
karlos
Veteran Member
Join Date: Apr 2004
Location: Germany/Poland
Old 08-07-2005 , 18:04  
#3

so the problem is that the line of the sma is just too long for the compiler ?
hmm ok
but when i comment that line it still reports that error
so does the compiler first reads the line and then checks it ?
__________________
alias White Panther
karlos is offline
Johnny got his gun
Veteran Member
Join Date: Jan 2004
Location: Tokyo
Old 08-07-2005 , 18:41  
#4

I noticed that if the line is too long, the compiler will have a problem with it regardless if it's commented.
Johnny got his gun is offline
karlos
Veteran Member
Join Date: Apr 2004
Location: Germany/Poland
Old 08-07-2005 , 18:57  
#5

ah ok
so its bit different i though
but thats is ok

you can close this topic
__________________
alias White Panther
karlos is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 22:59.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode