Jump to content

Ini functions


GEOSoft
 Share

Recommended Posts

I might have gone on thinking that because it worked for me that it was fine.

Not a problem, I think that's probably something we've all done: worked hard at creating a program or function that works perfectly in our isolated environments with varying sets of data/criteria, but as soon as we let it loose in the "wild" something goes haywire. I know it's happened to me (a lot!).

Thanks for the speedy response.

Link to comment
Share on other sites

  • Moderators

"idiot" proof it sometimes... we wouldn't be implying anything now would we? :P

Ha... Not at all actually :) Sorry if it seemed that I was implying that.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

  • 3 months later...

nice work thx for the share

Glad it helps you.

Smoke_N and I discussed merging his and mine together but never quite got around to it. Stay tuned, it might actually happen one of these days.

Edited by GEOSoft

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

  • 2 months later...

Just dragging this old thread up to add another func. This allows you to copy a complete section from an Ini file into another file. I had a need to do that for creating a temporary file which was later deleted.

;===============================================================================
; Function Name:    _INICopySection()
; Description:    Copy a complete section of an Ini file to another file
; Syntax:          _INICopySection("File Path & Name of file to copy from", "File Path & Name of file to copy to", "Section")
; Parameter(s):  
; Requirements:
; Return Value(s):  Copies a complete section from the input file to the output file.
; Author(s):        GEOSoft
;===============================================================================

Func _INICopySection($i_File, $o_File, $i_Section)
   Local $I, $iArray, $oSec = "", $nFile
   $nFile = FileOpen($o_File, 1)
   If @Error Then MsgBox(4096, "Error", "Unable to open the output file")
   $iArray = StringSplit(StringStripCR(FileRead($i_File)), @LF)
   $sSec = _ArraySearch($iArray, $i_Section, 0, 0, 0, True)
   If $sSec = -1 Then
      MsgBox(4096, "Error", "Unable to locate the requested section")
      Return SetError(1)
   EndIf
   $eSec = _ArraySearch($iArray, '[', $sSec +1, 0, 0, True)
   If $eSec <> -1 Then
      $eSec -=1
   Else
      $eSec = Ubound($iArray) -1
   EndIf
   For $I = $sSec To $eSec
      FileWriteLine($nFile, $iArray[$I])
   Next
   FileClose($nFile)
EndFunc ;<==> _INIAddSection($i_File, $i_Section, $i_Sort = 1)

I still want to get around to merging all of Smoke_Ns and Garys INI functions into a single file with mine. Hopefully soon.

In the meantime my functions from this thread are available in a zip file.

Ini.zip

Edited by GEOSoft

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

Hi GEOSoft,

Really good functions... i also work a lot with inis, and i also have few my own functions to handle the ini-structure files... such as _IniSectionExists() (with $sMask/RegExp support), _IniSectioncopy() (with Replace Flag), _IniWrite/ReadEx() (for UTF-8 support), _IniWriteMidle() (write to the certain line in section, or write before/after some text-line), and few more.

If i had more time, same as you, i would like to make a complete Ini_Library, collect all written functions here on the forum, and make some good UDF library... if only i had more free time :D

 

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

Hi GEOSoft,

Really good functions... i also work a lot with inis, and i also have few my own functions to handle the ini-structure files... such as _IniSectionExists() (with $sMask/RegExp support), _IniSectioncopy() (with Replace Flag), _IniWrite/ReadEx() (for UTF-8 support), _IniWriteMidle() (write to the certain line in section, or write before/after some text-line), and few more.

If i had more time, same as you, i would like to make a complete Ini_Library, collect all written functions here on the forum, and make some good UDF library... if only i had more free time :D

Thanks MsCreator. I agree it's something that we have to get done. In the meantime I noticed a mistake in the header of this func So I'll edit the post now

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

Based on a question in the General Help forum I have added a couple of functions to this UDF. Also the code in the first post has been replaced with a file link.

The new functions are _IniCopySection() and IniSortSectionByValue() Which will allow you to sort a section based on the key data values.

I also added sort order to the functions with the default always being ascending (0).

I have not added examples to the zip file yet but I hope to in the next few days.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

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