Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old July 19th, 2005, 08:46 AM
Alistair
Guest
 
Posts: n/a
Default random word generator

Hello folks...

this is my first post in here. I'm new to ASP having done all my previous
work in Flash and bog standard HTML. Only been learning for a couple of
weeks.

anyway...I have been building a guestbook type page, but as with quite a lot
of guestbooks and stuff some of the comments that get placed are not exactly
suitable, and tracking people down is a little difficult.

maybe you all can think of much better ways but remember I'm a newbie and am
working my way through..

so...

I have a form where people sign up to become a member..they select their
name and password etc and can log in, but this is completely anonymous....

so..I got an email script set up and working (took me a long time to figure
that one out!!!) and connected to a dbase, The user gives me his email addy
and name and a random number is generated, stored as his password and the
password is mailed to him,...thus if he doesn't give me a corect email addy
he doesn't get his password and therefore can't sign in or post nasty
comments..

But a number password isn't really all that and I would prefer to have a
random word generated.

is this possible??

again, being a newbie and not very up on what I can/can't do...I thought of
the following...

1) Store a bunch of words in a text file with a space between each one
2) Read in this file and store it as a variable
3) Trim off a random number of characters from the start of the text
4) Then search for the next space (which would be the beginning of the next
complete word)
5) The next space after that would then mark the end of the word
6) count the characters between the two spaces to give me the word length
7) and then select that number of characters and then I have a randomly
selected word!!!

I can't see why it wouldn't work as it seems logical to me, but maybe
someone (Ray seems to be the god of ASP (I've been reading here for a couple
of weeks and he seems to know everything!!!!)... can tell me otherwise?

many thanks




  #2  
Old July 19th, 2005, 08:46 AM
Lasse Edsvik
Guest
 
Posts: n/a
Default Re: random word generator

Alistair,

maybe something like this

<%
words="cat dog fruit banana"
wordarr = split(words," ")

randomize
randomword=wordarr(int(rnd * ubound(wordarr)))

response.write(randomword)
%>


/Lasse



"Alistair" <email@wormfilteralistair.inuk.com> wrote in message
news:vo08kriifrma2e@corp.supernews.com...[color=blue]
> Hello folks...
>
> this is my first post in here. I'm new to ASP having done all my previous
> work in Flash and bog standard HTML. Only been learning for a couple of
> weeks.
>
> anyway...I have been building a guestbook type page, but as with quite a[/color]
lot[color=blue]
> of guestbooks and stuff some of the comments that get placed are not[/color]
exactly[color=blue]
> suitable, and tracking people down is a little difficult.
>
> maybe you all can think of much better ways but remember I'm a newbie and[/color]
am[color=blue]
> working my way through..
>
> so...
>
> I have a form where people sign up to become a member..they select their
> name and password etc and can log in, but this is completely anonymous....
>
> so..I got an email script set up and working (took me a long time to[/color]
figure[color=blue]
> that one out!!!) and connected to a dbase, The user gives me his email[/color]
addy[color=blue]
> and name and a random number is generated, stored as his password and the
> password is mailed to him,...thus if he doesn't give me a corect email[/color]
addy[color=blue]
> he doesn't get his password and therefore can't sign in or post nasty
> comments..
>
> But a number password isn't really all that and I would prefer to have a
> random word generated.
>
> is this possible??
>
> again, being a newbie and not very up on what I can/can't do...I thought[/color]
of[color=blue]
> the following...
>
> 1) Store a bunch of words in a text file with a space between each one
> 2) Read in this file and store it as a variable
> 3) Trim off a random number of characters from the start of the text
> 4) Then search for the next space (which would be the beginning of the[/color]
next[color=blue]
> complete word)
> 5) The next space after that would then mark the end of the word
> 6) count the characters between the two spaces to give me the word length
> 7) and then select that number of characters and then I have a randomly
> selected word!!!
>
> I can't see why it wouldn't work as it seems logical to me, but maybe
> someone (Ray seems to be the god of ASP (I've been reading here for a[/color]
couple[color=blue]
> of weeks and he seems to know everything!!!!)... can tell me otherwise?
>
> many thanks
>
>
>
>[/color]


  #3  
Old July 19th, 2005, 08:46 AM
Alistair
Guest
 
Posts: n/a
Default Re: random word generator


"Lasse Edsvik" <lasse@nospam.com> wrote in message
news:%23E4ecl0iDHA.220@tk2msftngp13.phx.gbl...[color=blue]
> Alistair,
>
> maybe something like this
>
> <%
> words="cat dog fruit banana"
> wordarr = split(words," ")
>
> randomize
> randomword=wordarr(int(rnd * ubound(wordarr)))
>
> response.write(randomword)
> %>
>
>
> /Lasse
>[/color]
perfect, Many thanks

an array was going to be the other method that I thought of and I forgot
about the split function....part of being a newbie is that you easily forget
the little commands in favour of the far more exciting big commands.



  #4  
Old July 19th, 2005, 08:46 AM
Manohar Kamath [MVP]
Guest
 
Posts: n/a
Default Re: random word generator

Why not use a random number itself as a passcode?

--
Manohar Kamath
Editor, .netBooks
www.dotnetbooks.com


"Alistair" <email@wormfilteralistair.inuk.com> wrote in message
news:vo08kriifrma2e@corp.supernews.com...[color=blue]
> Hello folks...
>
> this is my first post in here. I'm new to ASP having done all my previous
> work in Flash and bog standard HTML. Only been learning for a couple of
> weeks.
>
> anyway...I have been building a guestbook type page, but as with quite a[/color]
lot[color=blue]
> of guestbooks and stuff some of the comments that get placed are not[/color]
exactly[color=blue]
> suitable, and tracking people down is a little difficult.
>
> maybe you all can think of much better ways but remember I'm a newbie and[/color]
am[color=blue]
> working my way through..
>
> so...
>
> I have a form where people sign up to become a member..they select their
> name and password etc and can log in, but this is completely anonymous....
>
> so..I got an email script set up and working (took me a long time to[/color]
figure[color=blue]
> that one out!!!) and connected to a dbase, The user gives me his email[/color]
addy[color=blue]
> and name and a random number is generated, stored as his password and the
> password is mailed to him,...thus if he doesn't give me a corect email[/color]
addy[color=blue]
> he doesn't get his password and therefore can't sign in or post nasty
> comments..
>
> But a number password isn't really all that and I would prefer to have a
> random word generated.
>
> is this possible??
>
> again, being a newbie and not very up on what I can/can't do...I thought[/color]
of[color=blue]
> the following...
>
> 1) Store a bunch of words in a text file with a space between each one
> 2) Read in this file and store it as a variable
> 3) Trim off a random number of characters from the start of the text
> 4) Then search for the next space (which would be the beginning of the[/color]
next[color=blue]
> complete word)
> 5) The next space after that would then mark the end of the word
> 6) count the characters between the two spaces to give me the word length
> 7) and then select that number of characters and then I have a randomly
> selected word!!!
>
> I can't see why it wouldn't work as it seems logical to me, but maybe
> someone (Ray seems to be the god of ASP (I've been reading here for a[/color]
couple[color=blue]
> of weeks and he seems to know everything!!!!)... can tell me otherwise?
>
> many thanks
>
>
>
>[/color]


  #5  
Old July 19th, 2005, 08:46 AM
Alan
Guest
 
Posts: n/a
Default Re: random word generator

Try this Alistair.

Function CreatePassword (Length)

Dim Count
Dim Password
Dim ValidLength
Const Valid =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvw xyz1234567890"

Password = ""
ValidLength = Len (Valid)
Randomize

' We want a password that is 'Length' characters long.
For Count = 1 To Length
Password = Password & Mid (Valid, (Int (Rnd * ValidLength) + 1), 1)
Next

CreatePassword = Password

End Function

Regards,

Alan

"Alistair" <email@wormfilteralistair.inuk.com> wrote in message
news:vo08kriifrma2e@corp.supernews.com...[color=blue]
> Hello folks...
>
> this is my first post in here. I'm new to ASP having done all my previous
> work in Flash and bog standard HTML. Only been learning for a couple of
> weeks.
>
> anyway...I have been building a guestbook type page, but as with quite a[/color]
lot[color=blue]
> of guestbooks and stuff some of the comments that get placed are not[/color]
exactly[color=blue]
> suitable, and tracking people down is a little difficult.
>
> maybe you all can think of much better ways but remember I'm a newbie and[/color]
am[color=blue]
> working my way through..
>
> so...
>
> I have a form where people sign up to become a member..they select their
> name and password etc and can log in, but this is completely anonymous....
>
> so..I got an email script set up and working (took me a long time to[/color]
figure[color=blue]
> that one out!!!) and connected to a dbase, The user gives me his email[/color]
addy[color=blue]
> and name and a random number is generated, stored as his password and the
> password is mailed to him,...thus if he doesn't give me a corect email[/color]
addy[color=blue]
> he doesn't get his password and therefore can't sign in or post nasty
> comments..
>
> But a number password isn't really all that and I would prefer to have a
> random word generated.
>
> is this possible??
>
> again, being a newbie and not very up on what I can/can't do...I thought[/color]
of[color=blue]
> the following...
>
> 1) Store a bunch of words in a text file with a space between each one
> 2) Read in this file and store it as a variable
> 3) Trim off a random number of characters from the start of the text
> 4) Then search for the next space (which would be the beginning of the[/color]
next[color=blue]
> complete word)
> 5) The next space after that would then mark the end of the word
> 6) count the characters between the two spaces to give me the word length
> 7) and then select that number of characters and then I have a randomly
> selected word!!!
>
> I can't see why it wouldn't work as it seems logical to me, but maybe
> someone (Ray seems to be the god of ASP (I've been reading here for a[/color]
couple[color=blue]
> of weeks and he seems to know everything!!!!)... can tell me otherwise?
>
> many thanks
>
>
>
>[/color]


  #6  
Old July 19th, 2005, 08:47 AM
WIlliam Morris
Guest
 
Posts: n/a
Default Re: random word generator

We use much the same function - with the exception that we remove the
vowels. This way, you don't "randomly" create inappropriate text. We also
double the string to flatten the selection curve.

--
William Morris
Product Development, Seritas LLC

"Alan" <XalanX.XhowardX@XparadiseX.XnetX.XnzX> wrote in message
news:#zWh3O4iDHA.2624@TK2MSFTNGP10.phx.gbl...[color=blue]
> Try this Alistair.
>
> Function CreatePassword (Length)
>
> Dim Count
> Dim Password
> Dim ValidLength
> Const Valid =
> "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvw xyz1234567890"
>
> Password = ""
> ValidLength = Len (Valid)
> Randomize
>
> ' We want a password that is 'Length' characters long.
> For Count = 1 To Length
> Password = Password & Mid (Valid, (Int (Rnd * ValidLength) + 1), 1)
> Next
>
> CreatePassword = Password
>
> End Function
>
> Regards,
>
> Alan
>
> "Alistair" <email@wormfilteralistair.inuk.com> wrote in message
> news:vo08kriifrma2e@corp.supernews.com...[color=green]
> > Hello folks...
> >
> > this is my first post in here. I'm new to ASP having done all my[/color][/color]
previous[color=blue][color=green]
> > work in Flash and bog standard HTML. Only been learning for a couple of
> > weeks.
> >
> > anyway...I have been building a guestbook type page, but as with quite a[/color]
> lot[color=green]
> > of guestbooks and stuff some of the comments that get placed are not[/color]
> exactly[color=green]
> > suitable, and tracking people down is a little difficult.
> >
> > maybe you all can think of much better ways but remember I'm a newbie[/color][/color]
and[color=blue]
> am[color=green]
> > working my way through..
> >
> > so...
> >
> > I have a form where people sign up to become a member..they select their
> > name and password etc and can log in, but this is completely[/color][/color]
anonymous....[color=blue][color=green]
> >
> > so..I got an email script set up and working (took me a long time to[/color]
> figure[color=green]
> > that one out!!!) and connected to a dbase, The user gives me his email[/color]
> addy[color=green]
> > and name and a random number is generated, stored as his password and[/color][/color]
the[color=blue][color=green]
> > password is mailed to him,...thus if he doesn't give me a corect email[/color]
> addy[color=green]
> > he doesn't get his password and therefore can't sign in or post nasty
> > comments..
> >
> > But a number password isn't really all that and I would prefer to have a
> > random word generated.
> >
> > is this possible??
> >
> > again, being a newbie and not very up on what I can/can't do...I thought[/color]
> of[color=green]
> > the following...
> >
> > 1) Store a bunch of words in a text file with a space between each one
> > 2) Read in this file and store it as a variable
> > 3) Trim off a random number of characters from the start of the text
> > 4) Then search for the next space (which would be the beginning of the[/color]
> next[color=green]
> > complete word)
> > 5) The next space after that would then mark the end of the word
> > 6) count the characters between the two spaces to give me the word[/color][/color]
length[color=blue][color=green]
> > 7) and then select that number of characters and then I have a randomly
> > selected word!!!
> >
> > I can't see why it wouldn't work as it seems logical to me, but maybe
> > someone (Ray seems to be the god of ASP (I've been reading here for a[/color]
> couple[color=green]
> > of weeks and he seems to know everything!!!!)... can tell me otherwise?
> >
> > many thanks
> >
> >
> >
> >[/color]
>
>[/color]


 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles