Long reply...Hi and welcome to the board.
I played around with your script a little and this is the top of the result.txt I made:
code:
33 = ('!')
34 = ('"')
35 = ('#')
36 = ('$')
37 = ('%')
38 = ('&')
39 = (''')
40 = ('(')
41 = (')')
42 = ('*')
43 = ('+')
44 = (',')
45 = ('-')
46 = ('.')
47 = ('/')
48 = ('0')
49 = ('1')
50 = ('2')
51 = ('3')
52 = ('4')
53 = ('5')
54 = ('6')
55 = ('7')
56 = ('8')
57 = ('9')
58 = (':')
59 = (';')
60 = ('<')
61 = ('=')
62 = ('>')
63 = ('?')
64 = ('@')
As you can see, the ", ', $, &, % and @ are all ok as single entries in the text file. Here is the part of the vartest.txt:
code:
'!'
'"'
'#'
'$'
'%'
'&'
'''
'('
')'
'*'
'+'
','
'-'
'.'
'/'
'0'
'1'
'2'
'3'
'4'
'5'
'6'
'7'
'8'
'9'
':'
';'
'<'
'='
'>'
'?'
'@'
ok, let's talk about Special Characters:
@
KiX and DOS (command prompt in Windows) treat @ in different ways. When KiX sees a @ it looks at the word touching and folloing the @ as a macro. ie @DATE is today's date. DOS, however, treats it as an ordinary character. If you want to output an @ in KiX, you need to @@.
examples from my manual:
@time ; shows the current time
@userid ; shows the user id of the current user
? "Your email address is cj@@email.com" ; prints cj@email.com
$
$ in KiX is used to show a variable. KiX looks at the word following and touching the $, so $abc is a variable and $abc def is only $abc and the def will prob raise an error. To print a $ on the screen or file in KiX you use $$. eg "I want more $$'s"
$ in DOS is a normal character. ie you can rename a file to a$b.txt if you want to.
%
% is used in KiX the same way as in DOS, it signifies an Environment Variable. %path% for example, is the current path. To print a % in KiX use %% eg "over 100%% is lots!" DOS sometimes uses % like KiX uses $
for example: for %a in (*.txt) do DEL %a this will delete all the .txt files in the current directory in DOS, but replacing %a with each .txt filename and running a DEL on it.
' and "
KiX uses both ' and " for quotes, but DOS only uses ". KiX uses quote for two things - as a 'display this text' command or a 'convert this number into a string' command; My manual covers this in greater detail. If you want to display a ' or " on the screen in KiX, you must surround it with the OTHER quote.
For example: To print don't - "don't" and to print "do" - '"do"'. KiX uses the outside quotes (ie the quote that is at the beginning and end) as the command and the inside is the text.
< and >
These are called ReDirectors in DOS and Comparitors (i think) in KiX. DOS uses these to 'redirect' the output of a process to a destination.
for example: DIR normally prints to the screen, but DIR > files.txt will print to a file called files.txt.
DOS uses > the same way KiX uses the REDIRECTOUTPUT() funciton. With the KiX ,0 is the DOS >> and the KiX ,1 is the DOS > (see the manual for more info about REDIRECTOUTPUT() )
< is DOS's reverse redirection. For example, there is a program in the NT4 Resource Kit called CLIP. It allows you to put the contents of a file onto the clipboard by doing this CLIP < yourfile.txt
In KiX < and > are used to test if one value is less than or greater than another. ie IF 1<2 "the universe is at peace" else "cj says 'welcome to my world'" endif
|
This symbol is called Pipe and is used by DOS to send the output of a process to another process.
For example DIR *.txt | find /i "result"
This will run a FIND /i "result" on each line of a DIR *.txt so any files that contain the word result will be displayed. ie result1.txt and 1result.txt. Getting DOS to do this from DIR without help is difficult. (the /i means ignore case)
KiX, however, treats | as a mathematical OR operation.
&
DOS treats & differently depending on the version of DOS you have. Some use it to allow multple commands on one line. eg DIR *.txt & DIR *.exe will do 2 DIRs. KiX uses & in two ways depending on syntax:
1. As a mathematical AND operator eg. $a=3&4
2. To convert a Hexadecimal number to Decimal. "&ff" ; prints 255
I hope I have covered them all.
So, the effects of a ', ", @, $, %, &, <, > or | in KiX and DOS will depend on where they are used and how. In DOS surrounding commands in "" often makes DOS ignore them: ie DIR "*.txt>file.txt" will return "file not found" unless you have a filename with ".txt>file.txt". KiX, however, is not fooled so easily and "@date" is the same as @date. KiX needs to see "@@date" to print the @ as a @.
I hope that as cleared things up a bit, if not, keep asking questions.
Now, changes to the script...
Rather than making a file full of characters, you can use the CHR() function to spit out the character of the number in (). eg CHR(65) is A and chr(97) is a.
When you are making passwords, note that some characters may not be allowed...
copy/paste this URL into ie:
search.microsoft.com/us/SearchMS25.asp?so=RECCNT&qu=characters%2520password%2520%2521&qu=extended+characters+password&boolean=ALL&i=08&i=07&p=1&nq=NEW&fqu=PASSWORD%2526CHARACTERS
Numbers in KiX. If you want to generate all the chars between 32 and 123 inclusive:
KiXtart 3.6x
code:
$i=start
DO
$var=chr($i)
; do your stuff here with $var
$i=$i+1
UNTIL $i=stop+1
or
KiXtart 2001 beta
code:
FOR $i=start TO stop
$var=chr($i)
; do your thing here with $var
NEXT
If you would like a password generator, here is a UDF version. A UDF is a User Defined Function and is new to KiX 2001 beta. Basically you can treat a UDF like a normal KiX function, so UDF(whatever) will print the return result of the UDF to the screen/file, $var=UDF(whatever) will assign the output to a variable, CHR(UDF(whatever)) will print the character whose number is returned by the UDF (this UDF must return a number) etc etc etc...
If you save this to a file called PassGen.UDF, you can access it from any script that has
CALL "\\server\share\PassGen.UDF"
in it. This is because KiX remembers all the UDFs it sees.
PassGen.UDF
code:
PassGen
Author cj (chrismat@ozemail.com.au)
Action Generates a random alphanumeric password
Syntax PASSGEN([length[,exclude]])
Parameters length
Optional numeric specifying the length of the password. If omitted, the length is set to eight (8).
exclude
Optional string of characters to be omitted from the password returned.
Returns A string of letters and numbers that is length long and does not contain any of the characters in exclude.
Examples passgen() ; returns 8 character alphanumeric string
Passgen(9) ; returns 9 char string
Passgen(6, "0Oo1l5Ss") ; 6 letters, no 0, 1, 5, o, l, s, O or S
Source
Function PassGen(Optional $iLength, Optional $sExclusion)
$PassGen="" ; default password is blank
if not val($iLength) $iLength=8 endif ; default length is 8
dim $i ; setup variables
$i=0
do
$x=rnd(2)
select
case $x=0 $iRND=rnd(9)+48 ; 0..9
case $x=1 $iRND=rnd(25)+97 ; a..z
case $x=2 $iRND=rnd(25)+65 ; A..Z
case 1
endSelect
if not instr($sExclusion, chr($iRND)) ; check exclusion list
$PassGen=$PassGen+chr($iRND)
$i=$i+1
endif
until $i=$iLength
EndFunction
The exclusion of 0, 1, 5, o, l, s, O and S could reduce the number of "my password doesn't work" call to your help desk
If you want to make the password case insensitive, ie a=A then just remove the line ending in ; A..Z from the UDF and change $x=rnd(2) to $x=rnd(1)
If you want to add support for special characters, let me know and I can tell you what to put into the UDF.
Well, that's enough outta me, anything I miss?
cj
------------------
cj's scripts page
cj's User Guide - 14 May 2001
chrismat@ozemail.com.au
[This message has been edited by cj (edited 22 May 2001).]