Delete a letter from a string
Blitz3D Forums/Blitz3D Programming/Delete a letter from a string
| ||
Run this program:player_name$="Trev" Replacement$=Right$(player_name$,1) Replace(player_name$,replacement$,"Z") Print player_name Stop WaitKey it should say TreZ instead of Trev |
| ||
player_name$="Trev" Replacement$=Right$(player_name$,1) player_name$ = Replace(player_name$,Replacement$,"Z") Print player_name Stop WaitKey |
| ||
THANKS!! my player name input functions work ok, but if you press backspace when there is nothing to delete the screen goes blank and I cant work out why EDIT- got it working but the REPLACE command removes all instances of a letter from a string if they are next to each other, dont know how to stop this |
| ||
Function Backspace$(St$) If Len(St$) = 0 Then Return "" Return Left$(St$, Len(St$) - 1) End Function |
| ||
Also check out the Chr$(letter) and Asc(letter$) commands, so you can replace that very long function "Convert_to_string$". Chr$() accepts a ASCII value and converts it to a character (like your function), while Asc() accepts a character and converts it back to a ASCII value. |
| ||
thanks Rott and PowerPC, once Im finished would it make a good entry to the code archives? I cant find anything similar in there, the reason I am doing this is because it makes it possible to use cool bitmap fonts instead of the 'unprofessional' INPUT command, |
| ||
once Im finished would it make a good entry to the code archives? I cant find anything similar in there, Sure, why not? Any contributions would always be useful to someone. Well, that's my opinion anyway! |