Howard Bullock
KiX Supporter
   
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
Here is my script that uses regular expressions via WSH to isolate the keys, and data. I decided that I wanted to explore this approach and did not want to abandon it just because I could not find a way to reduce the code content. It was a learning a experience.
check for all registry keys Errors:0 check for registry value types in import1:0 check for registry value types in import2:0 check for registry value types in import3:0 check for registry values in import1:0 check for registry values in import2:0 check for registry values in import3:0 The UDF ImportRegFile passed the validation test. Please do not forget to post your KiXtart Golf score.
KixGolf score = 918 code:
function ImportRegfile($Z) Dim $, $A[4], $B, $C, $o, $D, $E, $F, $G, $i, $K, $N, $T $o = createobject("VBscript.RegExp") $o.Global = 1
if ubound($Z)<0 $Z=$Z,"" endif for each $C in $Z
;ReadFile Kix $=open(1,$C) while @error=0 $B=ReadLine(1) if $B="" $E=$E+"`" else $E=$E+$B+"`" endif loop $=close(1)
$F=join(split($E,"\` "),"") $o.Pattern = '`\[(\-?)(.*?)\](?=`)|`"?([\w\- ]+)?@@?"?=("|.{3,6}\:)?(.*?)"?(?=`)' for each $B in $o.Execute($F) for $i=0 to 4 $A[$i]=$B.SubMatches($i) next
if $A[1] $K=$A[1] if $A[0] $C=DelKey($K) else $C=AddKey($K) endif else ;Add Values $N=$A[2] $D=$A[4] $T = 'dword:','hex:','"','hex(2):','','hex(7):' for $i=0 to 5 if $A[3]=$T[$i] $=$i endif next
if $=0 $D=val("&"+$D) endif
for each $C in split($D,",") if $=3 | $C>"00" & $=5 $B=execute('$C=Chr(&'+$C+')') endif $G=""+$G+$C next $D=$G $G="" if $=5 $D=join(split($D,"0000"),"|") endif
;Write Value if $D="-" $C=DelValue($K, $N) else if not $D $D="" endif $T = "DWORD","BINARY","SZ","EXPAND_SZ","","MULTI_SZ" $C=WriteValue($K, $N, $D, "REG_"+$T[$]) endif endif next next $ImportRegfile=0 exit 0 endfunction
[ 04 August 2002, 03:35: Message edited by: Howard Bullock ]
|