stefionesco

Multiple equal sign in INI file

13 posts in this topic

#1 ·  Posted

I have an INI file that contains some equal sign in the key of one of the section. Something like this:

[section]

https://www.google.ro/#safe=active&q=test = link_value

When I read the value is giving me as a result this "test = link_value".

I tried backslash, quotes, but nothing.

How can I skip the first equal sign?

Thanks

 

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Wouldn't

link_value = https://www.google.ro/#safe=active&q=test

be more sensible?

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

stefionesco,

When I test I get:

Row |Col 0                           |Col 1
[1] |https://www.google.ro/#safe     active&q=test = link_value

which is what I would expect.

If you create the ini files as part of your script, why not reverse the key/value pairs so as to avoid the problem?

M23

Edit: Hi water - great minds, eh?

Edited by Melba23
1 person likes this

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

#4 ·  Posted

Oh, my God... I never thought about this solution. Yes, indeed... Great minds.

Thanks

Share this post


Link to post
Share on other sites

#5 ·  Posted

Hi Melba,

I do my very best to - sometimes - be one step ahead of you ;)

1 person likes this

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#6 ·  Posted

On 11/4/2017 at 4:07 PM, water said:

Hi Melba,

I do my very best to - sometimes - be one step ahead of you ;)

OT:

 

But worth :D 


Click here to see my signature:

Spoiler

I will always thank you for the time you spent for me.
I'm here to ask, and from your response, I'd like to learn.
By my knowledge, I can help someone else, and "that someone" could help in turn another, and so on.

Share this post


Link to post
Share on other sites

#8 ·  Posted

Hi, there

I'm trying to make an application that search for subtitle for some movies, on Romanian subtitle site.
It seems to be an error in my script but I can't figure where. I think it's something about the fact that the value in every section contains equal sign.
I put in every section of INI file a link with both, English and Romanian subtitle, and a link that doesn't have none of them. Every search I made result positive with both subtitles in both links.
Where is the error?

Here is the script and the data.ini file.

 

#include <GuiConstants.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiConstants.au3>
#include <WindowsConstants.au3>
#include <AutoItConstants.au3>
#include <file.au3>
#include <FileConstants.au3>
#include <IE.au3>
#include <MsgBoxConstants.au3>

Local $oIE
Local $sSection1;Audrey Hepburn
Local $sSection2;Sean Connery
Local $sSection3;Rita Hayworth
Local $sLanguage
Local $sResult = ("Result.ini")
Local $aSection1 = IniReadSection('data.ini', 'Section1')
Local $aSection2 = IniReadSection('data.ini', 'Section2')
Local $aSection3 = IniReadSection('data.ini', 'Section3')
Local $aLanguage = IniReadSection('data.ini', 'Language')


Opt("GUIOnEventMode", 1)

Global $mainwindow = GuiCreate("SUB Tracker", 220, 180, 100, 100)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Terminate")

Local $idRadio1 = GUICtrlCreateRadio("Audrey Hepburn", 10, 10, 200, 20)
Local $idRadio2 = GUICtrlCreateRadio("Sean Connery", 10, 40, 200, 20)
Local $idRadio3 = GUICtrlCreateRadio("Rita Hayworth", 10, 70, 200, 20)

Local $searchbutton = GUICtrlCreateButton("SEARCH", 60, 100, 100, 25)
Local $resultbutton = GUICtrlCreateButton("SHOW RESULT", 50, 140, 120, 25)

GUICtrlSetOnEvent($resultbutton, "_Result")
GUICtrlSetOnEvent($searchbutton, "_Search")

GUISetState(@SW_SHOW)

While 1
    Sleep(100)
WEnd

Func _Result()
        ShellExecute ("Result.ini")
EndFunc

Func _Search()
            If GUICtrlRead($idRadio1) = $GUI_CHECKED Then
                SplashTextOn("Searching", "Search...", 600, 50)
                    For $i = 1 To $aSection1[0][0]
                        ControlSetText("Searching", "", "Static1", "Searching the SUB for " & $aSection1[$i][0])
                        $oIE = _IECreate($aSection1[$i][1], 1)
                        _IELoadWait($oIE)
                        $sSection1 = _IEBodyReadText($oIE)
                    For $j = 1 To $aLanguage[0][0]
                        If StringInStr($sSection1, $aLanguage[$j][0]) Then
                            IniWrite($sResult, $aSection1[$i][0], $aLanguage[$j][0], $aLanguage[$j][1])
                        EndIf
                    Next
                        _IEQuit($oIE)
                    Next
                        SplashOff()
                    MsgBox($MB_ICONINFORMATION, "SUB Tracker", "Done", 0)
            EndIf

            If GUICtrlRead($idRadio2) = $GUI_CHECKED Then
                SplashTextOn("Searching", "Search...", 600, 50)
                    For $i = 1 To $aSection2[0][0]
                        ControlSetText("Searching", "", "Static1", "Searching the SUB for " & $aSection2[$i][0])
                        $oIE = _IECreate($aSection2[$i][1], 1)
                        _IELoadWait($oIE)
                        $sSection2 = _IEBodyReadText($oIE)
                    For $j = 1 To $aLanguage[0][0]
                        If StringInStr($sSection2, $aLanguage[$j][0]) Then
                            IniWrite($sResult, $aSection2[$i][0], $aLanguage[$j][0], $aLanguage[$j][1])
                        EndIf
                    Next
                        _IEQuit($oIE)
                    Next
                        SplashOff()
                    MsgBox($MB_ICONINFORMATION, "SUB Tracker", "Done", 0)
            EndIf

            If GUICtrlRead($idRadio3) = $GUI_CHECKED Then
                SplashTextOn("Searching", "Search...", 600, 50)
                    For $i = 1 To $aSection3[0][0]
                        ControlSetText("Searching", "", "Static1", "Searching the SUB for " & $aSection3[$i][0])
                        $oIE = _IECreate($aSection3[$i][1], 1)
                        _IELoadWait($oIE)
                        $sSection3 = _IEBodyReadText($oIE)
                    For $j = 1 To $aLanguage[0][0]
                        If StringInStr($sSection3, $aLanguage[$j][0]) Then
                            IniWrite($sResult, $aSection3[$i][0], $aLanguage[$j][0], $aLanguage[$j][1])
                        EndIf
                    Next
                        _IEQuit($oIE)
                    Next
                        SplashOff()
                    MsgBox($MB_ICONINFORMATION, "SUB Tracker", "Done", 0)
            EndIf

EndFunc

Func _Terminate()
    Exit
EndFunc

Respect

Stef Ionesco

data.ini

Share this post


Link to post
Share on other sites

#9 ·  Posted

There is absolutely no error checking in your script. Example: When data.ini is not available your script crashes.
Add error checking after each function call and your script will show where you hit an error.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#10 ·  Posted

But data.ini is always available. 

Only the results is:

Quote

[My Fair Lady (1964)]
Romana=Romanian
Engleza=English
[Sauce Tartare (1949)]
Romana=Romanian
Engleza=English


and should be only this:

Quote

[My Fair Lady (1964)]
Romana=Romanian
Engleza=English

 

 

Share this post


Link to post
Share on other sites

#11 ·  Posted

That was just an example. I wanted to tell you that if an error occurs it goes unnoticed.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

You mean this:

#include <GuiConstants.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiConstants.au3>
#include <WindowsConstants.au3>
#include <AutoItConstants.au3>
#include <file.au3>
#include <FileConstants.au3>
#include <IE.au3>
#include <MsgBoxConstants.au3>

Local $oIE
Local $sSection1;Audrey Hepburn
Local $sSection2;Sean Connery
Local $sSection3;Rita Hayworth
Local $sLanguage
Local $sResult = ("Result.ini")
Local $aSection1 = IniReadSection('data.ini', 'Section1')
Local $aSection2 = IniReadSection('data.ini', 'Section2')
Local $aSection3 = IniReadSection('data.ini', 'Section3')
Local $aLanguage = IniReadSection('data.ini', 'Language')


Opt("GUIOnEventMode", 1)

Global $mainwindow = GuiCreate("SUB Tracker", 220, 180, 100, 100)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Terminate")

Local $idRadio1 = GUICtrlCreateRadio("Audrey Hepburn", 10, 10, 200, 20)
Local $idRadio2 = GUICtrlCreateRadio("Sean Connery", 10, 40, 200, 20)
Local $idRadio3 = GUICtrlCreateRadio("Rita Hayworth", 10, 70, 200, 20)

Local $searchbutton = GUICtrlCreateButton("SEARCH", 60, 100, 100, 25)
Local $resultbutton = GUICtrlCreateButton("SHOW RESULT", 50, 140, 120, 25)

GUICtrlSetOnEvent($resultbutton, "_Result")
GUICtrlSetOnEvent($searchbutton, "_Search")

GUISetState(@SW_SHOW)

While 1
    Sleep(100)
WEnd

Func _Result()
        ShellExecute ("Result.ini")
EndFunc

Func _Search()
            If GUICtrlRead($idRadio1) = $GUI_CHECKED Then
                SplashTextOn("Searching", "Search...", 600, 50)
                    For $i = 1 To $aSection1[0][0]
                        ControlSetText("Searching", "", "Static1", "Searching the SUB for " & $aSection1[$i][0])
                        $oIE = _IECreate($aSection1[$i][1], 1)
                        _IELoadWait($oIE)
                        $sSection1 = _IEBodyReadText($oIE)
                    For $j = 1 To $aLanguage[0][0]
                        If StringInStr($sSection1, $aLanguage[$j][0]) Then
                            IniWrite($sResult, $aSection1[$i][0], $aLanguage[$j][0], $aLanguage[$j][1])
                        EndIf

                    Next
                        _IEQuit($oIE)
                    Next
                        SplashOff()
                        If @error Then
                            msgbox(0,"failed",@error)
                        Else
                        MsgBox($MB_ICONINFORMATION, "SUB Tracker", "Done", 0)
                        EndIf

            EndIf

            If GUICtrlRead($idRadio2) = $GUI_CHECKED Then
                SplashTextOn("Searching", "Search...", 600, 50)
                    For $i = 1 To $aSection2[0][0]
                        ControlSetText("Searching", "", "Static1", "Searching the SUB for " & $aSection2[$i][0])
                        $oIE = _IECreate($aSection2[$i][1], 1)
                        _IELoadWait($oIE)
                        $sSection2 = _IEBodyReadText($oIE)
                    For $j = 1 To $aLanguage[0][0]
                        If StringInStr($sSection2, $aLanguage[$j][0]) Then
                            IniWrite($sResult, $aSection2[$i][0], $aLanguage[$j][0], $aLanguage[$j][1])
                        EndIf
                    Next
                        _IEQuit($oIE)
                    Next
                        SplashOff()
                        If @error Then
                            msgbox(0,"failed",@error)
                        Else
                        MsgBox($MB_ICONINFORMATION, "SUB Tracker", "Done", 0)
                        EndIf
            EndIf

            If GUICtrlRead($idRadio3) = $GUI_CHECKED Then
                SplashTextOn("Searching", "Search...", 600, 50)
                    For $i = 1 To $aSection3[0][0]
                        ControlSetText("Searching", "", "Static1", "Searching the SUB for " & $aSection3[$i][0])
                        $oIE = _IECreate($aSection3[$i][1], 1)
                        _IELoadWait($oIE)
                        $sSection3 = _IEBodyReadText($oIE)
                    For $j = 1 To $aLanguage[0][0]
                        If StringInStr($sSection3, $aLanguage[$j][0]) Then
                            IniWrite($sResult, $aSection3[$i][0], $aLanguage[$j][0], $aLanguage[$j][1])
                        EndIf
                    Next
                        _IEQuit($oIE)
                    Next
                        SplashOff()
                        If @error Then
                            msgbox(0,"failed",@error)
                        Else
                        MsgBox($MB_ICONINFORMATION, "SUB Tracker", "Done", 0)
                        EndIf
            EndIf

EndFunc

Func _Terminate()
    Exit
EndFunc

Anyhow, the results is the same, as I said before. It marks me in the Result file ALL the links, not only the links which satisfied the condition.

The example I made before is for the first section (Radio1 - Audrey Hepburn) but didn't work well for any of the other sections.

Edit: And I don't get any error message.

Edited by stefionesco

Share this post


Link to post
Share on other sites

#13 ·  Posted

#include <GuiConstants.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiConstants.au3>
#include <WindowsConstants.au3>
#include <AutoItConstants.au3>
#include <file.au3>
#include <FileConstants.au3>
#include <IE.au3>
#include <MsgBoxConstants.au3>

Local $oIE
Local $sSection1;Audrey Hepburn
Local $sSection2;Sean Connery
Local $sSection3;Rita Hayworth
Local $sLanguage
Local $sResult = ("Result.ini")
Local $aSection1 = IniReadSection('data.ini', 'Section1')
Local $aSection2 = IniReadSection('data.ini', 'Section2')
Local $aSection3 = IniReadSection('data.ini', 'Section3')
Local $aLanguage = IniReadSection('data.ini', 'Language')

Opt("GUIOnEventMode", 1)

Global $mainwindow = GuiCreate("SUB Tracker", 220, 180, 100, 100)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Terminate")

Local $idRadio1 = GUICtrlCreateRadio("Audrey Hepburn", 10, 10, 200, 20)
Local $idRadio2 = GUICtrlCreateRadio("Sean Connery", 10, 40, 200, 20)
Local $idRadio3 = GUICtrlCreateRadio("Rita Hayworth", 10, 70, 200, 20)

Local $searchbutton = GUICtrlCreateButton("SEARCH", 60, 100, 100, 25)
Local $resultbutton = GUICtrlCreateButton("SHOW RESULT", 50, 140, 120, 25)

GUICtrlSetOnEvent($resultbutton, "_Result")
GUICtrlSetOnEvent($searchbutton, "_Search")

GUISetState(@SW_SHOW)

While 1
    Sleep(100)
WEnd

Func _Result()
        ShellExecute ("Result.ini")
EndFunc

Func _Search()

            If GUICtrlRead($idRadio1) = $GUI_CHECKED Then
                SplashTextOn("Searching", "Search...", 600, 50)
                    For $i = 1 To $aSection1[0][0]
                        ControlSetText("Searching", "", "Static1", "Searching the SUB for " & $aSection1[$i][0])
                        $oIE = _IECreate($aSection1[$i][1], 1)
                        _IELoadWait($oIE)
                        $sSection1 = _IEBodyReadText($oIE)
                    For $j = 1 To $aLanguage[0][0]
                        If StringInStr($sSection1, $aLanguage[$j][0]) Then
                            IniWrite($sResult, $aSection1[$i][0], "", $aLanguage[$j][1])
                        EndIf
                    Next
                        _IEQuit($oIE)
                    Next
                        SplashOff()
                        MsgBox($MB_ICONINFORMATION, "SUB Tracker", "Done", 0)
            EndIf

            If GUICtrlRead($idRadio2) = $GUI_CHECKED Then
                SplashTextOn("Searching", "Search...", 600, 50)
                    For $i = 1 To $aSection2[0][0]
                        ControlSetText("Searching", "", "Static1", "Searching the SUB for " & $aSection2[$i][0])
                        $oIE = _IECreate($aSection2[$i][1], 1)
                        _IELoadWait($oIE)
                        $sSection2 = _IEBodyReadText($oIE)
                    For $j = 1 To $aLanguage[0][0]
                        If StringInStr($sSection2, $aLanguage[$j][0]) Then
                            IniWrite($sResult, $aSection2[$i][0], "", $aLanguage[$j][1])
                        EndIf
                    Next
                        _IEQuit($oIE)
                    Next
                        SplashOff()
                        MsgBox($MB_ICONINFORMATION, "SUB Tracker", "Done", 0)
            EndIf

            If GUICtrlRead($idRadio3) = $GUI_CHECKED Then
                SplashTextOn("Searching", "Search...", 600, 50)
                    For $i = 1 To $aSection3[0][0]
                        ControlSetText("Searching", "", "Static1", "Searching the SUB for " & $aSection3[$i][0])
                        $oIE = _IECreate($aSection3[$i][1], 1)
                        _IELoadWait($oIE)
                        $sSection3 = _IEBodyReadText($oIE)
                    For $j = 1 To $aLanguage[0][0]
                        If StringInStr($sSection3, $aLanguage[$j][0]) Then
                            IniWrite($sResult, $aSection3[$i][0], "", $aLanguage[$j][1])
                        EndIf
                    Next
                        _IEQuit($oIE)
                    Next
                        SplashOff()
                        MsgBox($MB_ICONINFORMATION, "SUB Tracker", "Done", 0)
            EndIf

EndFunc

Func _Terminate()
    Exit
EndFunc

I found the error. As Water said:

12 hours ago, water said:

There is absolutely no error

Every link open a page that contain a drop-down menu that contains the word I've search, so the result was always positive. I change with some other word and now work just fine.

Now I'm thinking if it is possible to unify in some way all the "if"s in one unique "If", using something like Radio-X where X=1, or 2, or 3? The same for the Section-X. 

This example I use here have only 3 Radio buttons, but the final script will have about 40 radio buttons and I'm trying to minimize the script. Do you think it's possible?

Thanks.

 

Stef Ionesco

data.ini

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