Author |
Message |
Viper
![](http://compsci.ca/v3/uploads/user_avatars/20678142424cb7690e076fe.jpg)
|
Posted: Thu Sep 08, 2005 8:43 am Post subject: name thing |
|
|
A list of names is entered ending with the sentinel name "zzzz". Output each of the names not including the sentinel.
i cant have it not put the sentinel |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
Flikerator
|
Posted: Thu Sep 08, 2005 10:29 am Post subject: Re: name thing |
|
|
Viper wrote: A list of names is entered ending with the sentinel name "zzzz". Output each of the names not including the sentinel.
i cant have it not put the sentinel
All you have to do is is before you put the name, detect the "zzzz".
Depending on how you did it...
exit when name = "zzzz"
put name
(You in Mr.Cs class? Lolz ) |
|
|
|
|
![](images/spacer.gif) |
Viper
![](http://compsci.ca/v3/uploads/user_avatars/20678142424cb7690e076fe.jpg)
|
Posted: Fri Sep 09, 2005 8:04 am Post subject: (No subject) |
|
|
tht dont work bc when they enter the name it puts it on the screen |
|
|
|
|
![](images/spacer.gif) |
Flikerator
|
Posted: Fri Sep 09, 2005 10:15 am Post subject: (No subject) |
|
|
Mind posting the code? It would be a lot easier to help you then. |
|
|
|
|
![](images/spacer.gif) |
beard0
![](http://ugray.be/compsci/silly.gif)
|
Posted: Sun Sep 11, 2005 5:11 pm Post subject: (No subject) |
|
|
code: | View.Set ("noecho") |
|
|
|
|
|
![](images/spacer.gif) |
Token
![](http://server2.uploadit.org/files/token89-avatar1.jpg)
|
Posted: Sun Sep 11, 2005 5:28 pm Post subject: (No subject) |
|
|
I dont think I understand the question, what do you mean by a sentinel? For some odd reason it comes to mind entering passwords when all you get is *** is that what we're trying to do here? I bet I'm completely off. |
|
|
|
|
![](images/spacer.gif) |
beard0
![](http://ugray.be/compsci/silly.gif)
|
Posted: Sun Sep 11, 2005 5:37 pm Post subject: (No subject) |
|
|
The sentinel is the name being given to the string "zzzz"
Viper wrote: ...ending with the sentinel name "zzzz".
He need's to output all names except the sentinel, and so far has only managed to "output" every single name, by which I think he actually means that he let turing display them as he input them. What I was saying he should do is use View.Set("noecho") to surpress the display of input, and then actually output only those names that are not "zzzz." |
|
|
|
|
![](images/spacer.gif) |
[Gandalf]
![](http://compsci.ca/v3/uploads/user_avatars/189297994e4c716fec7f1.png)
|
Posted: Sun Sep 11, 2005 5:41 pm Post subject: (No subject) |
|
|
The difficulty in that is that then you don't see what you are typing. There is no way to see what you are typing, and not see when you type zzzz unless you want to ignore all z's or something?
Anyway, since I wanted to...
code: | View.Set ("noecho")
var name : flexible array 1 .. 0 of string
var cnt : int := 0
loop
cnt += 1
new name, upper (name) + 1
get name (cnt)
exit when name (cnt) = "zzzz"
put name (cnt)
end loop
put "Finished" |
Or a simplified version which doesn't store the names:
code: | View.Set ("noecho")
var name : string
loop
get name
exit when name = "zzzz"
put name
end loop
put "Finished" |
|
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
beard0
![](http://ugray.be/compsci/silly.gif)
|
Posted: Sun Sep 11, 2005 5:50 pm Post subject: (No subject) |
|
|
Okay, Gandalf
You can see what you type now:
Turing: | var name : flexible array 1 .. 0 of string
loop
new name, upper (name ) + 1
get name (upper (name ))
exit when name (upper (name )) = "zzzz"
end loop
new name, upper (name ) - 1
cls
for i : 1 .. upper (name )
put name (i )
end for |
P.S. Why the cnt? |
|
|
|
|
![](images/spacer.gif) |
[Gandalf]
![](http://compsci.ca/v3/uploads/user_avatars/189297994e4c716fec7f1.png)
|
Posted: Sun Sep 11, 2005 6:05 pm Post subject: (No subject) |
|
|
Oops , it's not necessary, you're right.
I thought the problem was that the user shouldn't be able to see even when he is typing the zzzz. This would require the program to probably guess that when z is pressed it shouldn't output the name, which has quite a few problems. |
|
|
|
|
![](images/spacer.gif) |
beard0
![](http://ugray.be/compsci/silly.gif)
|
Posted: Sun Sep 11, 2005 6:14 pm Post subject: (No subject) |
|
|
If you wanted to get really fancy, you could use getch, and output anything that could not be "zzzz" (ie, supress "z", but then if the user continues with "a", output "za" and everything that follows). |
|
|
|
|
![](images/spacer.gif) |
|