Help me with Font.Draw
Author |
Message |
xStil
|
Posted: Sat Nov 01, 2008 12:53 pm Post subject: Help me with Font.Draw |
|
|
A subprogram to get text form the user and then draw it using Font.Draw. All the variables are declared in the full program.
Quote: process TextWrite
mainfont:=Font.New (MainFont+":"+intstr (sz))
var TEXT :string
TextActive:=true
get TEXT:*
Font.Draw (TEXT,linex,liney,mainfont,cl)
TextActive:=false
end TextWrite
The method used to call this subprogram is: Quote: if keys (T) then
delay (50)
fork TextWrite
end if
Again, everything it needs has been declared...
The problem is: I launch it, press 't', type the text, and then press enter...the text is written correctly, but I am forced to press enter a few more times (sometimes one more time, others it could take 10 presses) to get out of the get statement...
If I don't press enter those few more times, and try to close the window with Window.Close (winID), I get an error "Process "TextWrite": I/O attempted on closed stream 2."
Whats wrong in the code??? |
|
|
|
|
|
Sponsor Sponsor
|
|
|
xStil
|
Posted: Sat Nov 01, 2008 1:08 pm Post subject: RE:Help me with Font.Draw |
|
|
I figured it out:
The 'TextActive' variable is a variable to allow the whole program to know that TextWrite is functioning, so that most keyboard shortcuts would not be active while I am typing...I added 'and TextActive=false' to the if statement, and now all is well... I guess I forgot to make sure that this if statement knew when to be active and when to be not-active.
I might be able to show the program soon! |
|
|
|
|
|
Insectoid
|
Posted: Sat Nov 01, 2008 1:50 pm Post subject: RE:Help me with Font.Draw |
|
|
2 questions,
1. Why are you using processes? Procedures are far more reliable.
2. Why are you using delays? They only slow down the program, which is only useful for animations. |
|
|
|
|
|
xStil
|
Posted: Sat Nov 01, 2008 3:49 pm Post subject: RE:Help me with Font.Draw |
|
|
1: I feel more comfortable with calling a subprogram with fork, rather than just write down its name, or put it in a 'variable:=function (x,y...)'
But when I have to use procedure/function, then I don't hesitate...
More reliable? Don't procedures and functions allow for 'var parameters'? I heard those were risky to use and can cause complications at the smallest error.
2: I used the delay because, sometimes when I press 't' I hold on for longer and it is written down by the get statement
I got rid of it tho! |
|
|
|
|
|
|
|