Specific font for getting variables
Author |
Message |
supaphreek
|
Posted: Wed May 12, 2010 11:52 pm Post subject: Specific font for getting variables |
|
|
What is it you are trying to achieve?
I am trying to use the get command (or a similar command) so that the user can enter text for a variable but in a cool font (of my choice)
What is the problem you are having?
I dont know how to use a specific font for getting a variable....
Describe what you have tried to solve this problem
Nothing
Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
I have no relevant Code.
Please specify what version of Turing you are using
4.1.1 |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
Tony
![](http://wiki.compsci.ca/images/f/f4/OniTony.gif)
|
Posted: Thu May 13, 2010 12:05 am Post subject: RE:Specific font for getting variables |
|
|
You might be able to change the config settings on your IDE, to change the font. Though those changes would be local to your copy only (and generated binaries, but that's not an issue since you are using 4.1.1).
You would probably be interested in Font.Draw, but then you'd need to build your own "get" with loops, ifs, and getch |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
![](images/spacer.gif) |
DemonWasp
|
Posted: Thu May 13, 2010 12:09 am Post subject: RE:Specific font for getting variables |
|
|
The get command can only use whatever font the terminal is set to use (this is configured in Turing preferences). However, all output by put and get will use that font.
The other option is this:
1. Hide the "echo" from get: the display of what you're typing. You can do this with View.Set ( "noecho" )
2. Initialize your stylized font (Font.New).
3. Initialize a current input-string to be empty - ""
4. Draw the input-string in your font (Font.Draw)
5. Use polling keyboard input to detect which keys are hit (Input.KeyDown)
6. Whenever the user enters a character, append that to the input-string they're building.
7. Whenever the user hits backspace, delete the last character off of the input-string.
8. Whenever the user hits enter, terminate and return the accumulated input string; otherwise, return to Step 4.
You can see an example of a similar simple program here. All you will really need to change is that you want to use a font instead of drawing asterisks, which is probably a 3-4 line change. |
|
|
|
|
![](images/spacer.gif) |
supaphreek
|
Posted: Thu May 13, 2010 7:13 am Post subject: RE:Specific font for getting variables |
|
|
Ermmm, i know all bout forn.draw, get, loops, ifs and id definetly change it locally if i could :S
As for the comment by demonwasp
im pretty confused as to what i am supposed to do, i dont really understand half the commands in that code :S and where i would edit it because based on what your telling me, i would only be able to see the asterisks :S
But what i actually want is for them to see what theyre typing as its being typed (in a cool preset font) |
|
|
|
|
![](images/spacer.gif) |
DemonWasp
|
Posted: Thu May 13, 2010 7:47 am Post subject: RE:Specific font for getting variables |
|
|
You would need to change (the part that draws asterisks instead of text) to something new (the part that draws your word in a funny font, at a given location).
The part that draws the asterisks is the repeat command after put "Enter Password: "..
You want to replace that with a Font.Draw command that will draw the user's input from the "password" string - or whatever you rename it to. This is a one line fix.
You'll probably also want to replace that put with a Font.Draw for consistency.
As for the rest of the commands, I recommend you look them up in the Turing documentation. ord isn't scary - it just gets the ASCII value for the character you pass to it; chr does the opposite, taking a value and converting it to its ASCII character representation. The numbers I've used will make more sense when you look at that ASCII table I linked. |
|
|
|
|
![](images/spacer.gif) |
supaphreek
|
Posted: Thu May 13, 2010 8:39 pm Post subject: RE:Specific font for getting variables |
|
|
OK! thats great i got it working using that code, however im wondering what use the middle lines have?
the stuff starting from if (ord (ch) = 8) then |
|
|
|
|
![](images/spacer.gif) |
Tony
![](http://wiki.compsci.ca/images/f/f4/OniTony.gif)
|
Posted: Thu May 13, 2010 9:05 pm Post subject: RE:Specific font for getting variables |
|
|
Uhh... it would have been best if you were to write that block of code yourself; then you would have known all the required parts, and exactly how they work.
But for that particular line... what key has an ASCII value of 8 ? |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
![](images/spacer.gif) |
supaphreek
|
Posted: Thu May 13, 2010 10:13 pm Post subject: RE:Specific font for getting variables |
|
|
OH! now i get it so thats pretty much another way of getting a value for a key
the first one alllows backspacing
the second one allows you to press enter to exit the loop
and thee last is for printable characters
Thanks Tony! I get it now |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
|
|