NTDOCAdministrator
(KiX Master)
2006-09-26 12:02 AM
KiXtart Learning Series - Lesson 02

KiXtart Learning Series - Round 02


    RULES
  • No KiXtart.org Moderators or Administrators aside from myself are allowed to post in this thread.
  • (This is for those with less experience to learn, not for bored, experienced users to bump their post count)
  • (If you're able to easily do this task then please don't participate with any solutions)
  • (If the task is too easy then I'll increase the difficulty level next time)
  • No using IM,PM or Google to locate/find an answer (you're on the honor system here).
  • For this lesson please don't use the UDF forum. The only help you're allowed is the KiXtart User Manual
  • All submitted code must be as though it were to be used in production. ie.. code should set options and
    have error checks as well as documentation of what the code is doing. Error checking does not need to
    be extensive but should have some basic check.
  • Code may be submitted as soon as you're ready.


Objective: Modify the 3rd binary value of the supplied regsitry modification to "bc"

Please download this Registry export which will create a new key and value in the Registry located here:
HKEY_CURRENT_USER\Software\KiXtart-Learning Round02

Download round02.reg

Code:
Windows Registry Editor Version 5.00
 
[HKEY_CURRENT_USER\Software\KiXtart-Learning]
"Round02"=hex:28,00,00,00,ff,ff,ff,ff,02,00,00,00,03,00,00,00,3c,00,00,00,50,\
00,00,00,fe,ff,ff,ff,b2,03,00,00,02,05,00,00,02,04,00,00
 




Previous Learning Series
9/21/2006
KiXtart Learning Series - Round 01
http://www.kixtart.org/ubbthreads/showflat.php?Cat=0&Number=168455

 


Gargoyle
(MM club member)
2006-09-26 02:57 AM
Re: KiXtart Learning Series - Round 02

Code:

;*************************************************************************
; Script Name: Learning Round 2
; Author: Gargoyle
; Date: 9/25/2006
; Description: Change a binary string in the registry
;*************************************************************************

Dim $SO,$ValRead,$Count,$Element,$valarray[],$ValWrite

;Script Options
$SO=SETOPTION("Explicit", "ON")
$SO=SETOPTION("NoMacrosInStrings", "ON")
$SO=SETOPTION("NoVarsInStrings", "ON")
$SO=SETOPTION("WrapAtEOL", "ON")

If NOT @LOGONMODE
    Break On
EndIf

; For use in creating an array to allow for changes to said array
$Element = 0

; Read in the Value we want to work with
$ValRead = ReadValue("HKCU\Software\KiXtart-Learning","Round02")

; Build an array with each element = to a binary group
For $Count = 1 to Len($ValRead) step 2
   
redim preserve $Valarray[$Element]
   
$ValArray[$Element] = SubStr($ValRead,$Count,2)
   
$Element = $Element + 1
Next


;Now we can change the element we want
$Valarray[2] = "bc"

;And now to put it all back together so that we can write it
For $Count = 0 to Ubound($Valarray)
   
$ValWrite = $Valwrite + $ValArray[$Count]
Next

;Finally we write it back to the registry
$SO = Writevalue("HKCU\Software\KiXtart-Learning","Round02",$ValWrite,"Reg_Binary")

?
$valRead
?$ValWrite



Gargoyle
(MM club member)
2006-09-26 03:58 AM
Re: KiXtart Learning Series - Round 02

And as a function with error checking...
Code:
;*************************************************************************
; Script Name: Learning Round 2
; Author: Gargoyle
; Date: 9/25/2006
; Description: Change a binary string in the registry
;*************************************************************************

;Error Codes
; 0 = Change has been made
; 3 = Change String to long
; 4 = Change String not in range (0 - f)
; 5 = Unable to read Value
; 6 = Unable to write value
; 7 = Invalid Position

; Required values
;     $Key = The Registry key to read
;     $Entry = The Registry entry to read
;     $Position = Which Binary position do you want to change
;     $Changeto = The value to change to

Dim $SO

;Script Options
$SO=SETOPTION("Explicit", "ON")
$SO=SETOPTION("NoMacrosInStrings", "ON")
$SO=SETOPTION("NoVarsInStrings", "ON")
$SO=SETOPTION("WrapAtEOL", "ON")

If NOT @LOGONMODE
    Break On
EndIf

ChangeBinary("HKCU\Software\KiXtart-Learning","Round02",3,"bc")

Function ChangeBinary($Key,$Entry,$Position,$ChangeTo)

Dim $ValRead,$Count,$Element,$valarray[],$ValWrite,$ValCheck[],$

$ValCheck = "0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"

;Check to make sure the ChangeTo is acceptable
If Len($ChangeTo) > 2
   
Exit 3
EndIf

For $ = 1 to 2
   
If Ascan($ValCheck,SubStr($Changeto,$,1)) = -1
       
Exit 4
    EndIf
Next


; For use in creating an array to allow for changes to said array
$Element = 0

; Read in the Value we want to work with
$ValRead = ReadValue($Key, $Entry3D"#000000" size=2>)

If @Error = 0

; Build an array with each element = to a binary group
    For $Count = 1 to Len($ValRead) step 2
       
redim preserve $Valarray[$Element]
       
$ValArray[$Element] = SubStr($ValRead,$Count,2)
       
$Element = $Element + 1
    Next
       
;Now we can change the element we want
If $Position > Ubound($Valarray)
   
Exit 7
Else
    $Valarray[($Position - 1)] = $ChangeTo
EndIf

;And now to put it all back together so that we can write it
    For $Count = 0 to Ubound($Valarray)
       
$ValWrite = $Valwrite + $ValArray[$Count]
    Next

;Finally we write it back to the registry
    If Writevalue($Key,$Entry,$ValWrite,"Reg_Binary") = 0
   
   
Else
        Exit 6
   
EndIf

Else
    Exit 5
EndIf


EndFunction
? @error



NTDOCAdministrator
(KiX Master)
2006-09-26 03:59 AM
Re: KiXtart Learning Series - Round 02

Very nice Gargoyle.

Are you sure you came up with that solution though just on your own and with the user manual?

If so, then I think you're a long way from noobie status on KiXtart.

I would not expect anyone that was new, semi-new to KiXtart to be able to easily have coded that.

Good job, thanks for participating.


Gargoyle
(MM club member)
2006-09-26 04:05 AM
Re: KiXtart Learning Series - Round 02

Once I had the first one, the second was easy. Had a heck of time figuring out how to break up the ReadValue string though.

I have watched you guys enough to start picking this stuff up, but since 90% of the scripting I do is Admin based, this is stuff I hardly ever get into (that and I am a networking guy and hardly ever touch the servers)


NTDOCAdministrator
(KiX Master)
2006-09-26 04:05 AM
Re: KiXtart Learning Series - Round 02

Nothing wrong overall with using a single $ for a var, but again if this was in use in a 1K - 2K lines of script using a single $ could be a nightmare for someone to manage that was not the orignal author of the code.

Again (imho) one should use a unique var for such a case or a meaningful name.

For use though in small scripts it is fine with me too.


NTDOCAdministrator
(KiX Master)
2006-09-26 04:13 AM
Re: KiXtart Learning Series - Round 02

So you trying to say that I should ratchet up the complexity of the series now?

Anyone out there lurking that is learning from this or is this just an open forum for me, Garg and Bjorn?


LonkeroAdministrator
(KiX Master Guru)
2006-09-26 04:44 AM
Re: KiXtart Learning Series - Round 02

just a point... (sorry for dropping into this thread I'm not supposed to post in)

using the $ var makes sense in here, when it was used instead of the good old $i.
but then, in the next loop he used $count.

for simplicity's sake, I would use either one, but not both.


Gargoyle
(MM club member)
2006-09-26 04:58 AM
Re: KiXtart Learning Series - Round 02

The lone $ was supposed to be changed to $Count before posting but I forgot to. As for the complexity, this one made me think a bit. So if you do decide to rachet it up another notch, just don't make it to big.

Bryce
(KiX Supporter)
2006-09-26 06:12 AM
Re: KiXtart Learning Series - Round 02

I love seeing these things!

By the way?

Code:

(˙˙˙˙&#9787;&#9829;<P_˙˙˙˛&#9829;&#9787;&#9827;&#9787;&#9830;



Did you sneeze on your keyboard?!?!


Bryce
(KiX Supporter)
2006-09-26 06:13 AM
Re: KiXtart Learning Series - Round 02

hmm the board forums don't like some those ASCII chars it seems :P

NTDOCAdministrator
(KiX Master)
2006-09-26 06:57 AM
Re: KiXtart Learning Series - Round 02

Yes, and I agreed that for use here it was fine, but in a larger script it could
easily lead to problems such as scope issues and or difficulty in others being able to manage the code.

The point being that one has to be aware and not just blindly use it because they saw other scripters use it.


Gargoyle
(MM club member)
2006-09-26 08:03 AM
Re: KiXtart Learning Series - Round 02

Quote:

I love seeing these things!

By the way?

Code:

(˙˙˙˙☻♥



Did you sneeze on your keyboard?!?!




Must be the HTML tags that I am posting with. I don't see it.


Björn
(Korg Regular)
2006-09-26 09:38 AM
Re: KiXtart Learning Series - Round 02

lol. I've missed that there was a round#02, I'll get right to it (haven't peeked at gargs code yet ) And Doc, I'll give you some noob-code

NTDOCAdministrator
(KiX Master)
2006-09-26 10:24 AM
Re: KiXtart Learning Series - Round 02

Okay here is another similar method.

NO LOOKING Bjorn!!


;Declare variable and set options 
If Not @LogonMode
Break On
EndIf
Dim $SO
$SO=SetOption('Explicit','On')
$SO=SetOption('NoVarsInStrings','On')
$SO=SetOption('NoMacrosInStrings','On')
$SO=SetOption('WrapAtEOL','On')

;Declare our variables
Dim $Key, $Value, $Count, $i, $UpdateValue
;Assign read value from the Registry to our variable
$Key = 'HKCU\Software\KiXtart-Learning'
$Value = ReadValue($Key,'Round02')
;Check if there is an error reading the value, if so quit and set error
If @ERROR Exit @ERROR EndIf
;Declare an array to use
Dim $Binary[(Len($Value)/2)-1]
;Set our counter to 0
$Count = 0
;Step through the read value and create the array
;We take 2 steps so that each element will be part of the 2 character binary value
For $i = 1 To Len($Value) Step 2
;We now assign 2 characters each time through the array
$Binary[$Count] = SubStr($Value,$i,2)
;We reset the counter before going back through the process again
$Count = $Count + 1
Next
;Here we set the specific element to a value we want to change
$Binary[2] = "bc"
;Now we write that value change to the registry using a Join since the $Binary
;var is an array format.
$UpdateValue = WriteValue($Key,'Round02',Join($Binary,""),REG_BINARY)
;Check if there is an error writing the value, if so quit and set error
If @ERROR Exit @ERROR EndIf




Björn
(Korg Regular)
2006-09-26 11:02 AM
Re: KiXtart Learning Series - Round 02

I'm trying not to! I'm currently stuck at the same point I always get stuck. will try to post something working in a while. (don't get your hopes up tho ) grrr. how can this be so tricky?
wait... I am not to add the same value again... grrr, back to the drawingboard - need to learn how to read..
Now, just dug my own grave. I'll post in a week or so when I'll start to think somewhat normal again...


PaulyT
(Fresh Scripter)
2006-09-26 04:39 PM
Re: KiXtart Learning Series - Round 02

I had ended up with similar code to the example Doc posted with a slight difference in the For - Next.

Code:

For $ = 1 to Len($round02RegValue) step 2
$modifyValueArray[$ / 2] = SubStr($round02RegValue, $, 2)
Next



I peek at the forum every day or two. It would be nice for a day to go by before posting results and making it temping for a look see.


Benny69
(MM club member)
2006-09-26 06:51 PM
Re: KiXtart Learning Series - Round 02

There is more than one way to skin a cat, here is a method without the use of arrays:
Code:

;region Setup Variables
Dim $so,$Byte_To_Be_Altered,$NewByteData,$Return

$so=SetOption("Explicit", "ON")
$so=SetOption("NoMacrosInStrings", "ON")
$so=SetOption("NoVarsInStrings", "ON")
$so=SetOption("WrapAtEOL", "ON")
;endregion

;set byte to be altered
$Byte_To_Be_Altered = 3

;set new byte data
$NewByteData = 'bc'

;call registry binary data change function
;AlterBinRegVal(< key >,< value >,< byte to be altered >,< new byte data >)
$Return = AlterBinRegVal('HKCU\Software\KiXtart-Learning','Round02',$Byte_To_Be_Altered,$NewByteData)
If Not($Return=0)
;do somthing with error code
EndIf

Function AlterBinRegVal($Key,$Value,$Byte,$Data)

;region Setup Variables
Dim $so,$Result,$AlteredResult,$Return
;endregion

;read registry value
$Result = ReadValue($Key,$Value)
;check for reading error, if so exit function
If @ERROR
Exit @ERROR
EndIf

;create new binary value by adding:
;'bytes Left of byte to be altered' + 'new data byte' + 'bytes Right of byte to be altered'
$AlteredResult = Left($Result,$Byte*2-2) + $Data + Right($Result,Len($Result)-$Byte*2)

;write altered value back to registry
$Return = WriteValue($Key,$Value,$AlteredResult,'Reg_Binary')
;check for writing error, if so exit function
If @ERROR
Exit @ERROR
EndIf

EndFunction



NTDOCAdministrator
(KiX Master)
2006-09-26 09:07 PM
Re: KiXtart Learning Series - Round 02

Nice Benny thanks for the input.

I do like this method that Witto has been using for the script header

Code:
If Not @LogonMode
Break On
EndIf



LonkeroAdministrator
(KiX Master Guru)
2006-09-26 10:28 PM
Re: KiXtart Learning Series - Round 02

to be noted. only useful for kix32.exe

NTDOCAdministrator
(KiX Master)
2006-09-26 10:49 PM
Re: KiXtart Learning Series - Round 02

Correct, thank you Jooel.

WKIX32.EXE is a console-less version of KiXtart.


Björn
(Korg Regular)
2006-09-28 12:14 PM
Re: KiXtart Learning Series - Round 02

hrm, ain't got the time to play currently.. will post some crap later on.

Mart
(KiX Supporter)
2006-09-28 01:10 PM
Re: KiXtart Learning Series - Round 02

Quote:


....
will post some crap later on
....





LOL Maybe someone can learn some crappy scripting this way
Nah, juts kidding Björn


Björn
(Korg Regular)
2006-09-28 01:37 PM
Re: KiXtart Learning Series - Round 02

Mart, that was exacly my point
feels terrible not having the 'time' to do this. feels even dumber that I didn't understand what to do first at all ^^;


Gargoyle
(MM club member)
2006-10-04 02:19 PM
Re: KiXtart Learning Series - Round 02

No pressure Doc, but are we going to have another round?

NTDOCAdministrator
(KiX Master)
2006-10-04 06:49 PM
Re: KiXtart Learning Series - Round 02

Yeah, pretty soon. Just a bit busy. This next round though there will be a delay before any posting.

Seems better if there is at least some type of delay before posting.


Björn
(Korg Regular)
2006-10-05 11:13 AM
Re: KiXtart Learning Series - Round 02

Agree about the delay - ain't got any time to do this stuff, too much going on at work and private right now..
I've got something working. will post at lunchtime (1,5h away)

ok, lunchtime and 2:nd post since my previous post seems to have failed
Notice : I'm not really happy with this - but cannot give it more time nor fix it better...
added: just noticed that my comments wasn't in this .. you'll have to live with it a few hours (removed those tags after my first post...)
ADDED AGAIN ... Well, after peeking at the other codes, I finally got to the point of REALLY knowing what was to be done... buggr. well, I'll be happy if I recive a 'f' for this

Code:

;enjoy my totally wrong code:
If NOT @LOGONMODE
Break On
EndIf

Dim $SO

$SO = SetOption("Explicit","On")
$SO = SetOption("NoVarsInStrings","On")
$SO = SetOption("NoMacrosInStrings","On")
;
dim $counter,$key,$val
dim $wr,$add,$wri
dim $split[],$c,$x
dim $sp[],$spl,$
;define values
$counter=0
$key='HKEY_CURRENT_USER\Software\Golfing'
$val='Round02'
$add='28,00,00,00,ff,ff,ff,ff,02,00,00,00,03,00,00,00,3c,00,00,00,50,\ 00,00,00,fe,ff,ff,ff,b2,03,00,00,02,05,00,00,02,04,00,00'
$wri='28000000ffffffff02000000030000003c00000050000000feffffffb20300000205000002040000'


$wr=readvalue($key,$val)
$split=split($add,',')


for each $c in $split
select
case $counter = 2 $c = 'bc' Redim preserve $sp[$counter] $sp[$counter]=$c
case 1 if instr($c,'\') $x=substr($c, len($c) - 1, 3) $=trim($x) Redim preserve $sp[$counter] $sp[$counter]=$x else Redim preserve $sp[$counter] $sp[$counter]=$c endif
endselect
$counter=$counter+1
next

ReDim $counter
$counter=0

for $counter = 0 to ubound($sp)
$spl = $spl + $sp[$counter]
next

/*
$wr ' Read value from reg' ?
$wri ' should be equal to line above' ?
$spl ' this is what we wanna write' ?
*/
if $wr = $spl 'entry already altered' ? exit @error else $wr=writevalue($key,$val,$spl,'reg_binary') if @error 'error: ' + @ERROR @SERROR + ' ' ? else 'altered key' ? endif endif



If you haven't noticed yet - this doesn't do what it was meant to do ...
and since this is the second time I cannot use my webbrowser and screwed up a third post / alterning of this post... gah, this is what I'll post and deliver, since this post I have peeked at others codes, and therefore I disqalify both my spelling and paricipation in this 'round'...
well, rewrote it quickly - or, did my 'own' version of the 'real' thing... this is more or less fresh from the drawingboard - not something I would put in production...
Code:


If NOT @LOGONMODE
Break On
EndIf

Dim $SO
Dim $wro[],$apa,$count,$counter,$wr,$wri,$key,$val,$to,$o,$
$SO = SetOption("Explicit","On")
$SO = SetOption("NoVarsInStrings","On")
$SO = SetOption("NoMacrosInStrings","On")
$key='HKEY_CURRENT_USER\Software\Golfing'
$val='Round02'
$count=0
$counter=0

$wri=readvalue($key,$val)

for $count=0 to 80 step 2
$o=right(ltrim(substr($wri, 1, $count)),2)
if $count=6 $o='bc' endif
Redim preserve $wro[$counter] $wro[$counter]=$o
$counter=$counter+1
next
Redim $counter
$counter=0

for $counter = 0 to ubound($wro)
$to= $to + $wro[$counter]
next

;$to ?
;$wri ?
if $to = $wri 'entry already altered' ? exit @error else $wr=writevalue($key,$val,$to,'reg_binary') if @error 'error: ' + @ERROR @SERROR + ' ' ? else 'altered key' ? endif endif



Björn
(Korg Regular)
2006-10-09 09:33 AM
Re: KiXtart Learning Series - Round 02

Just understood the task... will post something working today - got some spare time over for education

Björn
(Korg Regular)
2006-10-09 12:34 PM
Re: KiXtart Learning Series - Round 02

This is what I finally came up with - no real errorchecking tho =/ And man, I've used things I've never touched before.. and the redim preserve, that took like ages to acctually figure out how to do it.
Code:
If NOT @LOGONMODE
	Break On
EndIf

Dim $SO

$SO = SetOption("Explicit","On")
$SO = SetOption("NoVarsInStrings","On")
$SO = SetOption("NoMacrosInStrings","On")
;
dim $counter,$key,$val
dim $wr,$add,$wri
dim $split[],$c,$x
dim $sp[],$spl,$
;define values
$counter=0
$key='HKEY_CURRENT_USER\Software\Golfing'
$val='Round02'
$add='28,00,00,00,ff,ff,ff,ff,02,00,00,00,03,00,00,00,3c,00,00,00,50,\'+  '00,00,00,fe,ff,ff,ff,b2,03,00,00,02,05,00,00,02,04,00,00'
$wri='28000000ffffffff02000000030000003c00000050000000feffffffb203'+
'00000205000002040000'


$wr=readvalue($key,$val)
$split=split($add,',')


for each $c in $split
select 
case $counter = 2 $c = 'bc' Redim preserve $sp[$counter] $sp[$counter]=$c 
case 1 if instr($c,'\') $x=substr($c, len($c) - 1, 3) 
       $=trim($x) Redim preserve $sp[$counter] 
       $sp[$counter]=$x else Redim preserve $sp[$counter] $sp[$counter]=$c endif
endselect
$counter=$counter+1
next

ReDim $counter
$counter=0

for $counter = 0 to ubound($sp)
$spl = $spl + $sp[$counter]
next

/*
$wr ' Read value from reg' ?
$wri ' should be equal to line above'  ?
$spl ' this is what we wanna write' ?
*/
if $wr = $spl 'entry already altered' ? exit @error 
else 
$wr=writevalue($key,$val,$spl,'reg_binary') 
if @error 'error: ' + @ERROR @SERROR + ' ' ? 
else 
'altered key' ? endif endif


I just noticed that my fifth edit of this post has gone a-wall, and my final part that acctually did what it more or less was supposed to is gone..
Provided below:
Code:
If NOT @LOGONMODE
	Break On
EndIf

Dim $SO
Dim $wro[],$apa,$count,$counter,$wr,$wri,$key,$val,$to,$o,$
$SO = SetOption("Explicit","On")
$SO = SetOption("NoVarsInStrings","On")
$SO = SetOption("NoMacrosInStrings","On")
$key='HKEY_CURRENT_USER\Software\Golfing'
$val='Round02'
$count=0
$counter=0

$wri=readvalue($key,$val)

 for $count=0 to 80 step 2
  $o=right(ltrim(substr($wri, 1, $count)),2)
  if $count=6 $o='bc' endif
  ReDim preserve $wro[$counter] $wro[$counter]=$o 
  $counter=$counter+1
 next
ReDim $counter
$counter=0

 for $counter = 0 to ubound($wro)
  $to= $to + $wro[$counter]
 next 

 ;$to ?
 ;$wri ?
if $to = $wri 'entry already altered' ? exit @error 
else 
$wr=writevalue($key,$val,$to,'reg_binary') 
if @error 'error: ' + @ERROR @SERROR + ' ' ? 
else 
'altered key' ? endif endif

This still lacks errorchecking - and uses the wrong key-structure.., but should be the code-snippet that you could comment. Interesting that you didn't notice that it didn't do the job correctly


NTDOCAdministrator
(KiX Master)
2006-10-09 09:49 PM
Re: KiXtart Learning Series - Round 02

Hi Bjorn,

Okay I'll try to take a look and provide feedback later this evening.

I found that the forum was still set to not allow posting until approved. I've modified that so you can now post okay.

Please remove the long lines in your posts though.


NTDOCAdministrator
(KiX Master)
2006-10-10 04:35 AM
Re: KiXtart Learning Series - Round 02

I've left the long lines to comment on your code better.

In the future though please modify you code to prevent
the long lines.


;Good to have these options set 
If NOT @LOGONMODE
Break On
EndIf

Dim $SO

$SO = SetOption("Explicit","On")
$SO = SetOption("NoVarsInStrings","On")
$SO = SetOption("NoMacrosInStrings","On")
;
dim $counter,$key,$val
dim $wr,$add,$wri
dim $split[],$c,$x
dim $sp[],$spl,$
;define values
$counter=0
; This is not the correct key for the Round/Lesson 2
; I changed it from Round 1 to reflect the nature of these posts better
$key='HKEY_CURRENT_USER\Software\Golfing'
$val='Round02'
;Hard coding the value prevents you from altering similar code, you're stuck with
;only being able to update this specific entry vs a more dynamic approach to alter any
;similar binary values as show in some of the other examples.
$add='28,00,00,00,ff,ff,ff,ff,02,00,00,00,03,00,00,00,3c,00,00,00,50,\ 00,00,00,fe,ff,ff,ff,b2,03,00,00,02,05,00,00,02,04,00,00'
$wri='28000000ffffffff02000000030000003c00000050000000feffffffb20300000205000002040000'


$wr=readvalue($key,$val)
$split=split($add,',')

;Code layout / indenting could be improved to greatly enhance the readablilty of the code
;for other coders that might have to modify/update your code in the future.
for each $c in $split
;The use and indentation of SELECT could be improved for readability
select
case $counter = 2 $c = 'bc' Redim preserve $sp[$counter] $sp[$counter]=$c
;Don't need IF in this Select statement could just do Case InStr then supply another CASE 1 for
;instances where the expected results are not found. ie... what if anything you want to happen
;if your code just does not return what you expect.
case 1 if instr($c,'\') $x=substr($c, len($c) - 1, 3) $=trim($x) Redim preserve $sp[$counter] $sp[$counter]=$x else Redim preserve $sp[$counter] $sp[$counter]=$c endif
endselect
$counter=$counter+1
next

;Code naming should remain constant - ie... You use "redim" above and here you have "ReDim" not
;a critical issue but more attention to such details shows a more professional style of coding
ReDim $counter
$counter=0

for $counter = 0 to ubound($sp)
$spl = $spl + $sp[$counter]
next

/*
$wr ' Read value from reg' ?
$wri ' should be equal to line above' ?
$spl ' this is what we wanna write' ?
*/
if $wr = $spl 'entry already altered' ? exit @error else $wr=writevalue($key,$val,$spl,'reg_binary') if @error 'error: ' + @ERROR @SERROR + ' ' ? else 'altered key' ? endif endif

;Code was operational as posted, but lacked any real error checking and was limited
;in scope due to hard coding of the binary data instead of dynamically reading it.
;Code structure was not really commented on as to what the code is doing which should be
;a consideration for production coding in a business.

;Very unique method and glad to see you got it going Bjorn.
;Hope to see your code submission for Lesson 3

;Thanks again for participating, if you have any questions please let us know.


Björn
(Korg Regular)
2006-10-10 08:24 AM
Re: KiXtart Learning Series - Round 02

Thanks for the input Doc, sorry for the long lines, but my postings were screwed up all the time, and all my alterings is totally gone.. just edited it again and if you just changed so I can alter I hope you can verify my second snippet.

Björn
(Korg Regular)
2006-10-13 04:02 PM
Re: KiXtart Learning Series - Round 02

I do have a question, but I will rewrite my second submission / perhaps my first as well edited more in the lines of the rules and the way it should be written. Note, this is only for my own, I need to get a grip on handeling this more correct as you might have noticed. Will also try to participate in lesson #3 and hopefully submit something this weekend.