Jump to content

How to skip INI sections ?


Recommended Posts

How can i skip sections with given section name s ?

Right now i am detecting Level=< or > specified value but some sections should not be detected/removed so i need to skip them.

Those sections do not have Key Level= but still removed for some reason.

for $X = 1 to $Section[0]
        $level = IniRead ($filename,$Section[$X],'Level','Return Error. Nothing found in specified range')
        If $level >= Number ($MinValue) and $level <= Number ($MaxValue) Then
            $removed = IniDelete ($filename,$Section[$X])
Endif

Please help

Link to comment
Share on other sites

YEs here please:

$MinValue = GUICtrlRead ($Min);reads number from input
    $MaxValue = GUICtrlRead ($Max);reads number from input
    for $X = 1 to $Section[0];not sure what that does but it works
        $level = IniRead ($filename,$Section[$X],'Level','Return Error. Nothing found in specified range');Looking for Level which is in specified range
        If $level >= Number ($MinValue) and $level <= Number ($MaxValue) Then;if found level is more then min and less then max then remove section
            $removed = IniDelete ($filename,$Section[$X]);remove section which had level in range
Endif

Problem is that there are 2 or 3 other sections that have no such thing as Level= so they are being removed i am not sure why.

I need to add something that would say If section does not have key Level= then its a bad section and move to next one

Thanks

Link to comment
Share on other sites

Hey man i think i found the answer but i dont understand why it works, can u explain ?

$MinValue = GUICtrlRead ($Min)
    $MaxValue = GUICtrlRead ($Max)
for $X = 1 to $Section[0]
    $level = IniRead ($filename,$Section[$X],'Level','Return Error. Nothing found in specified range')
        
    $badsection = IniRead ($filename,$Section[$X],"Level",'')
If $badsection = @error Then
    SoundPlay (@TempDir & '/searching.mp3')
ElseIf $level >= Number ($MinValue) and $level <= Number ($MaxValue) Then
    $removed = IniDelete ($filename,$Section[$X])
Endif

All i did was added

$badsection = IniRead ($filename,$Section[$X],"Level",'')
If $badsection = @error Then
    SoundPlay (@TempDir & '/searching.mp3')

But not sure why does it jump over those sections that dont have Level= Key in them :D

Confused lol

Link to comment
Share on other sites

You should check the return value from IniRead:

$badsection = IniRead ($filename,$Section[$X],"Level",'error')
If $badsection <> "error" And $level >= Number($MinValue) And $level <= Number($MaxValue) Then IniDelete ($filename,$Section[$X])

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

YEs i did look at that, says it returns 2 dimensional blah blah i dont understand that yet :D

It's not for IniRead or IniReadSectionNames, it's probably for IniReadSection.

So i did what i did ad it works i dont know why but what the hell lol

Well, you just check if IniRead return @error, but @error in this case will equel 0, so it's equivalent to empty string (""). It's the same as checking the default value, that's for the Default parameter in IniRead() is there.

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

Thanks guys i will be looking at it.

Program is released already so i guess i will be working in its features if any will be requested.

Program was posted here

http://www.adrenalineparty.com/UT2004tools.shtml

Its called Clean RPG meant to clean Unreal tournament 2004 RPG users database file withing specified range and remove Bot's and remove empty lines left behind.

Link to comment
Share on other sites

Thanks guys i will be looking at it.

Program is released already so i guess i will be working in its features if any will be requested.

Program was posted here

http://www.adrenalineparty.com/UT2004tools.shtml

Its called Clean RPG meant to clean Unreal tournament 2004 RPG users database file withing specified range and remove Bot's and remove empty lines left behind.

Did you see my reply to your other post? http://www.autoitscript.com/forum/index.ph...st&p=697594
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...