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 / Word generation

Author
Message
Master Man Of Justice
16
Years of Service
User Offline
Joined: 13th Feb 2008
Location: Between Insanity and Intelligence
Posted: 23rd Jan 2010 20:19 Edited at: 23rd Jan 2010 20:28
Ok, what im trying to do is make a program which writes to a file

X to Y length of alphanumerics,
like 1-5 characters and numbers possible using
ABCDEFGHIJKLMNOPQRSTUVWXYZ
and
1234567890

im know how to do the file access, but im having trouble with the main part, the generation.
i got here but now im totally stumped
i know about the left$ mid$ and right$ and len$ stuff
but im not quite sure how to go about this.


SoulMan
22
Years of Service
User Offline
Joined: 22nd Nov 2002
Location: In a house somewhere on the planet earth
Posted: 24th Jan 2010 05:08
Here's something I whipped up in about 10 Minutes.

It will take the two strings you provided and produce a random string of 16 characters randomly choosing between the two and then randomly choose from the length of the characters in each string.
Hope that helps.

I am Batman!
Neuro Fuzzy
17
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 26th Jan 2010 05:43
Couple problems with that code soulman. The RND command picks a random integer up to your argument, INCLUDING zero. Also, your counter goes from 0 to 16, INCLUDING zero, which means it would have 17 characters.

These lines:


therefore do not always add a character to OUTPUT$. If the rnd command returns a zero, the string returned from mid$ is "", because the indexes go from 1 to length.


To generate a random string always containing 16 character, randomly chosen from those to strings, the code would look like this:



SoulMan
22
Years of Service
User Offline
Joined: 22nd Nov 2002
Location: In a house somewhere on the planet earth
Posted: 26th Jan 2010 08:39
Ok, sorry if I was slightly off on the RND and For statement.
I thought it was odd too that when I had tried 0-15 it was just giving me 15 characters and when I did 0-16 it gave me 16 characters. However I should have tested the values a little more to see what was being generated. I'm going to add that to my list of things to watch out for.

I am Batman!

Login to post a reply

Server time is: 2024-11-24 20:50:56
Your offset time is: 2024-11-24 20:50:56