Computer Science Canada

can anyone help put a font.draw into a procedure???

Author:  n00b.skillz [ Fri Dec 15, 2006 10:28 am ]
Post subject:  can anyone help put a font.draw into a procedure???

i have no clue how to put font.draw into my procedure i tried everything, is it even possible??
plz let me know and if u can help me stick it in somewhere...


setscreen ("nocursor")
colourback (grey)
cls
var count : int := 0
var fontID : int := Font.New ("Arial:14:bold")
var choice : int
var guess : string
var finished := false %recived help from Hackmaster (from compsci)
procedure Question (question, a, b, c, d, right: string)
cls
put question %recieved help from Hackmaster (from compsci)and from %tutorial because i didn't understand what a procedure was
put "a) ", a
put "b) ", b
put "c) ", c
put "d) ", d
get guess
if guess = "a" and right = "a" then
put "Right! good Job!"
count := count + 1
elsif guess = "b" and right = "b" then
put "Right! good Job!"
count := count + 1
elsif guess = "c" and right = "c" then
put "Right! good Job!"
count := count + 1
elsif guess = "d" and right = "d" then
put "Right! good Job!"
count := count + 1
else
Font.Draw ("Wrong", 75, 250, fontID, red)
if right = "a" then
put " It was ", a, "."
elsif right = "b" then
put " It was ", b, "."
elsif right = "c" then
put " It was ", c, "."
elsif right = "d" then
put " It was ", d, "."
end if
end if
delay (2000)
end Question

Author:  ZeroPaladn [ Fri Dec 15, 2006 1:20 pm ]
Post subject: 

perhaps explaining what your code should be doing instead of just putting "I can't do ths help me plz" can help us help you. We can't do anything when we don't know what it should be, or supposed to be, doing.

Next, it is much easier to read your code when you have the code and /code tags...
code:
[code]
Insert Code Here ^.^
[/code]


Third, you can't have, well, this...
Turing:
if something = somethingElse then
    % insert code here
else
    Font.Draw (x, y, fontID, color)
elsif
    %more code here
end if

'Cause it wont work out. You'll get an error. else is used as when all other possibilities don't match the criteria (defined using your if and elsif), and you can't put other elsifs after an else. See the Turing Walkthrough for great tutorials on everything Turing (and we mean everything). I suggest looking at the if-elsif-else Tutorial and the font Tutorial. They should give you all the help you need to get this done.

Lastly, I see a Font.Draw inside your code allready. Guess what, nothing is wrong with it. I think it's your messed up if-elsif-else setup you have going that is stopping your code from running, not the placement of your Font.Draw.

Good Luck!

Author:  n00b.skillz [ Fri Dec 15, 2006 10:32 pm ]
Post subject: 

okay well here is what i need exactly that code is working properly right now but i want the user input to be displayed in font.draw so when the user types something in it will automatically use the font.draw. do u get what i'm sayin... do u have any tips or suggestions on how to do this?

Author:  uberwalla [ Fri Dec 15, 2006 10:38 pm ]
Post subject: 

ok i think i get what you are trying to do so i made a little something to show you how to do what i think your asking. simply just instead of the quotations put a variable. example:

Turing:

var font : int := Font.New ("serif:22")
var word : string
get word
Font.Draw (word, maxx div 2, maxy div 2, font, 7)


that what your looking for?

Author:  n00b.skillz [ Fri Dec 15, 2006 11:40 pm ]
Post subject: 

i really appreaciate the help uberwalla the program is attached

Author:  Clayton [ Fri Dec 15, 2006 11:47 pm ]
Post subject: 

what you are looking for (if I understand you correctly) can be found here

Author:  uberwalla [ Fri Dec 15, 2006 11:59 pm ]
Post subject: 

ok from what i understand from the comments you put in the code is that you want a different font or something. so all you have to do is either change what you have

code:

var fontID : int := Font.New ("Arial:14:bold")


change "Arial" to something different and itll change the font. its all basic microsoft word// word perfect etc fonts.

also if you dont wanna change that font and u want some with that font then make a new variable:

code:

var fontID1 : int := Font.New ("Times New Roman:14:bold")

do something like that and change fontid to something else?

code:

Font.Draw ("You have chosen Urban", 75, 345, **fontID**, 3)


also what you could do is just:

code:

var font : int := Font.New ("Arial:12")
var b : string := "Hi"
var x : int := maxx div 2
var y : int := maxy div 2
var clr :int := 7
Font.Draw ("a)      " + b, x, y, font, clr)


ok so i made that small code to just show you how you could come about solving the problem. im not going to incorperate this right into your proc because thats your place to learn//test your skills Smile basically just do the stuff you had and move coordinates that i put into the ones u want and so on.

if u need me to explain more what i did just reply with the question. ill be on quite a bit longer because im working on my english summative so i got a free weekend Smile

Author:  n00b.skillz [ Sat Dec 16, 2006 7:33 pm ]
Post subject: 

not exactly. i will try to explain what i want exactly since i know i can be confusing at times. Basically what i want to do is be able to have a font.draw in my procedure, so that the questions i later type in will be displayed in a font.draw without me typing font.draw everytime. i'll use an example from my model: if u select urban it will take you to a question which will appear in default font about zelda. basically i would like to have the same code but for that question to appear in a different font from the turing default. so my question is where exactly would i have to encorporate the font.draw in my procedure declaration. Then after i have finished declaring it i would like to know what i must put in after where i am typing in the actual question for it to be in font.draw becuase everytime i try something it says the procedure has too few paramaters due to the fact that i do not know what i must stick in at the question line to make it work.

Author:  uberwalla [ Sat Dec 16, 2006 10:44 pm ]
Post subject: 

Here i added the font.draws into your proc, i hope its what you were looking for. if not ill you'll have to be a little more specific sorry its kinda confusing for me right now cuz im just hearing font.draw in proc so here we are...

Turing:

procedure Question (question, a, b, c, d, right : string)
    cls
    Font.Draw (question, 1, maxy - 10, fontID2, 7)
    Font.Draw ("a)     " + a, 1, maxy - 20, fontID2, 7)
    Font.Draw ("b)     " + b, 1, maxy - 30, fontID2, 7)
    Font.Draw ("c)     " + a, 1, maxy - 40, fontID2, 7)
    Font.Draw ("d)     " + d, 1, maxy - 50, fontID2, 7)
    get guess
    cls
    if guess = "a" and right = "a" then
        Font.Draw ("Right! Good Job!", 1, maxy - 10, fontID2, 7)
        count := count + 1
    elsif guess = "b" and right = "b" then
        Font.Draw ("Right! Good Job!", 1, maxy - 10, fontID2, 7)
        count := count + 1
    elsif guess = "c" and right = "c" then
        Font.Draw ("Right! Good Job!", 1, maxy - 10, fontID2, 7)
        count := count + 1
    elsif guess = "d" and right = "d" then
        Font.Draw ("Right! Good Job!", 1, maxy - 10, fontID2, 7)
        count := count + 1
    else
        Font.Draw ("Wrong", 75, 250, fontID, red)
        if right = "a" then
            Font.Draw ("It was " + a + ".", 1, maxy - 10, fontID2, 7)
        elsif right = "b" then
            Font.Draw ("It was " + b + ".", 1, maxy - 10, fontID2, 7)
        elsif right = "c" then
            Font.Draw ("It was " + c + ".", 1, maxy - 10, fontID2, 7)
        elsif right = "d" then
            Font.Draw ("It was " + d + ".", 1, maxy - 10, fontID2, 7)
        end if
    end if
    delay (2000)
end Question


all you have to do really is put as a variable:
var fontID2 :int := Font.New ("Arial:8")
if its to small well change it Razz but change the y value of the font.draw otherwise i think itll go off the screen.

Author:  n00b.skillz [ Sun Dec 17, 2006 12:18 am ]
Post subject: 

yesss omg finally someone uderstood my thx soooooo much i'm now well on my way to solvin my isp thx for solvin dat problem i'll be sure to give u credit on my isp and when it's done i'll post it so you can see what your foundations have created:P haha thx again ur a genius

Author:  uberwalla [ Sun Dec 17, 2006 1:15 am ]
Post subject: 

np i guess. not trying to trash you or anything but... it really was quite easy. you just had to put some thought in it. it is basically exactly the same as put except you can choose your font, size , color, and coordinates in one command. good luck with your isp Smile


: