forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Random character generator? Is this even POSSIBLE?

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help
View previous topic :: View next topic  
Author Message
vds_noob2003
Newbie


Joined: 29 Dec 2002
Posts: 3

PostPosted: Sun Jan 05, 2003 4:19 am    Post subject: Random character generator? Is this even POSSIBLE? Reply with quote

I'm really confused. I was sitting here, playing with this neat new language,
feeling all proud of myself for the stupid little programs I made, when I
came to a problem. I thought "Hey, can I make something randomly
generate 12 characters/numbers and assign a variable to it?" Confused Well,
I've been sitting here for like ever now and I can't seem to figure it
out...any suggestions would be VERY welcome.

In advance,
Thanks from a very confused VDS newbie
Back to top
View user's profile Send private message
SnarlingSheep
Professional Member
Professional Member


Joined: 13 Mar 2001
Posts: 759
Location: Michigan

PostPosted: Sun Jan 05, 2003 6:37 am    Post subject: Reply with quote

Welcome to VDS.
Hopefully I understand what you mean, if so this is pretty simple.
%%RangeA and B hold the ranges for @RANDOM(). I have it between 48 and 90 to generate random characters from 0 to Z, then put them into %%Test using @CHR(). For example if @RANDOM() comes up with 72(alt+072) it would put "H" as one of the characters.
Let me know if it's not what you were looking for.
Code:

%%RangeA = 48
%%RangeB = 90
%%Test = @CHR(@RANDOM(%%RangeA,%%RangeB))@CHR(@RANDOM(%%RangeA,%%RangeB))@CHR(@RANDOM(%%RangeA,%%RangeB))@CHR(@RANDOM(%%RangeA,%%RangeB))@CHR(@RANDOM(%%RangeA,%%RangeB))@CHR(@RANDOM(%%RangeA,%%RangeB))@CHR(@RANDOM(%%RangeA,%%RangeB))@CHR(@RANDOM(%%RangeA,%%RangeB))@CHR(@RANDOM(%%RangeA,%%RangeB))@CHR(@RANDOM(%%RangeA,%%RangeB))@CHR(@RANDOM(%%RangeA,%%RangeB))@CHR(@RANDOM(%%RangeA,%%RangeB))
INFO %%Test

_________________
-Sheep
My pockets hurt...
Back to top
View user's profile Send private message Send e-mail
Tsunami1988
Contributor
Contributor


Joined: 15 Aug 2002
Posts: 70
Location: The Netherlands

PostPosted: Sun Jan 05, 2003 10:51 am    Post subject: Reply with quote

SnarlingSheep wrote:
Welcome to VDS.
Hopefully I understand what you mean, if so this is pretty simple.
%%RangeA and B hold the ranges for @RANDOM(). I have it between 48 and 90 to generate random characters from 0 to Z, then put them into %%Test using @CHR(). For example if @RANDOM() comes up with 72(alt+072) it would put "H" as one of the characters.
Let me know if it's not what you were looking for.
Code:

%%RangeA = 48
%%RangeB = 90
%%Test = @CHR(@RANDOM(%%RangeA,%%RangeB))@CHR(@RANDOM(%%RangeA,%%RangeB))@CHR(@RANDOM(%%RangeA,%%RangeB))@CHR(@RANDOM(%%RangeA,%%RangeB))@CHR(@RANDOM(%%RangeA,%%RangeB))@CHR(@RANDOM(%%RangeA,%%RangeB))@CHR(@RANDOM(%%RangeA,%%RangeB))@CHR(@RANDOM(%%RangeA,%%RangeB))@CHR(@RANDOM(%%RangeA,%%RangeB))@CHR(@RANDOM(%%RangeA,%%RangeB))@CHR(@RANDOM(%%RangeA,%%RangeB))@CHR(@RANDOM(%%RangeA,%%RangeB))
INFO %%Test

Doesn't @RANDOM() only works for VDS 2.x (and lower)? I get an "Invalid @ function" when I use it in VDS 3.51.
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
ShinobiSoft
Professional Member
Professional Member


Joined: 06 Nov 2002
Posts: 790
Location: Knoxville, Tn

PostPosted: Sun Jan 05, 2003 11:11 am    Post subject: Reply with quote

Actually @random() and RANDOM are a function/command for VDS 4, but
can be obtained for previous version of VDS with the vdsrnd16.dll. I
beleive there is also a vdsrnd32.dll.

_________________
Bill Weckel
ShinobiSoft Software

"The way is known to all, but not all know it."
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger
Tsunami1988
Contributor
Contributor


Joined: 15 Aug 2002
Posts: 70
Location: The Netherlands

PostPosted: Sun Jan 05, 2003 11:18 am    Post subject: Reply with quote

bweckel wrote:
Actually @random() and RANDOM are a function/command for VDS 4, but
can be obtained for previous version of VDS with the vdsrnd16.dll. I
beleive there is also a vdsrnd32.dll.

You're right. I tried vdsrnd16.dll before, but that didn't work for me. But vdsrnd32.dll works perfect. Thanx!
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
Dr. Dread
Professional Member
Professional Member


Joined: 03 Aug 2001
Posts: 1065
Location: Copenhagen, Denmark

PostPosted: Sun Jan 05, 2003 11:39 am    Post subject: Reply with quote

Once upon a time I did a random password generator - pure VDS, no DLLs. It runs in VDS 3 also
and can be tweaked to pick random characters from a list of available chars.

It's posted here:
http://www.vdsworld.com/forum/viewtopic.php?t=125

Greetz
Dr. Dread

_________________
~~ Alcohol and calculus don't mix... Don't drink and derive! ~~

String.DLL * advanced string processing
Back to top
View user's profile Send private message
vds_noob2003
Newbie


Joined: 29 Dec 2002
Posts: 3

PostPosted: Mon Jan 06, 2003 6:52 am    Post subject: Thanks! Buuuut.... Reply with quote

I'm still not sure of everything. Why did you choose 48 and 90 as your ranges?? And that @CHR in there confuses me further, lol. Can I make it simpler for myself? How about randomly generating just ONE character, lol. Would the code look like...

%%RangeA = 48
%%RangeB = 90
%%Test = @CHR(@RANDOM(%%RangeA,%%RangeB))

That? Hehe...I think the only parts I don't understand are the numbers 48 and 90, and the @CHR stuck in there. If you could explain that and help me, I would appreciate it SO much!!!!

Once again,
Thanks in advance from a less confused newbie to VDS Very Happy
Back to top
View user's profile Send private message
ShinobiSoft
Professional Member
Professional Member


Joined: 06 Nov 2002
Posts: 790
Location: Knoxville, Tn

PostPosted: Mon Jan 06, 2003 7:00 am    Post subject: Reply with quote

48 and 90 are character codes. @chr() converts the character codes to
ascii text. For example, @chr(90) is the letter Z. For his example, he's
using numbers 1 thru 0 and characters A thru Z.

_________________
Bill Weckel
ShinobiSoft Software

"The way is known to all, but not all know it."
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger
SnarlingSheep
Professional Member
Professional Member


Joined: 13 Mar 2001
Posts: 759
Location: Michigan

PostPosted: Mon Jan 06, 2003 8:45 am    Post subject: Reply with quote

To hopefully help you out a bit more, open a text editor, like Notepad, hold your alt key and on the keypad(on the right of the keyboard) hit 0 then 1 then 6 then 9 and let go of alt. That will show "©"
That means the Character Code for the copyright symbol is 169. @CHR() in VDS will turn that Character Code back into regular text.
Try out the code below and see if it helps you, and read through the VDS help file Wink
Code:

%%Char = ©
REM Use @ASC() to show the Character Code for ©
%%CharCode = @ASC(%%Char)
INFO Character Code is: %%CharCode
REM Use @CHR() to turn that Character Code back to ASCII Text
INFO ASCII Text Value is: @CHR(%%CharCode)

Once you get the hang of a few things, VDS couldn't be much easier.
Good luck Smile

_________________
-Sheep
My pockets hurt...
Back to top
View user's profile Send private message Send e-mail
vds_noob2003
Newbie


Joined: 29 Dec 2002
Posts: 3

PostPosted: Mon Jan 06, 2003 8:25 pm    Post subject: Gotcha! Buuuut.... Reply with quote

Ok, last question, I promise! Smile Ok, now that I understand how to generate random numbers and place them into a variable, how do I make a random amount of random characters and place them into a variable? That may sound slightly confusing (atleast to me, lol), so I'll rephrase it. Remember how earlier I wondered if you could take like a certain amount of characters, generate them randomly, and place them into a variable? it's the same, except instead of 14 characters I want to randomly generate to put into a variable, I want to generate a random amount of characters (within reason, like 1-300 characters) and do the same thing we did before.
Back to top
View user's profile Send private message
Tsunami1988
Contributor
Contributor


Joined: 15 Aug 2002
Posts: 70
Location: The Netherlands

PostPosted: Mon Jan 06, 2003 8:44 pm    Post subject: Re: Gotcha! Buuuut.... Reply with quote

vds_noob2003 wrote:
Ok, last question, I promise! Smile Ok, now that I understand how to generate random numbers and place them into a variable, how do I make a random amount of random characters and place them into a variable? That may sound slightly confusing (atleast to me, lol), so I'll rephrase it. Remember how earlier I wondered if you could take like a certain amount of characters, generate them randomly, and place them into a variable? it's the same, except instead of 14 characters I want to randomly generate to put into a variable, I want to generate a random amount of characters (within reason, like 1-300 characters) and do the same thing we did before.


Ok, I think that this should work Smile

Code:
%%RangeA = 1
%%RangeB = 300
%%Range1 = @RANDOM(%%RangeA,%%RangeB)

%%RangeC = 1
%%RangeD = 300
%%Range2 = @RANDOM(%%RangeC,%%RangeD)

IF @GREATER(%%Range1,%%Range2)
  %%Range = @RANDOM(%%Range2,%%Range1)
ELSE
  %%Range = @RANDOM(%%Range1,%%Range2)
END
INFO %%Range1@CR()%%Range2@CR()@CR()%%Range@CR()@CR()@CHR(%%Range)
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
SnarlingSheep
Professional Member
Professional Member


Joined: 13 Mar 2001
Posts: 759
Location: Michigan

PostPosted: Mon Jan 06, 2003 9:13 pm    Post subject: Reply with quote

I think this is what you want.
Code:

REM Holds how many characters to generate..between 1 and 15.
%%Characters = @RANDOM(1,15)
%X = 1
%%Test = ""
REM Add a Random Character until there are as many as the number %%Characters holds.
REPEAT
  %%Test = %%Test@CHR(@RANDOM(48,90))
   %X = @FADD(%X,1)
UNTIL @GREATER(%X,%%Characters)
INFO %%Test

_________________
-Sheep
My pockets hurt...
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group