Wordlist generator.

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
Corsario

Wordlist generator.

Post by Corsario » Thu Mar 04, 2004 7:24 pm

I need to generate automaticaly a secuential word list. Words might be 9 characters long. Characters to be used are all numbers and "a" to "z". I can do it with numbers, but not with other characters.
Thanks.

User avatar
support
Automation Wizard
Posts: 1450
Joined: Sat Oct 19, 2002 4:38 pm
Location: London
Contact:

Post by support » Thu Mar 04, 2004 7:46 pm

real words, or just a random selection of letters up to 9 long?

For real words would need some kind of database to compare to.

But creating random strings up to 9 chars long is no problem.
MJT Net Support
[email protected]

Corsario

Wordlist generator

Post by Corsario » Fri Mar 05, 2004 9:36 am

Not real words,

example:

starting at: 111111111
next: 111111112
next: .........
next: DB2FR52GF
next: .........
next: F64K7J25TR
next: .........
end: ZZZZZZZZZ

With numbers its easy.
Thanks.

Corsario

Wordlist generator

Post by Corsario » Fri Mar 05, 2004 9:43 am

It´s intended for sequentially numbering documents as invoices and keep them archived.
Thanks again.

User avatar
support
Automation Wizard
Posts: 1450
Joined: Sat Oct 19, 2002 4:38 pm
Location: London
Contact:

Post by support » Fri Mar 05, 2004 9:55 am

Hi,

This isn't random. As it starts with 111111111 and ends with ZZZZZZZZZ there must be a sequence.

But if you do want a random string generator, here's a subroutine I just knocked up which gives you a random alphanumeric string of 9 characters length:


SRT>MakeRandomString
Let>LengthOfString=9
Let>ChrArray=A;B;C;D;E;F;G;H;I;J;K;L;M;N;O;P;Q;R;S;T;U;V;W;X;Y;Z
Separate>ChrArray,;,Chars
Let>c=0
Let>theword=
Repeat>c
Let>c=c+1
//Let's flip a coin to see if we get a char or a number
Random>2,CharOrNum
If>CharOrNum=0,number,character
Label>number
Random>9,thenumber
Let>theword=%theword%%thenumber%
Goto>next
Label>character
Random>26,rndcharnum
Let>rndcharnum=rndcharnum+1
Let>thischar=Chars_%rndcharnum%
Let>theword=%theword%%thischar%
Label>next
Until>c,LengthOfString
END>MakeRandomString


This returns a variable called 'theword' containing the random string.

An example to show the subroutine in operation:


Label>start
GoSub>MakeRandomString
MessageModal>theword
Goto>start


Hope this helps.
MJT Net Support
[email protected]

User avatar
support
Automation Wizard
Posts: 1450
Joined: Sat Oct 19, 2002 4:38 pm
Location: London
Contact:

Post by support » Fri Mar 05, 2004 9:57 am

Hi,

Looking at your post again I don't think you mean random. You actually have a sequence I think where each bit of the string goes from A..Z then 1..9. Am I right? In which case that's easier. You just need to keep a record, maybe in an INI file of the last sequence used. And just increment. No need to use random at all.
MJT Net Support
[email protected]

Lumumba

Post by Lumumba » Fri Mar 05, 2004 10:01 am

Let>Alphabet=abcdefghijklmnopqrstuvwxyz
Let>ac=0
Let>RandomString=

Label>RGenerator
Add>ac,1
Random>Pos,26
MidStr>Alphabet,%Pos%,1,Char
ConCat>RandomString,%Char%
If>acDone
MessageModal>%RandomString%

-----

Well less sophisticated as what has been provided by MJT's support, but maybe usefull for Macro Scheduler novices and those who had to work with a previous release of Macro Scheduler (without that Array thang) :wink:

Please check the command syntax, was a quik brain dump and therefore could be wrong 8) and I had no chance to test it :oops:

Corsario
Newbie
Posts: 2
Joined: Fri Mar 05, 2004 9:48 am

Wordlist generator

Post by Corsario » Fri Mar 05, 2004 10:51 am

Wow! very nice forum and quick answer...

Yes, you are wright, dont need random. It´s a sequence. My problem was setting the characters to use and how to calculate the following step.
example:
take AA5GTR45A
and then get AA5GTR45B
adding the next number or letter following the numerical order and then the alphabetical order.
Thanks.

Lumumba

Post by Lumumba » Fri Mar 05, 2004 11:47 am

Every customer have his unique (cryptic) identifier with an incremental invoice number ?

But whats the trigger?

How to identify that the following invoice has to be for another customer (and therefore needs a new naming) ?

-----

Assuming you're saving the previously used InvoiceName in an INI file (and the counter is numeric) ...

ReadINIFile>...
MidStr>PrevInv,1,7,Name
MidStr>PrevInv,8,2,Counter
Ask>Following invoice for: %Name%[%Counter%] ?,Answer
If>Answer=NO,CreateNewInvoiceIdentifier
Add>Counter,1
WriteINIFile>C:\Invoice.ini
WriteLine>C:\%Name%%Counter%.txt, ...
.

Label>CreateNewInvoiceIdentifier
.
.
.

-----

MacroScheduler > 7.x works with the GoSub command - so feel free to create some spagethi code :wink:

Corsario
Newbie
Posts: 2
Joined: Fri Mar 05, 2004 9:48 am

Post by Corsario » Fri Mar 05, 2004 12:17 pm

Sorry for my english, I´m fighting with it. :oops:

The job is as follows:
I have created an invoice model in Word.
When I open the document I need to autocomplete the field invoice number. (As you know invoices need to be correlatively numbered.)
Numerically it´s easy (a=a+1), simply take the last number wich was stored in an ini file and add 1.
Then send the result to the invoice field.
Till here I have the code of the macro and runnig.

Here comes the problem: how to use alphanumeric characters instead of only numeric characters?, and keep correlatively numbered.

Thanks

Lumumba

Post by Lumumba » Fri Mar 05, 2004 3:18 pm

If you've to work with MSWord on a daily basis it would make sense to have a look at its already implemented macro functionality (VBA aka Visual Basic for Applications). Or you've the option to create a formula for that specific field!

I'm pretty sure that Support would be able to point to some VBS (aka Visual Basic Script) functions you can use from within Macro Scheduler.

Based on my suggestion (see above): you could check for the character (which you've taken from the INI) in the string variable "Alphabet" with the Position> command for its position and afterwards add 1 (to get the next character).

Lumumba

Post by Lumumba » Fri Mar 05, 2004 3:33 pm

Ey, its that easy ...
Once you've identified a character (and his position from the string var "Alphabet") save both informations in the INI.
So you've to add 1 to that "historic" char pos to get the next char from the string var. Done. Well very basic style. Who cares - it should work.

Let>Alphabet=abcdefghijklmnopqrstuvwxyz

Invoice.INI

[Invoice]

Name=AA5GTR45
CounterChar=b
CounterCharPos=2

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts