Errors on "format"
#1

Hi.

I simply used "format" to...format a string, but when compiling, I got these errors :

Код:
date_kilou.pwn(19) : error 012: invalid function call, not a valid address
date_kilou.pwn(19) : error 029: invalid expression, assumed zero
date_kilou.pwn(19) : warning 215: expression has no effect
date_kilou.pwn(19) : error 001: expected token: ";", but found "sizeof"
date_kilou.pwn(19) : fatal error 107: too many error messages on one line
My code is the following :

PHP код:

new string[500] = "";
    new 
cdate[3], time[3];
    
gettime(time[0], time[1], time[2]);
    
getdate(cdate[0], cdate[1], cdate[2]);
    for(new 
0strlen(format); i++)
    {
        
        switch(
format[i])
        {
            
/*************************
                    Jour
            *************************/
            
            
case 'd'format(stringsizeof(string), "%s%02d"stringcdate[2]); 
(I try to make a date function, with almost the same features as the php version but in pawn).

I absolutely don't know the source of the errors, so if someone was able to help me, thanks to him in advance.
Reply
#2

mybe
PHP код:
  case 'd'format(stringsizeof(string), "  '%s' '%02d'  "stringcdate[2]); 
Reply
#3

Already tried, already failed.
This isn't designed to be assigned to a SQL query, so I don't understand the meaning of the simple quotes here.
You'd give me an explaination ?
Reply
#4

Just adding simple " ' " s inside a string won't make any difference.
OT:
It's actually just a simple format. I don't understand the problem of the pawn compilers, they are especially designated to kill someone
And I don't understand why he is expecting a semi colon when you still need several more parameters inside a format.
Maybe try doing simple thing: like putting it in braces, or try simply formatting it with something simple. Like that we might find a way to a solution
Reply
#5

I added the "format" into brackets (which gives me now

PHP код:
case 'd'// line 19
// line 20
      
format(stringsizeof(string), "%s%02d"stringcdate[2]);  // line 21
// line 22 
And now, the errors are more numerous :

Код:
date_kilou.pwn(21) : error 012: invalid function call, not a valid address
date_kilou.pwn(21) : warning 215: expression has no effect
date_kilou.pwn(21) : warning 215: expression has no effect
date_kilou.pwn(21) : warning 215: expression has no effect
date_kilou.pwn(21) : warning 215: expression has no effect
date_kilou.pwn(21) : warning 215: expression has no effect
date_kilou.pwn(21) : error 001: expected token: ";", but found ")"
date_kilou.pwn(21) : error 029: invalid expression, assumed zero
date_kilou.pwn(21) : fatal error 107: too many error messages on one line
So I tried adding a simple "format" just before, and I get exactly the same errors as above but on the line of the format I added (still line 21) :

PHP код:
case 'd'// line 19
            
// line 20
                
format(stringsizeof(string), "%s%s"string"123"); // line 21
                
format(stringsizeof(string), "%s%02d"stringcdate[2]); // line 22
            
// line 23 
Reply
#6

Doesn't it seem obvious that you can't use a function's name as a variable's name?
Reply
#7

@Vince : I renamed "format" to "formatt" and it works absolutely fine.
Thanks.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)