Loose indentation - Am I an idiot or...?
#1

Ok, so I've got this code:

pawn Код:
#define CreateLetter(%0) \
                for(new letter; letter < sizeof (%0); letter++) \
                { \
                    CreateObject(FONT, x + (%0)[letter][0] + (spacing * 4.8), y, z + (%0)[letter][1], 0, 0, 0); \
                } \
                spacing++ //There is NO ';' supposed to be here
Now if I want to use this code in my scripts, it gives me the following error:

Код:
C:\Users\Hiddos\Hiddos\scripts\filterscripts\haystacks.pwn(490) : warning 217: loose indentation
I'm kinda sick of finding out WHAT exactly causes the compiler to get this error, I've already tried quite everything I could come up with. That includes in placing the code in "how the compiler thinks it is".

For those interested:

pawn Код:
public CreateHayText(sentence[32], Float:x, Float:y, Float:z)
{
    new spacing = 0;
    for(new lpos; lpos < sizeof sentence; lpos++)
    {
        switch(lpos)
        {
            case 'a', 'A':
            {
                CreateLetter(A); //Loose indentation
            }
            case 'b', 'B':
            {
                //CreateLetter(B);
                for(new letter; letter < sizeof A; letter++)
                {
                    CreateObject(FONT, x + B[letter][0] + (spacing * 4.8), y, z + B[letter][1], 0, 0, 0);
                }
                spacing++;
                                //Would be EXACTLY the same code as generated, but NO loose indentation.
            }
                        //All cases with 'case 'c', 'C': {}', doesn't relates to the problem at all.
            default: spacing += 2;
        }
    }
    return 1;
}
Any help is welcome ^^.


PS: I'm also getting some sort of problem with 'sizeof' when not giving the string/array a fixed length like:

pawn Код:
stock bla(text[])
{
  new var = sizeof text; //Errors
}

stock bla(text[128])
{
  new var = sizeof text; //Does not errors;
}
Any tips on that would be great as well ^^
Reply
#2

Maybe the compiler doesn't like that kind of 'long' defines...

As it's just a define (doesn't need to look nice), it could work like this:

pawn Код:
#define CreateLetter(%0) \
                for(new letter; letter < sizeof (%0); letter++) CreateObject(FONT, x + (%0)[letter][0] + (spacing++ * 4.8), y, z + (%0)[letter][1], 0, 0, 0)
Also, have you tried:

pawn Код:
stock bla(text[], var = sizeof text)
{
    // Should work
}
Reply
#3

Quote:
Originally Posted by Finn
Посмотреть сообщение
Maybe the compiler doesn't like that kind of 'long' defines...

As it's just a define (doesn't need to look nice), it could work like this:

pawn Код:
#define CreateLetter(%0) \
                for(new letter;letter<sizeof(%0);letter++)CreateObject(FONT,x+(%0)[letter][0]+(spacing++* 4.8),y,z+(%0)[letter][1],0,0,0)
]
Try this, the shorter the better with #define macros as the line limit is 512 characters.
Reply
#4

Well thanks for that, the loose indent doesn't warns me anymore lols.

The only lasting problem is the part with the 'sizeof'. Ah well, I'll have it with a fixed length then. Thanks ^^
Reply
#5

try this:

pawn Код:
stock bla(text[])
{
  new var = strlen(text);
}
If you didn't specify the size then it could be any size, I guess.
Reply
#6

Quote:
Originally Posted by ViRuXe
Посмотреть сообщение
try this:

pawn Код:
stock bla(text[])
{
  new var = strlen(text);
}
If you didn't specify the size then it could be any size, I guess.
Why didn't I think of that.. lol. Thanks, that makes the puzzle complete, now back to solving problems myself
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)