Strange vc error
Displaying 1-10 of 10 total.
1
Please enter a numerical value for the importance of this sticky.
Enter 0 to unsticky.
Beni

I keep getting this error on line 356, 359 and 362. 'syntax error in if statement'. But there is no if statement.

346: void makeArrayFromString(int array, string s)
{
int l = len(s);
int size = l/4+2;
resizeArray(array,size);
setArrayVal(array,0,l);
int asc,v,shift,bitmask,imask,c;
for(c=0; c<l, c++)
{
// gets the int that the character should be in.
v = getArrayVal(array,c/4+1);
356: asc = ascii(s,c);
// there are 4 characters per int. This makes a bit mask of
// the ascii value shifted to the right position in the int
shift = c%4-3; shift = shift << 3; bitmask = asc << shift;
// why is there no bitwise inverter in verge? oh well, this works
359: imask = (255 << shift) ^ (65535 << 16 | 65535);
v = v & imask; // clears the bits we need to set to the new character.
v = v | bitmask; // Then sets them properly.
362: setArrayVal(array,c/4+1,v);
}
}

Has anyone seen anything like this before?

[Zip: Made code less wide for my small screen]

Posted on 2004-12-04 16:45:53 (last edited on 2004-12-04 21:03:00)

RageCage

v = v & imask;
v = v | bitmask;

perhaps I just am not familiar with these operations but I don't believe I've ever seen them before in verge except in a if statment. Could this be your problem?

if I'm wrong and they are legal operations, what do they do? Also, have you checked the syntax of preceeding if statements outside the function?

Posted on 2004-12-04 17:05:31

Beni

& and | are bitwise operators. Check the manual. Section IV.b, operators.

And I tried commenting out the whole body of the function and there were no compile errors. So it can't be any if statements before the function.

Posted on 2004-12-04 17:18:14

Omni

Those look like binary operations.

I don't Verge supports binary logical operators, but last time I said it didn't support MIDI I turned out to be wrong, so I could be wrong here too.

EDIT: Nevermind, I was too late and also completely wrong here. I'm not quite sure why it shouldn't be working.

Posted on 2004-12-04 17:18:59 (last edited on 2004-12-04 17:21:43)

Beni

Well I found the problem. I accidently put a comma in my for statement instead of a semicolon. Seems the compiler is misreporting the error. It was easy enough to find because my function was small, but I bet someone will make the same mistake with a much larger function and hunt down the problem for hours.

Posted on 2004-12-04 18:37:13

Zip

for(c=0; c<l, c++)
...saw that one straight off. :)

Zip

Posted on 2004-12-04 20:59:57

RageCage

I can't believe I missed that!

Posted on 2004-12-05 21:17:52

Interference22

Quote:Originally posted by Zip

for(c=0; c<l, c++)
...saw that one straight off. :)

Zip


Good grief.

Posted on 2004-12-10 12:41:23

Gayo

Once in v2 I put a superfluous semicolon after the last term of a for condition. It took me like two hours to find.

Posted on 2004-12-11 02:34:24

Technetium

When I do that (put a semicolon at the end of a for or while loop), I usually end up commenting out large sections to narrow it down. It's usually the fastest way that I've found to find errors that the compiler isn't good at locating. The other one that screws with the compiler good is forgetting the ending quote of a string somewhere, and fooling the compiler into thinking subsequent code is part of the string.

Posted on 2004-12-12 04:00:31


Displaying 1-10 of 10 total.
1
 
Newest messages

Ben McGraw's lovingly crafted this website from scratch for years.
It's a lot prettier this go around because of Jon Wofford.
Verge-rpg.com is a member of the lunarnet irc network, and would like to take this opportunity to remind you that regardless how babies taste, it is wrong to eat them.