Computer Science Canada String Limit |
Author: | mike200015 [ Mon Feb 21, 2005 3:02 pm ] |
Post subject: | String Limit |
is there a way to limit the amount of letters that will be output? I know you can do: var x :string (6) which will only allow an input of at most 6 letters, but then when more than 6 letters are input then it screws up the game by exitting and going to the code. Is there a way to allow as many letters to be input, but then it will only output the 1st 6 letters? |
Author: | Flikerator [ Mon Feb 21, 2005 3:20 pm ] | ||||
Post subject: | |||||
Or if you want to keep asking for the word till you get it;
|
Author: | mike200015 [ Mon Feb 21, 2005 3:26 pm ] |
Post subject: | |
thnx.. can u help me wit a couple other things flikerator? |
Author: | mike200015 [ Mon Feb 21, 2005 3:32 pm ] | ||
Post subject: | |||
[quote="Flikerator"]
that doesnt work tho, if the name is longer than 6 it just shows up blank, i want it to; if the name is longer than 6 ,to only show the first 6 letters. |
Author: | Andy [ Mon Feb 21, 2005 3:36 pm ] |
Post subject: | |
err y not just go put word(1..6) |
Author: | cycro1234 [ Mon Feb 21, 2005 3:39 pm ] |
Post subject: | |
var word : string get word if length (word) <= 6 then word := word else word := word(1..6) end if |
Author: | mike200015 [ Mon Feb 21, 2005 3:48 pm ] | ||
Post subject: | |||
just tired it, and it didnt work ![]() |
Author: | AsianSensation [ Mon Feb 21, 2005 4:26 pm ] | ||
Post subject: | |||
why not? It works fine for me. Maybe because you were too lazy to include:
|
Author: | Flikerator [ Mon Feb 21, 2005 4:32 pm ] |
Post subject: | |
Andy wrote: err y not just go put word(1..6)
That would just display the first six letters not make it have six letters. If thats what he wants then that will work but; If I enter Flikerator (10 letters) and then put; put name(1..6) then my name is still flikerator but it just displays six letters. Quote: thnx.. can u help me wit a couple other things flikerator?
What other things? |
Author: | Tony [ Mon Feb 21, 2005 5:33 pm ] | ||
Post subject: | |||
Flikerator wrote: Andy wrote: err y not just go put word(1..6)
That would just display the first six letters
no? ![]() |
Author: | McKenzie [ Mon Feb 21, 2005 6:06 pm ] | ||
Post subject: | |||
That crashes if length < 6. Try
|
Author: | mike200015 [ Mon Feb 21, 2005 6:18 pm ] |
Post subject: | |
jus tried your way McKenzie, it didnt work cuz im using Font.Draw so when i put your code in, then it only showed like the 1st letter right at the right side of the screen, and the rest of it was off the screen ![]() ![]() |
Author: | Flikerator [ Mon Feb 21, 2005 6:18 pm ] | ||
Post subject: | |||
tony wrote: Flikerator wrote: Andy wrote: err y not just go put word(1..6)
That would just display the first six letters
no? ![]() Yes but lets say he is making a character generater. Now for the rest of the game my name is now "Fliker" because I didn't know. I even ignored the warning he supplied when he told me to choose my name ![]() Quote: put name (1 .. min (6, length (name)))
Again my name will show Fliker but will still be Flikerator. |
Author: | mike200015 [ Mon Feb 21, 2005 6:25 pm ] |
Post subject: | |
what i want to do is; since im using Font.Draw, the x-coordinate of the Font.Drawargument to be sumthing like maxx-length(name)-3, so that the name they enter will be fully shown and the last letter about 3 spaces away from maxx. Except that way doesnt work. Does anyone know how to do it like that using Font.Draw? |
Author: | Cervantes [ Mon Feb 21, 2005 7:26 pm ] |
Post subject: | |
Use Font.Width. And don't ask what Font.Width does. Use the help file. And don't ask how you should use Font.Width, because it's simple. Think about things before you ask. (Sorry, it's just this whole thread seems to be people giving you perfectly good code and you saying "no it doesn't work".) |
Author: | TheZsterBunny [ Mon Feb 21, 2005 10:40 pm ] |
Post subject: | |
... var word : string(6) ... can't even try to put in more than 6 letters tho' -Z |
Author: | Flikerator [ Tue Feb 22, 2005 7:04 pm ] |
Post subject: | |
TheZsterBunny wrote: ...
var word : string(6) ... can't even try to put in more than 6 letters tho' -Z What EXACTLY do you want so I can help you out. Or at least try. |
Author: | mike200015 [ Wed Feb 23, 2005 6:38 pm ] | ||
Post subject: | |||
just incase anyone wanted to know how to do it... i just figured it out:
and then jus sub in for your own variables and numbers... |