| View previous topic :: View next topic |
| Author |
Message |
vds_noob2003 Newbie
Joined: 29 Dec 2002 Posts: 3
|
Posted: Sun Jan 05, 2003 4:19 am Post subject: Random character generator? Is this even POSSIBLE? |
|
|
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?" 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 |
|
 |
SnarlingSheep Professional Member


Joined: 13 Mar 2001 Posts: 759 Location: Michigan
|
Posted: Sun Jan 05, 2003 6:37 am Post subject: |
|
|
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 |
|
 |
Tsunami1988 Contributor


Joined: 15 Aug 2002 Posts: 70 Location: The Netherlands
|
Posted: Sun Jan 05, 2003 10:51 am Post subject: |
|
|
| 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 |
|
 |
ShinobiSoft Professional Member


Joined: 06 Nov 2002 Posts: 790 Location: Knoxville, Tn
|
Posted: Sun Jan 05, 2003 11:11 am Post subject: |
|
|
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 |
|
 |
Tsunami1988 Contributor


Joined: 15 Aug 2002 Posts: 70 Location: The Netherlands
|
Posted: Sun Jan 05, 2003 11:18 am Post subject: |
|
|
| 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 |
|
 |
Dr. Dread Professional Member


Joined: 03 Aug 2001 Posts: 1065 Location: Copenhagen, Denmark
|
|
| Back to top |
|
 |
vds_noob2003 Newbie
Joined: 29 Dec 2002 Posts: 3
|
Posted: Mon Jan 06, 2003 6:52 am Post subject: Thanks! Buuuut.... |
|
|
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  |
|
| Back to top |
|
 |
ShinobiSoft Professional Member


Joined: 06 Nov 2002 Posts: 790 Location: Knoxville, Tn
|
Posted: Mon Jan 06, 2003 7:00 am Post subject: |
|
|
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 |
|
 |
SnarlingSheep Professional Member


Joined: 13 Mar 2001 Posts: 759 Location: Michigan
|
Posted: Mon Jan 06, 2003 8:45 am Post subject: |
|
|
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
| 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  _________________ -Sheep
My pockets hurt... |
|
| Back to top |
|
 |
vds_noob2003 Newbie
Joined: 29 Dec 2002 Posts: 3
|
Posted: Mon Jan 06, 2003 8:25 pm Post subject: Gotcha! Buuuut.... |
|
|
Ok, last question, I promise! 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 |
|
 |
Tsunami1988 Contributor


Joined: 15 Aug 2002 Posts: 70 Location: The Netherlands
|
Posted: Mon Jan 06, 2003 8:44 pm Post subject: Re: Gotcha! Buuuut.... |
|
|
| vds_noob2003 wrote: | Ok, last question, I promise! 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
| 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 |
|
 |
SnarlingSheep Professional Member


Joined: 13 Mar 2001 Posts: 759 Location: Michigan
|
Posted: Mon Jan 06, 2003 9:13 pm Post subject: |
|
|
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 |
|
 |
|
|
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
|
|