Easier Way To Display Text
Hi ...
I just downloaded the two files Ken Rhodes recommended. Maybe I'll
find an answer to my current question there. This program makes a text
string `Proper,' with first letter (only) capitalized.
include get.e
--
integer KeyPres
sequence PlyrNam
--
KeyPres = 0
PlyrNam = {}
--
clear_screen ()
position (7, 20)
puts (1, "What's Your Name?? __________")
position (7, 39) -- Beginning of `Name' line.
while KeyPres != 13 do -- Break on <RET>.
KeyPres = wait_key ()
-- Capitalize first letter.
if (length (PlyrNam) = 0) and
(KeyPres >= 97 and KeyPres <= 122) then
KeyPres = KeyPres -32
end if
-- Make rest of letters lower case.
if (length (PlyrNam) > 0) and
(KeyPres >= 65 and KeyPres <= 90) then
KeyPres = KeyPres +32
end if
-- Now, make sure they ARE letters.
if (KeyPres >= 65 and KeyPres <= 90) or
(KeyPres >= 97 and KeyPres <= 122) then
PlyrNam = PlyrNam & KeyPres
puts (1, KeyPres)
end if
end while
--
position (12, 20)
puts (1, "Hey, " & PlyrNam & ", welcome aboard.")
Output: If user types `j67O^5)hN,' it will appear as `John.'
My question is: There's gotta be an easier, shorter way to do this. This
program isn't even all that good; it wouldn't display `Mary Ann'
correctly.
Thanks,
Sam
|
Not Categorized, Please Help
|
|