
-----------------------------------
Clayton
Thu Oct 19, 2006 11:32 am

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:


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:


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.

-----------------------------------
Prince Pwn
Tue Jan 02, 2007 6:12 pm


-----------------------------------
This is cool!

-----------------------------------
Clayton
Tue Jan 02, 2007 6:18 pm


-----------------------------------
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.

-----------------------------------
CodeMonkey2000
Tue Jan 02, 2007 7:44 pm


-----------------------------------
well, once it's done this would be pretty useful

-----------------------------------
Clayton
Tue Jan 02, 2007 7:53 pm


-----------------------------------
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".

-----------------------------------
lord
Mon Jan 15, 2007 9:23 pm

Re: Getting with Font
-----------------------------------
to be to the point ....................................................................................................... :!:  :!:LOL :!:  :!:
