New guy needs help (already!) system.vc error
Displaying 1-7 of 7 total.
1
Please enter a numerical value for the importance of this sticky.
Enter 0 to unsticky.
timbecile

So I grabbed this yesterday to check it out, and am working through the 'Hello World' tutorials. I'm still on number 1 and am already having problems.

So here's the deal...I grabbed two lines from the sully system.vc to add a background graphic ad am getting this:

'system.vc(7): 'string' is not a recognized keyword or identifier!'

What am I doing wrong?

here's the code:


void autoexec()
{
while (!b3)
{
RectFill(0, 0, ImageWidth(screen), ImageHeight(screen), 0, screen);

string _im = 'Dragonfire Shirt 1.jpg';
int im = LoadImage( _im );
PrintCenter(ImageWidth(screen)/2, ImageHeight(screen)/2, screen, 0, 'Hello World!');
ShowPage();
}

Exit('Bye!');

}

Posted on 2004-10-25 20:40:35

Omni

I don't think variable names can begin with underscores.


string image_name = 'Dragonfire Shirt 1.jpg';


Would probably be better.

And how come nobody uses double quotes anymore? Geez. I like double quotes!


EDIT: Oh. The < pre > formatting takes out double quotes. [...Er...why?]

EDIT 3:

Don't declare any variables from within a while() loop, either. Put them outside the loop, preferably near the beginning of the function.

Posted on 2004-10-25 20:42:18 (last edited on 2004-10-25 20:46:00)

vecna

Variable names can have underscores, but the problem is that you can only declare local variables at the base level of the function, not within a while or for loop or whatever. ... I know, I know. So if you move the variable declaration outside the while loop, it'll work.

Edit: like so.


void autoexec()
{
string _im = 'Dragonfire Shirt 1.jpg';
int im = LoadImage( _im );

while (!b3)
{
RectFill(0, 0, ImageWidth(screen), ImageHeight(screen), 0, screen);
PrintCenter(ImageWidth(screen)/2, ImageHeight(screen)/2, screen, 0, 'Hello World!');
ShowPage();
}

Exit('Bye!');
}


You could still put the assignment inside the loop, but I moved them out because as you had it, it was loading the image at each frame and causing a big memory leak. You only need to load the image once, so, outside the loop.

Posted on 2004-10-25 21:14:27 (last edited on 2004-10-25 21:18:49)

timbecile

You guys rock! That did it...so here's the final bit I did to make it work the way I wanted:


void autoexec()
{

string _im = 'Dragonfire Shirt 1.jpg';
int im = LoadImage( _im );


while (!b3)
{
RectFill(0, 0, ImageWidth(screen), ImageHeight(screen), 0, screen);
Blit( 0,0, im, screen );
PrintCenter(ImageWidth(screen)/2, ImageHeight(screen)/2, screen, 0, 'Hello World!');
ShowPage();
}

Exit('Bye!');

}



forgot to use blit to make it show up. Thanks for the help....I'm sure I'll be around a lot for more of it!

one more question.....could I have loaded the image like this (instead of using two variables?)


int im = LoadImage( 'Dragonfire Shirt 1.jpg' );

Posted on 2004-10-25 21:28:11

Overkill

Yes, your latter method will work, and more efficiently, at that.

Posted on 2004-10-25 21:33:12

Feyr

*edit* Oops, I was wrong. And forgot to hit submit until long after the question was answered correctly, too. ;P

Posted on 2004-10-25 21:38:56 (last edited on 2004-10-25 21:42:22)

zonker6666

Yes sir :) you dont need to use that intermidate string.

Posted on 2004-10-26 20:07:24


Displaying 1-7 of 7 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.