Sign in to follow this  
Followers 0
Nologic

StringSplit use

3 posts in this topic

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

Share this post


Link to post
Share on other sites



#2 ·  Posted (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 by SlimShady

Share this post


Link to post
Share on other sites

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. :lol:

Hehe so I'll take my dunce cap and go stand in the corner. :idiot:

Again thanks for the help. :D

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0