Another stupid n00b question.
Displaying 1-13 of 13 total.
1
Please enter a numerical value for the importance of this sticky.
Enter 0 to unsticky.
fox_astron

Ok, while following Rysen's tutorial, I decided I'd try to expand a little bit on the text box... and apparently Verge doesn't like it when I use PHP syntax. :^p

I'm trying to set it up so that the Textbox function includes a 48x48 portrait that I specify in the arguements. So... I tried this, hoping that 'face' would fill in properly:

void TextBox(string face, string text)

{
int TextBg = LoadImage('menus\textbox.pcx');
int MyFont = LoadFont('menus\smallfont1.gif');
int portrait = LoadImage('menus\',face,'.gif');
while(!b1)
{
Render();
TBlit(16,130,portrait,screen);
Blit(0,178,TextBg,screen);
PrintString(10,185,screen,MyFont,text);
ShowPage();
}
Unpress(1);
FreeImage(TextBg);
FreeFont(MyFont);
}


But, of course... it gags and sputters with '); Expected , found' errors when it hits the Int Portrait line. So... that said, What's the proper syntax for what I'm trying to do?

Posted on 2005-02-26 22:43:02

gannon

in verge string concatenation (putting strings together) is done with +
ie

int portrait = LoadImage('menus\'+face+'.gif');

Posted on 2005-02-26 22:46:37 (last edited on 2005-02-26 22:48:01)

TomT64

Maybe you'd better put a space between the plus signs so it's easier to understand why it works.

Posted on 2005-02-27 01:50:11

fox_astron

and yay, it works now. Knew it was something simple. Thanks.

I understand how it works, just didn't remember the terminology and thus... couldn't look it up.

Posted on 2005-02-27 02:15:04

Overkill

From my experience PHP's concatination is done with '.' not ','. I guess if you do commas, you're passing multiple arguments, which the echo function can handle. But actual string concatination is '.'. The '+' also works in some cases in PHP, but I found it converted my strings to jibberish numbers (which was odd o__0).

Also to be noted is that I don't think Verge 3 is capable of doing concatination with the += operator. I think in Verge 3, it'll spit compiler errors at you. I could be wrong, someone test this for me!


// NOTE THAT VERGE-RPG.COM CONVERTS DOUBLE QUOTES TO SINGLE QUOTES... WHICH I DISLIKE.
string s;
s = 'HELLO'
s += ' MOAR STRING PLZTHXBYE';
log(s);

Posted on 2005-02-27 08:18:13 (last edited on 2005-02-27 08:20:42)

CrazyAznGamer

Quote:Originally posted by overkill


Also to be noted is that I don't think Verge 3 is capable of doing concatination with the += operator. I think in Verge 3, it'll spit compiler errors at you. I could be wrong, someone test this for me!


// NOTE THAT VERGE-RPG.COM CONVERTS DOUBLE QUOTES TO SINGLE QUOTES... WHICH I DISLIKE.
string s;
s = 'HELLO'
s += ' MOAR STRING PLZTHXBYE';
log(s);


Um... I think that this has already been discussed in the docs, where most answers are.
Also, I agree with you. We Americans like our quotations to be double quotations.
Or at least we Asian-Americans.

Posted on 2005-02-27 19:23:42

fox_astron

Why would you use S +='MOAR'; when you could use S = S+'MOAR';?

Posted on 2005-02-27 21:46:49

Omni

Technically, because it means he has to type less. So, implicitly, it's because programmers are lazy :)

Posted on 2005-02-27 22:04:44

fox_astron

ah. I'm so glad I'm an artist. We're lazy too, but not as bad. :^p

Posted on 2005-02-27 22:41:17

Kildorf

It's not really just because we're lazy (though that's a big part of it ^^). Reducing the amount of times you repeat anything is good, because it makes changes less error-prone in the future. Say, for example, you're changing things and you want to replace the s in your example with anothers. It's been a while since you looked at the code and you're tired and hungry and rushed for time, so you've forgetten exactly what's going on. If you read down through your code, you might change s = s + 'moar' to anothers = s + 'moar' (just because you didn't see the second s), which is obviously wrong, whereas s += 'moar' would change to anothers += 'moar' which is right.

I also find the += version somewhat more readable, personally, and I think it bothers mathematicians less (mention a=a+b to a purist mathematician and the results are amusing). I admit that's sort of a silly example, but if things around it were complicated I still hold that it could be a problem. It is mostly because of the lazy thing, though.

Posted on 2005-02-28 05:24:57

Bitmonkey

I have a horrible memory and get lost in my code all the time, so I always name my variables verbosely. like, 'CharacterGenderPersonalPronoun' and what not. And I'm just lazy enough to complain when I have to type 'CurrentConversationNodeText=CurrentConversationNodeText+CharacterGenderPersonalPronoun' :D But that's just me.

Posted on 2005-02-28 20:54:16

Interference22

Abbreviation is good practice, but I never abbreviate past the point at which I know what a variable is without having to check. For instance:

I need to store variables for where my Data Panel GUI element is on the screen. I can abbreviate 'Data Panel' to 'dpanel' with little loss of understanding (unless, of course, I also have a Direction Panel.. erk). Therefore I can comfortably use 'dpanelx' to store it's X co-ordinate and 'dpanely' to store it's Y. If things are starting to look funky, the odd underscore ('dpanel_x') doesn't hurt either.

Posted on 2005-03-01 05:22:36

gannon

I don't write my varible name so that I can understand them. I write them so other people can look over the code and understand them. I wouldn't do dpanelx because while the panelx is fine few (namely just me) would know what the d stood for.

Posted on 2005-03-01 13:09:11


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