Jump to content
Sign in to follow this  
EndFunc

StringSplit with Ini

Recommended Posts

EndFunc

What I'm trying to do seems complicated and can't quite get it.

I am reading a value from an ini file. The value contains file extensions with a | as the delimter. Now what I am trying to do is create an input box to add or remove a file type from that value. So far I haven't had much luck. I tried using stringsplit and other thing but can't get it to delete the value or either add anything yet. Here's what I had so far which isn't much.

$FindType = IniRead($ConfigFile, "ConfigSet", "Search", "NotFound")
            $aType = StringSplit($FindType, "|")
            $SearchInput = InputBox($AppTitle, "These are the current file types to search." & @CRLF & $FindType & @CRLF & @CRLF & "Please enter a type to add or remove.", "", " M")
            If @error Then ContinueLoop
            For $t= 1 To $aType[0]
            If $SearchInput = $aType[$t] Then
            $imsgBoxAns = MsgBox(36, $AppTitle, "That file type is already exist. Do you want to remove it?")
             Select 
            Case $imsgBoxAns = 6
            StringReplace($aType[$t], " ", " ")
            StringStripWS($FindType,8)
            EndSelect
            Else
            ;IniWrite($ConfigFile, "ConfigSet", "Search", $aType[$t])
            Next

EndFuncAutoIt is the shiznit. I love it.

Share this post


Link to post
Share on other sites
evilertoaster

Are you maybe wanting a StringReplace() to remove them and simply a '&' to add extensions on to the end?

Edited by evilertoaster

Share this post


Link to post
Share on other sites
EndFunc

Are you maybe wanting a StringReplace() to remove them and simply a '&' to add extensions on to the end?

Well the ini file looks like

[ConfigSet]

Search=.doc|.xls|.ppt|.pst

I want to be able to remove any of the file types or add types in the Search key by editing the ini file with an inputbox and not manually. Can't figure out how to do it via an input box.

Edited by EndFunc

EndFuncAutoIt is the shiznit. I love it.

Share this post


Link to post
Share on other sites
evilertoaster

$read=IniRead(@ScriptDir & "\temp.ini","ConfigSet","Search","")

; Adds an extension
$read=$read&"|.zip"

;removes an extension
$read=StringReplace($read,"|.xls","")

;saves chages
IniWrite(@ScriptDir & "\temp.ini","ConfigSet","Search",$read)oÝ÷ Øz)yû¥+(Øb§¶«z+0«r¢ì×Ø­é¦iËnjYr¬zØb²+0«r¢ì×ø«y§bµ¨"jv®¶­s`¢b33c·&VCÔæ&VB67&DF"fײgV÷C²b3#·FV×æægV÷C²ÂgV÷C´6öæfu6WBgV÷C²ÂgV÷Cµ6V&6gV÷C²ÂgV÷C²gV÷C²¢b33c·6V&6ÒçWD&÷gV÷C²gV÷C²ÂgV÷C´VçFW"6ö×FærFòFB÷"&VÖ÷fRgV÷C²¢b33c·FV×Õ7G&æu&WÆ6Rb33c·&VBÂgV÷C·ÂgV÷C²fײb33c·6V&6ÂgV÷C²gV÷C²¦bb33c·FV×ÒgV÷C²gV÷C²FVâb33c·&VCÒb33c·&VBfײgV÷C·ÂgV÷C²fײb33c·6V&6¤æw&FR67&DF"fײgV÷C²b3#·FV×æægV÷C²ÂgV÷C´6öæfu6WBgV÷C²ÂgV÷Cµ6V&6gV÷C²Âb33c·&VB

Edited by evilertoaster

Share this post


Link to post
Share on other sites
EndFunc

$read=IniRead(@ScriptDir & "\temp.ini","ConfigSet","Search","")

; Adds an extension
$read=$read&"|.zip"

;removes an extension
$read=StringReplace($read,"|.xls","")

;saves chages
IniWrite(@ScriptDir & "\temp.ini","ConfigSet","Search",$read)oÝ÷ Øz)yû¥+(Øb§¶«z+0«r¢ì×Ø­é¦iËnjYr¬zØb²+0«r¢ì×ø«y§bµ¨"jv®¶­s`¢b33c·&VCÔæ&VB67&DF"fײgV÷C²b3#·FV×æægV÷C²ÂgV÷C´6öæfu6WBgV÷C²ÂgV÷Cµ6V&6gV÷C²ÂgV÷C²gV÷C²¢b33c·6V&6ÒçWD&÷gV÷C²gV÷C²ÂgV÷C´VçFW"6ö×FærFòFB÷"&VÖ÷fRgV÷C²¢b33c·FV×Õ7G&æu&WÆ6Rb33c·&VBÂgV÷C·ÂgV÷C²fײb33c·6V&6ÂgV÷C²gV÷C²¦bb33c·FV×ÒgV÷C²gV÷C²FVâb33c·&VCÒb33c·&VBfײgV÷C·ÂgV÷C²fײb33c·6V&6¤æw&FR67&DF"fײgV÷C²b3#·FV×æægV÷C²ÂgV÷C´6öæfu6WBgV÷C²ÂgV÷Cµ6V&6gV÷C²Âb33c·&VB
Yeah i haven't gotten that to work. It would need to be able to not have any spaces also once I did finally get what I'm trying to get work. I seems simple enough but just can't figure out syntax.

EndFuncAutoIt is the shiznit. I love it.

Share this post


Link to post
Share on other sites
PsaltyDS

Maybe:

$read = StringStripWS(IniRead(@ScriptDir & "\temp.ini", "ConfigSet", "Search", ""), 8)

$search = StringStripWS(InputBox("", "Enter somthing to add or remove"), 8)

If StringInStr($read, $search) Then
    If MsgBox(32 + 4, "Question", "Found in search list:  " & $search & @CRLF & _
            "Click YES to delete...") = 6 Then
        If StringInStr($read, $search & "|") Then
            $read = StringReplace($read, $search & "|", "")
        Else
            $read = StringReplace($read, "|" & $search, "")
        EndIf
    Else
        Exit
    EndIf
Else
    If MsgBox(32 + 4, "Question", "Not found in search list:  " & $search & @CRLF & _
            "Click YES to add...") = 6 Then
        $read &= "|" & $search
    Else
        Exit
    EndIf
EndIf

If MsgBox(32 + 1, "Question", "New search list:" & @CRLF & _
        @TAB & $read & @CRLF & _
        "Click OK to write to ini file, or CANCEL to exit...") = 1 Then
    IniWrite(@ScriptDir & "\temp.ini", "ConfigSet", "Search", $read)
Else
    Exit
EndIf

I don't understand the issue over "spaces", so I just threw in some StringStripWS() for that.

:shocked:

Edited by PsaltyDS

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites
EndFunc

Maybe:

$read = StringStripWS(IniRead(@ScriptDir & "\temp.ini", "ConfigSet", "Search", ""), 8)

$search = StringStripWS(InputBox("", "Enter somthing to add or remove"), 8)

If StringInStr($read, $search) Then
    If MsgBox(32 + 4, "Question", "Found in search list:  " & $search & @CRLF & _
            "Click YES to delete...") = 6 Then
        If StringInStr($read, $search & "|") Then
            $read = StringReplace($read, $search & "|", "")
        Else
            $read = StringReplace($read, "|" & $search, "")
        EndIf
    Else
        Exit
    EndIf
Else
    If MsgBox(32 + 4, "Question", "Not found in search list:  " & $search & @CRLF & _
            "Click YES to add...") = 6 Then
        $read &= "|" & $search
    Else
        Exit
    EndIf
EndIf

If MsgBox(32 + 1, "Question", "New search list:" & @CRLF & _
        @TAB & $read & @CRLF & _
        "Click OK to write to ini file, or CANCEL to exit...") = 1 Then
    IniWrite(@ScriptDir & "\temp.ini", "ConfigSet", "Search", $read)
Else
    Exit
EndIf

I don't understand the issue over "spaces", so I just threw in some StringStripWS() for that.

:shocked:

Very nice. Thanks It seems to do what I was trying to do :P. Oh well much appreciated. :(

EndFuncAutoIt is the shiznit. I love it.

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.