Author |
Message |
foo fighter
|
Posted: Mon Dec 12, 2005 5:10 pm Post subject: forgot how to center text |
|
|
i can't remember how to output something in the middle of the screen (centered). |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Albrecd
|
Posted: Mon Dec 12, 2005 6:31 pm Post subject: (No subject) |
|
|
The Default screensize in turing is 639x 399y so depending on the size of your text, you would position it accordingly. |
|
|
|
|
|
spiderman
|
Posted: Mon Dec 12, 2005 6:50 pm Post subject: (No subject) |
|
|
or u could use locate!!!!!!!!!!!!!!!!!!!!!
u learned this i can't believe u forgot!!!!!!!!!!!!!!!!!!!!!! |
|
|
|
|
|
[Gandalf]
|
Posted: Mon Dec 12, 2005 6:55 pm Post subject: (No subject) |
|
|
spiderman, stop spamming useless posts. If you know him, talk to him using private messages. And by the way, Text.Locate() and locate() are the exact same thing. |
|
|
|
|
|
Cervantes
|
Posted: Mon Dec 12, 2005 8:13 pm Post subject: (No subject) |
|
|
Albrecd wrote:
The Default screensize in turing is 639x 399y so depending on the size of your text, you would position it accordingly.
Text.Locate, or locate, works on rows and columns. If you want to work in x and y coordinates, you have to use locatexy. Or Text.Locatexy, which I assume exists.
And yes, spiderman, [Gandalf] is right. Cut the spam. |
|
|
|
|
|
Geminias
|
Posted: Mon Dec 12, 2005 10:27 pm Post subject: (No subject) |
|
|
hmm.. it doesn't matter what screen size it is.
if you write
code: |
locate (maxx div 2, maxy div 2)
put "BUMBLEBEETUNA"
|
you guessed it buddy, you're gonna see that crap written write in the center of any screen.
regards,[/code] |
|
|
|
|
|
Cervantes
|
Posted: Mon Dec 12, 2005 10:31 pm Post subject: (No subject) |
|
|
No, you will NOT see your text centred. You will get an error, because you located off the screen. You have to use locatexy().
To really centre text, you'd also need to know the length function.
code: |
var output := "Ali Baba"
locate (maxrow div 2, maxcol div 2 - length (output) div 2)
put output
|
Untested |
|
|
|
|
|
Geminias
|
Posted: Mon Dec 12, 2005 10:59 pm Post subject: (No subject) |
|
|
yeah to really center it, i suppose, but no point in using the length function. you just start off with maxx div 2, look where it is, then start subracting from it until its in the center. Unless you're a turing champion you might want to make a function to work with every string, but if you're like me and plan to learn turing for 3 days and move on then just try the former. |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Mr. T
|
Posted: Mon Dec 12, 2005 11:04 pm Post subject: Alex's Opinion |
|
|
Germinias: If your only willing to learn the basics in Turing, then I wouldn't suggest moving on to a different language. |
|
|
|
|
|
Vincent1000
|
Posted: Wed Dec 14, 2005 7:24 pm Post subject: (No subject) |
|
|
How would I go about centering more than one line of text?
Halle Barrey
123 Fake St
Faketown, Ohio
M5R E2ES |
|
|
|
|
|
Cervantes
|
Posted: Wed Dec 14, 2005 8:28 pm Post subject: (No subject) |
|
|
Vincent1000, you'll have to locate before each call of "put".
Geminias: That's a terrible way to get things done. Hardcoding is not a good idea. Why don't we just destroy programming languages all together and go back to building circuits with logic gates? |
|
|
|
|
|
Vincent1000
|
Posted: Thu Dec 15, 2005 11:37 am Post subject: (No subject) |
|
|
Ok... so if i wanted to center multiple lines of text i would go
code: | locate (maxrow div 2, maxcol div 2 - length (name) div 2)
put "name"
locate (maxrow div 2, maxcol div 2 - length (place) div 2)
put "place"
locate (maxrow div 2, maxcol div 2 - length (time) div 2)
put "time" |
When I try that it overlaps on the screen |
|
|
|
|
|
Cervantes
|
Posted: Thu Dec 15, 2005 1:43 pm Post subject: (No subject) |
|
|
And so it should. You located to the exact same spot each time. You have to decrease the row.
Also, do you have variables like this?:
code: |
var name := "name"
var place := "place"
var time := "time"
|
Because what you passed to the length function doesn't have quotes around it. |
|
|
|
|
|
|