
-----------------------------------
foo fighter
Mon Dec 12, 2005 5:10 pm

forgot how to center text
-----------------------------------
i can't remember how to output something in the middle of the screen (centered).

-----------------------------------
Albrecd
Mon Dec 12, 2005 6:31 pm


-----------------------------------
 Text.Locate (x, y) 

The Default screensize in turing is 639x 399y so depending on the size of your text, you would position it accordingly.

-----------------------------------
spiderman
Mon Dec 12, 2005 6:50 pm


-----------------------------------
or u could use locate!!!!!!!!!!!!!!!!!!!!!
u learned this i can't believe u forgot!!!!!!!!!!!!!!!!!!!!!!

-----------------------------------
[Gandalf]
Mon Dec 12, 2005 6:55 pm


-----------------------------------
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
Mon Dec 12, 2005 8:13 pm


-----------------------------------
 Text.Locate (x, y) 

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
Mon Dec 12, 2005 10:27 pm


-----------------------------------
hmm..   it doesn't matter what screen size it is.  

if you write 


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
Mon Dec 12, 2005 10:31 pm


-----------------------------------
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.


var output := "Ali Baba"
locate (maxrow div 2, maxcol div 2 - length (output) div 2)
put output

Untested

-----------------------------------
Geminias
Mon Dec 12, 2005 10:59 pm


-----------------------------------
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.

-----------------------------------
Mr. T
Mon Dec 12, 2005 11:04 pm

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
Wed Dec 14, 2005 7:24 pm


-----------------------------------
How would I go about centering more than one line of text?

                                            Halle Barrey
                                            123 Fake St
                                          Faketown, Ohio
                                             M5R E2ES

-----------------------------------
Cervantes
Wed Dec 14, 2005 8:28 pm


-----------------------------------
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
Thu Dec 15, 2005 11:37 am


-----------------------------------
Ok... so if i wanted to center multiple lines of text  i would go


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
Thu Dec 15, 2005 1:43 pm


-----------------------------------
And so it should.  You located to the exact same spot each time.  You have to decrease the row.  :wink:

Also, do you have variables like this?:

var name := "name"
var place := "place"
var time := "time"

Because what you passed to the length function doesn't have quotes around it.
