
-----------------------------------
junkpro11
Sat May 29, 2004 8:48 pm

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 

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



-----------------------------------
Paul
Sat May 29, 2004 8:53 pm


-----------------------------------
its like this, you have a string
say

var word: string:="hello"

then if backspace is pressed, then make the word = to this

if backspace is pressed then
word:=word(1..(length(word)-1))
end if
cls
put word


-----------------------------------
junkpro11
Sat May 29, 2004 9:04 pm


-----------------------------------
thanks!

-----------------------------------
Paul
Sat May 29, 2004 9:07 pm


-----------------------------------
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
Sat May 29, 2004 9:35 pm


-----------------------------------
thanks....i experimented a bit and kinda understood the code. u cleared things up though..

thanks!
