BrianTX
Korg Regular
Registered: 2002-04-01
Posts: 895
|
Here is the function I created that solves the problem and script(s) Jens posted.
Kixgolf score = 716 (Please someone else verify). I'm using KiXtart 2001 v4.10 (99) with Windows 2000 SP2.
Here is the code:
code:
Function ImportRegFile($c) DIM $,$y,$z,$k,$n,$a,$i,$b,$t IF UBOUND($c)<0 $c=SPLIT($c) ENDIF FOR EACH $y in $c OPEN(9,$y) Do $=READLINE(9) $y=LEFT($,1) $i=INSTR($,'=') If $y='[' $k=SUBSTR($,2,LEN($)-2) ADDKEY($k) If LEFT($k,1)='-' DELKEY(SUBSTR($k,2)) Endif Endif IF $i $a=SPLIT($,'=')[1] $n=SUBSTR($,2,$i-3) While RIGHT($a,1)=\ $a=LEFT($a,LEN($a)-1)+TRIM(READLINE(9)) Loop $y=SPLIT($a,':') SELECT CASE $y[0]=dword $=VAL('&'+SUBSTR($a,7)) $t=DWORD CASE UBOUND($y) $z=SUBSTR($y[0],5,1) $='' For $i= 1 to LEN($y[1]) STEP 3 $b=SUBSTR($y[1],$i,2) $t=BINARY If $Z $t=EXPAND_SZ $b=CHR(VAL('&'+$b)) Endif $=$+$b Next IF 7=$z $t=MULTI_SZ $=$+'|' Endif CASE 1 $=SUBSTR($a,2,LEN($a)-2) $t=SZ ENDSELECT WRITEVALUE($k,$n,$,'REG_'+$t) IF $a='-' Delvalue($k,$n) Endif Endif Until @error Close(9) Next EndFunction
I'm not sure I used every trick in the book, but I used most of them. Feel free to verify the script and score.
There are some shortcomings in my script in that it doesn't work for every .reg file, only ones similar to the ones Jens created....
The next stage is to improve this script (I would suggest we add error-correction and support various exceptions that would cause the script to bomb with some .reg files in addition to) by making it even shorter.
Brian
{edit} Also, please post your versions of the script, as well! I won't be here for a bit, cuz I'm going out to a movie.. Cheers! [ 21 July 2002, 00:14: Message edited by: BrianTX ]
|