Nologic Posted December 3, 2004 Share Posted December 3, 2004 Not sure why the below code isn't working. I'm looking to split a sting once where the pipe symbol is "|" then split it once more at equals "=" and then write the value to the registry. $TB_1 = "Y" $TB_2 = "N" $TB_3 = "N" ... $TB_31 = "N" ; Toolbar Strings $TB_A = "01=New|02=Open|03=metapath|...|31=Print" For $i = 1 To 31 Step 1 $j = Eval( "TB_" & $i ) $k = StringSplit( $TB_A , '|' ) $l = StringSplit( $k[$i] , '=' ) If $j = "y" Then $keyname = "HKEY_CURRENT_USER\Software\Notepad2\Toolbar Strings" RegWrite ( $keyname , $l[1] , "REG_SZ" , $l[2] ) EndIf Next Link to comment Share on other sites More sharing options...
SlimShady Posted December 3, 2004 Share Posted December 3, 2004 (edited) I think this will work. I renamed the variables so you know in the future what the variables contain. Tip: Use an ini file and loop through the values instead of using: $TB_1, $TB_2, etc.. $TB_1 = "Y" $TB_2 = "N" $TB_3 = "N" ... $TB_31 = "N" ; Toolbar Strings $TB_A = "01=New|02=Open|03=metapath|...|31=Print" $toolbar_values = StringSplit($TB_A , '|' ) $keyname = "HKEY_CURRENT_USER\Software\Notepad2\Toolbar Strings" For $i = 1 To 31 Step 1 $choice = Eval( "TB_" & $i ) $value = StringSplit($toolbar_values[$i] , '=' ) $value_leftpart = $value[1] $value_rightpart = $value[2] If $choice = "y" Then RegWrite ( $keyname , $value_leftpart , "REG_SZ" , $value_rightpart) EndIf Next Edited December 3, 2004 by SlimShady Link to comment Share on other sites More sharing options...
Nologic Posted December 3, 2004 Author Share Posted December 3, 2004 SlimShady - Thanks for your time...found the problem tho...not the code...but my folder naming. Hehe its one of those embarassing moments. $g_szVersion = "Notepad2" If WinExists($g_szVersion) Then Exit; It"s already running AutoItWinSetTitle($g_szVersion) That was in the script and low and behold I was creating the script in a folder called Notepad2 that was open. Hehe so I'll take my dunce cap and go stand in the corner. Again thanks for the help. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now