forums

TNT Basic Forums > Programming Q&A
Center Text?
< Last Thread     Next Thread >
Author
Thread        Post A Reply

11-09-2009 23:15

Posted by:
Jimm

Location:
Winnipeg, MB

Click Here to Email Jimm   Find more posts by Jimm

Hey, I'm trying to make a procedure that takes a string as input, processes it, and then outputs an integer to use for the x position of the string. Problem is I'm not exactly sure how to get the main loop of the program to read the procedure's output. Here's what I have so far:

Procedure CenterText(string Text)

int XValue

XValue=80-(Text Width (Text)/2) 'Substitute 80 for your screen width/2.
End Proc ()

Any help would be muy appreciante! :P

11-09-2009 23:29

Posted by:
Jimm

Location:
Winnipeg, MB

Click Here to Email Jimm   Find more posts by Jimm

Just a note...

P.S. There's something wrong with your Procedures help section :/

11-10-2009 08:39

Posted by:
allnodcoms

Location:
hertfordshire (England)

Click Here to Email allnodcoms   Find more posts by allnodcoms

"Board Moderator Wanted - experience irrelevant!"

OK, I give up...

Jimm, when TNT2 rolls out you are definitely a BETA tester - if you can't find any bugs then no-one will!

I'll let Mark (site admin) know about the 404 for the procedure help, thanks for pointing it out (again...). You do have a local copy though, it's in the TNT download, or if you prefer a .pdf version I compiled one (fully linked and stuff) and it's available in the Directory.

Right, back to the question... To return a value from a Proc you simply put that single value in the brackets after the 'end proc' call. In your case:

end proc(XValue)

You can then check that value with the Return statement:

print Return Int

will print the contents of XValue...

Procedures are one of the things that get the treatment in TNT2, basically they are gone. We will get sensible 'Functions' with the ability to directly return a value, Print CenterText(Text) for example, and the addition of pointers will allow things like CenterText(VarPtr(Text)) to directly alter the original value. That's still some way off though, so for now Dodgy Proc's and Iffy Returns it is...

Danny (nod the mod)

11-11-2009 03:58

Posted by:
Jimm

Location:
Winnipeg, MB

Click Here to Email Jimm   Find more posts by Jimm

Thanks again :)

Haha I will definitely take up that tester position! TNT2 sounds like it'll be pretty groovy!

All times are GMT        Post A Reply

Forum Jump:
< Last Thread     Next Thread >

< Contact Us - TNT Basic >

Powered by: vBulletin Lite Version 1.0.1 Lite
Copyright © Jelsoft Enterprises Limited 2000.