Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 can you delete a part of a string?
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
junkpro11




PostPosted: Sat May 29, 2004 8:48 pm   Post subject: can you delete a part of a string?

i want to getch sth then add all the strings together, and if the backspace is pressed, i want to delete watever i recently getch

this is my code
code:

loop
            count := count + 1
           
            locate (10, 30 + count)
            getch (input)
           
            exit when input= chr (10)
            put "-"..
            if input not=chr(10) and input not=chr (8) then
            guess:= guess + input
            end if
            if input = chr (8) then
                locate (10, 30 + count - 1)
                put ""
                count := count - 2
                 
            elsif input = chr (10) then %enter key
                Music.PlayFile ("select.wav")
            else
                guess:=guess
            end if
            end loop

Sponsor
Sponsor
Sponsor
sponsor
Paul




PostPosted: Sat May 29, 2004 8:53 pm   Post subject: (No subject)

its like this, you have a string
say
code:

var word: string:="hello"

then if backspace is pressed, then make the word = to this
code:

if backspace is pressed then
word:=word(1..(length(word)-1))
end if
cls
put word
junkpro11




PostPosted: Sat May 29, 2004 9:04 pm   Post subject: (No subject)

thanks!
Paul




PostPosted: Sat May 29, 2004 9:07 pm   Post subject: (No subject)

lets say u have a string containing "abcde"
the first letter of the string, or in the code word(1) is a
word(2) is b and so on.
The code, when u press backspace
it makes the value of the word equal to from the first letter of ur string to the second last letter
so if you have abcde
the code would reduce it to
abcd, when u press backspace
ofcourse it would crash when you have nothing left and u still press backspace... so u have to restrict that.
length(word) just finds the length
and word:=word(1..(length(word)-1))
is basically, word is equal to word from letter one to the second last letter.
junkpro11




PostPosted: Sat May 29, 2004 9:35 pm   Post subject: (No subject)

thanks....i experimented a bit and kinda understood the code. u cleared things up though..

thanks!
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 5 Posts ]
Jump to:   


Style:  
Search: