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 / jumbled letter program

Author
Message
Plastico
20
Years of Service
User Offline
Joined: 3rd May 2004
Location:
Posted: 30th Aug 2004 07:47
is it possible to create a program that just jumbles letters on your keyboard then shows them to you? or maybe something more difficult like only having letters that start with M, end with E, and only 5 letters long?

lol, this might sound odd, but I have to know how I would do this? some help
Physics coder
20
Years of Service
User Offline
Joined: 25th May 2004
Location: United States
Posted: 31st Aug 2004 01:34 Edited at: 31st Aug 2004 01:35
i take it you want to jumble a string of letters?

what i would do first is randomize the timer:

randomize timer()

next i would get the string:

input "Enter a string:",a$

and get the length of the string:

string_length=len(a$)

and then make an array of the letters and a flag like so:

type letter_type
char$ as string
exist as boolean
endtype

dim letter(string_length) as letter_type

i'd then fill the array with the letters of the string.

after that i would make a blank string and add a random letter that doesn't exist in the new string, add it to the string, and then change the flag so the same letter isn't randomly picked again:
s$=""
for l=1 to string_length
letter(l).exist=0
next l

`repeat the loop for each letter
for l=1 to string_length
`get random letters until one is found that hasn't been added yet
repeat
n=rnd(string_length-1)+1
until letter(n).exist=0
`once a letter is found, add it
letter(n).exist=1
s$=s$+letter(n).char$
next l

all this works in this snippet:



-----------------------------------
To delete the bug, delete the code.
Specs: Sony VAIO Laptop, Windows XP, P4 2.8Ghz, 512MB RAM, ATI Radeon 64MB video memory, DBP Upgrade 5.3.

Login to post a reply

Server time is: 2024-11-27 08:26:08
Your offset time is: 2024-11-27 08:26:08