Author |
Message |
mike200015
|
Posted: 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? |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
Flikerator
|
Posted: Mon Feb 21, 2005 3:20 pm Post subject: (No subject) |
|
|
code: | var word : string
get word
if length (word) =< 6 then
word := word
else
word := ""
end if |
Or if you want to keep asking for the word till you get it;
code: | var word : string
loop
get word
exit when length (word) <= 6
end loop |
|
|
|
|
|
![](images/spacer.gif) |
mike200015
|
Posted: Mon Feb 21, 2005 3:26 pm Post subject: (No subject) |
|
|
thnx.. can u help me wit a couple other things flikerator? |
|
|
|
|
![](images/spacer.gif) |
mike200015
|
Posted: Mon Feb 21, 2005 3:32 pm Post subject: (No subject) |
|
|
[quote="Flikerator"] code: | var word : string
get word
if length (word) =< 6 then
word := word
else
word := ""
end if |
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. |
|
|
|
|
![](images/spacer.gif) |
Andy
|
Posted: Mon Feb 21, 2005 3:36 pm Post subject: (No subject) |
|
|
err y not just go put word(1..6) |
|
|
|
|
![](images/spacer.gif) |
cycro1234
![](http://www.inetresults.com/gifs/images/Mad_hack.gif)
|
Posted: Mon Feb 21, 2005 3:39 pm Post subject: (No subject) |
|
|
var word : string
get word
if length (word) <= 6 then
word := word
else
word := word(1..6)
end if |
|
|
|
|
![](images/spacer.gif) |
mike200015
|
Posted: Mon Feb 21, 2005 3:48 pm Post subject: (No subject) |
|
|
code: |
var word : string
get word
if length (word) <= 6 then
word := word
else
word := word(1..6)
end if |
just tired it, and it didnt work ![Confused Confused](http://compsci.ca/v3/images/smiles/icon_confused.gif) |
|
|
|
|
![](images/spacer.gif) |
AsianSensation
|
Posted: Mon Feb 21, 2005 4:26 pm Post subject: (No subject) |
|
|
why not? It works fine for me.
Maybe because you were too lazy to include:
after the end if? |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
Flikerator
|
Posted: Mon Feb 21, 2005 4:32 pm Post subject: (No 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? |
|
|
|
|
![](images/spacer.gif) |
Tony
![](http://wiki.compsci.ca/images/f/f4/OniTony.gif)
|
Posted: Mon Feb 21, 2005 5:33 pm Post subject: (No subject) |
|
|
Flikerator wrote: Andy wrote: err y not just go put word(1..6)
That would just display the first six letters
Turing: |
name := word(1..6)
|
no? ![Thinking Thinking](http://compsci.ca/v3/images/smiles/eusa_think.gif) |
|
|
|
|
![](images/spacer.gif) |
McKenzie
![](http://www.wizards.com/global/images/swtcg_article_27_pic3_en.gif)
|
Posted: Mon Feb 21, 2005 6:06 pm Post subject: (No subject) |
|
|
That crashes if length < 6. Try
code: | put name(1..min(6,length(name))) |
|
|
|
|
|
![](images/spacer.gif) |
mike200015
|
Posted: Mon Feb 21, 2005 6:18 pm Post subject: (No 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 ![Sad Sad](images/smiles/icon_sad.gif) |
|
|
|
|
![](images/spacer.gif) |
Flikerator
|
Posted: Mon Feb 21, 2005 6:18 pm Post subject: (No subject) |
|
|
tony wrote: Flikerator wrote: Andy wrote: err y not just go put word(1..6)
That would just display the first six letters
Turing: |
name := word(1..6)
|
no? ![Thinking Thinking](http://compsci.ca/v3/images/smiles/eusa_think.gif)
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. |
|
|
|
|
![](images/spacer.gif) |
mike200015
|
Posted: Mon Feb 21, 2005 6:25 pm Post subject: (No 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? |
|
|
|
|
![](images/spacer.gif) |
Cervantes
![](http://compsci.ca/v3/uploads/user_avatars/1023105758475ab2e040bde.jpg)
|
Posted: Mon Feb 21, 2005 7:26 pm Post subject: (No 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".) |
|
|
|
|
![](images/spacer.gif) |
|