Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / help! how to read+replace individual letters out of a string

Author
Message
dragon tail
21
Years of Service
User Offline
Joined: 23rd Jul 2003
Location: United Kingdom
Posted: 9th Oct 2004 07:18
Right, probably sounds easy (probably is), but i basically designing a translator - secrect code hybrid thing.

what i have so far is the user types in a string using input, and that string is saved. then what i want to do is read each letter out of the string, and replace each letter which something else, say replace all the "a"s with "/"s or "b"s with "r", etc

I looked up the help files and found:

but cant get it to work for me. any help would be greatly appreciated =)

dragontail

the_winch
21
Years of Service
User Offline
Joined: 1st Feb 2003
Location: Oxford, UK
Posted: 9th Oct 2004 09:35
Prints a string a character at a time as well as the ASCII code for the character.



Shrink dbpro exes with upx
can i scream?
Mentor
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: United Kingdom
Posted: 10th Oct 2004 20:35
print "message"
input message$
a=len (message$)
dim temp$(a)
for i=1 to a
temp$(i)=mid$(message$,i)
next i

do
print "convert character"
input a$
print "to character"
input b$
for i=1 to a
if temp$(i)=a$
temp$(i)=b$
endif
next i
print "currently encoded as"
for i=1 to a
print temp$(i);
next i
print
loop

its easier to handle the text if you stuff it into an array and then play with it, this will take a string and then allow you to subsitute individual characters, hope thats some help.

Mentor.

PC1: P4 3ghz, 1gig mem, 3x160gig hd`s, Radeon 9800pro w cooler (3rd gfx card), 6 way speakers.
PC2: AMD 2ghz, 512mb ram, FX5200 ultra, 16 bit SB.
Mini ATX cases suck.

Login to post a reply

Server time is: 2024-11-27 13:02:25
Your offset time is: 2024-11-27 13:02:25