Computer Science Canada

Getting with Font

Author:  Clayton [ Thu Oct 19, 2006 11:32 am ]
Post subject:  Getting with Font

Well, I've seen the question a couple times "Can you get, and have the text show in a specific font?". So I decided to create a function to show that it is possible. Here is the code:

Turing:

function gets (xpos, ypos, font, clr : int) : string
    var a : string (1)
    var word : string := ""
    loop
        getch (a)
        exit when a = '\n'
        if word ~= "" and ord (a) = 8 then
            word := word (1 .. * -1)
        else
            if a ~= "\b" then
                word += a
            end if
        end if
        cls
        Font.Draw (word, xpos, ypos, font, clr)
    end loop
    result word
end gets


an example of its use:

Turing:

var name : string := ""
put "Please enter your name"
name := gets (0,0, Font.New ("times new roman : 20"), red)


all you need for this function to function (no pun intended) properly is an ordered pair (x,y) coordinates, your font, and a color to display the font in. Have fun with it if you want to use it.

Author:  Prince Pwn [ Tue Jan 02, 2007 6:12 pm ]
Post subject: 

This is cool!

Author:  Clayton [ Tue Jan 02, 2007 6:18 pm ]
Post subject: 

It's not perfect, for instance it clears the screen every iteration through a loop, so if you have anything on the screen, you will lose it. It's just a rough model to work with.

Author:  CodeMonkey2000 [ Tue Jan 02, 2007 7:44 pm ]
Post subject: 

well, once it's done this would be pretty useful

Author:  Clayton [ Tue Jan 02, 2007 7:53 pm ]
Post subject: 

I don't plan on finishing it. The only reason I posted was because people kept asking if it could be done. So I posted a half done version to prove the point, and have them do the work instead of saying "This is Freakman of compsci.ca's 'gets' function, but I have no idea how it works".

Author:  lord [ Mon Jan 15, 2007 9:23 pm ]
Post subject:  Re: Getting with Font

to be to the point ....................................................................................................... Exclamation :!:LOL Exclamation Exclamation


: