Search the Community
Showing results for tags 'Ini'.
-
INI file [GUI_Settings] GuiXPos=638 GuiYPos=187 GuiWidth=640 GuiHeight=640 GuiTitle=My Custom GUI GuiIcon=C:\Windows\SysWOW64\shell32.dll, 239 GuiFont=12, 400, 0, Comic Sans MS RuningCnt=2 [GUI_Messages] 1=Move and resize the window, then reopen to check if it saves its position 2=Is everything alright? 3=to start again delete the ini file $ini = _Map_GetfromIni($MyIni) $value = $ini.Section.Key $Title = $ini.GUI_Settings.GuiTitle avoid spaces and dots in section names, and keys e.g. if it was 'GUI Settings' $Title = $ini["GUI Settings"].GuiTitle ; https://www.autoitscript.com/forum/topic/212138-maps-getset-from-to-ini-file/?do=findComment&comment=1535856 #NoTrayIcon #include <GUIConstants.au3> #include <WinAPIShellEx.au3> #include <Array.au3> Opt("ExpandVarStrings", 1) ;0=don't expand, 1=do expand Global $MyIni = SetIni(StringTrimRight(@ScriptFullPath, 4) & ".ini") Global $ini = _Map_GetfromIni($MyIni) OnAutoItExitRegister("SaveToExit") _WinAPI_SetCurrentProcessExplicitAppUserModelID(_WinAPI_CreateGUID()) ; ensure a unique ID Global $hGUI = GUICreate($ini.GUI_Settings.GuiTitle _ , $ini.GUI_Settings.GuiWidth _ , $ini.GUI_Settings.GuiHeight _ , $ini.GUI_Settings.GuiXPos _ , $ini.GUI_Settings.GuiYPos _ , BitOR($GUI_SS_DEFAULT_GUI, $WS_SIZEBOX, $WS_THICKFRAME)) ; check for the icon $aIcon = StringSplit($ini.GUI_Settings.GuiIcon, ", ", 1) GUISetIcon($aIcon[1], ($aIcon[0] = 2 ? Int($aIcon[2]) : "")) ; check for the font $aFont = StringSplit($ini.GUI_Settings.GuiFont, ", ", 1) If $aFont[0] = 4 Then GUISetFont($aFont[1], $aFont[2], $aFont[3], $aFont[4]) Global $Label1 = GUICtrlCreateLabel($ini.GUI_Messages[$ini.GUI_Settings.RuningCnt], 10, 15, $ini.GUI_Settings.GuiWidth - 20, 25) GUICtrlSetResizing(-1, $GUI_DOCKHEIGHT) GUISetState(@SW_SHOW) ;more accuracy GUI reposition WinMove($hGUI, "", Default, Default, $ini.GUI_Settings.GuiWidth, $ini.GUI_Settings.GuiHeight) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd ;-------------------------------------------------------------------------------------------------------------------------------- Func SaveToExit() ; save postion by exit Local $aWpos = WinGetPos($hGUI) $ini.GUI_Settings.GuiXPos = $aWpos[0] $ini.GUI_Settings.GuiYPos = $aWpos[1] $ini.GUI_Settings.GuiWidth = $aWpos[2] $ini.GUI_Settings.GuiHeight = $aWpos[3] $ini.GUI_Settings.RuningCnt += 1 _Map_SaveToIni($ini, $MyIni) EndFunc ;==>SaveToExit ;-------------------------------------------------------------------------------------------------------------------------------- Func SetIni($sIniFile) ; Make a ini file if not exist ;Local $sIniFile = FileGetShortName(StringTrimRight(@ScriptFullPath, 4) & ".ini") If Not FileExists($sIniFile) Then Local $mIni[], $mSection[] $mSection.GuiXPos = -1 $mSection.GuiYPos = -1 $mSection.GuiWidth = @DesktopWidth / 3 $mSection.GuiHeight = @DesktopWidth / 3 $mSection.GuiTitle = "My Custom GUI" $mSection.GuiIcon = @SystemDir & "\shell32.dll, 239" $mSection.GuiFont = "12, 400, 0, Comic Sans MS" $mSection.RuningCnt = 1 $mIni["GUI_Settings"] = $mSection ; add Section as GUI_Settings map to ini map Local $mMessage[] $mMessage[1] = "Move and resize the window, then reopen to check if it saves its position" $mMessage[2] = "Is everything alright?" $mMessage[3] = "to start again delete the ini file" $mIni["GUI_Messages"] = $mMessage ; add Section as GUI_Messages map to ini map _Map_SaveToIni($mIni, $sIniFile) Sleep(300) ShellExecute($sIniFile) EndIf Return $sIniFile EndFunc ;==>SetIni ; #FUNCTION# -------------------------------------------------------------------------------------------------------------------- ; Name...........: _Map_GetfromIni ; Description....: Reads an INI file and returns a map of section names to their respective key-value pairs. ; Syntax.........: _Map_GetfromIni($sFilePath) ; Parameters.....: $sFilePath - The path to the INI file to read. ; Return values..: A map of maps where each section is a map of key-value pairs collection. ; Author ........: ioa747 ; Notes .........: $ini = _Map_GetfromIni($sIniPath) ; value = $ini.Section.Key ; Link ..........: ; Dependencies...: ;-------------------------------------------------------------------------------------------------------------------------------- Func _Map_GetfromIni($sFilePath) Local $aSectionName, $Data, $mNewMap[] ;check if FileExists If Not FileExists($sFilePath) Then Return SetError(13, 0, -1) ; an array of all section names in the INI file. $aSectionName = IniReadSectionNames($sFilePath) For $R = 1 To $aSectionName[0] ; Read the INI section $aSectionName[$R]. This will return a 2 dimensional array. Local $aKey = IniReadSection($sFilePath, $aSectionName[$R]) Local $mKey[] ; Check if an error occurred. If Not @error Then ; Enumerate through the array displaying the keys and their respective values. For $i = 1 To $aKey[0][0] ;ConsoleWrite($i & ") " & $aKey[$i][0] & ":" & $aKey[$i][1] & @CRLF) $mKey[$aKey[$i][0]] = $aKey[$i][1] Next EndIf $mNewMap[$aSectionName[$R]] = $mKey Next Return $mNewMap EndFunc ;==>_Map_GetfromIni ;-------------------------------------------------------------------------------------------------------------------------------- Func _Map_SaveToIni(ByRef $mMap, $sFilePath) Local $aSectionName, $mKey, $aKey, $Data $aSectionName = MapKeys($mMap) $mKey = $mMap[$aSectionName[0]] $aKey = MapKeys($mKey) For $R = 0 To UBound($aSectionName) - 1 $mKey = $mMap[$aSectionName[$R]] $aKey = MapKeys($mKey) Local $iRowsCnt = UBound($aKey) Local $aSection[$iRowsCnt + 1][2] $aSection[0][0] = $iRowsCnt For $i = 0 To $iRowsCnt - 1 $Data = $mKey[$aKey[$i]] ;ConsoleWrite($i & ") " & $aKey[$i] & ":" & $Data & @CRLF) $aSection[$i + 1][0] = $aKey[$i] $aSection[$i + 1][1] = $Data Next ; Write the array to the section labelled $aSectionName[$R]. IniWriteSection($sFilePath, $aSectionName[$R], $aSection) Next ;_ArrayDisplay($aSection, "$aSection") EndFunc ;==>_Map_SaveToIni ;----------------------------------------------------------------------------------------
-
AU3Text.au3 v1.0 An extensive UDF to ease the internationalization of AutoIt scripts and programs. Add multi-lingual support to your scripts and programs in a consistent and portable manner. Main features: Store messages in a human-readable INI format.Organize messages in different categories.Handle singular and plural string variants at run time.Expands meta-characters and all AutoIt macro's.Supports UTF-16 Little-Endian encoding.GUI Menu and Combo Create/Read helper functions.Command line utility to extract messages from AutoIt scripts.Fully portable!The download contains the following files:ReadMe.txt Instructions and information on the UDF. AU3Text-HowTo.txt Step by step instructions to convert programs for internationalization with AutoIt. AU3Text-Demo.au3 AU3Text demo. AU3Text-Extractor.au3 Source file for command line utility to extract AU3Text messages from scripts. You'll need to compile this script before you can use it. This is BETA software! LibAU3Text.au3 Main AU3Text library. LibAU3TextGUI.au3 AU3Text GUI helpers. LibAU3TextDev.au3 Additional developer functions. LibLocale.au3 Locale functions. Originally based on guinness' excellent _GetOSLanguage function, but has grown into a full stand-alone UDF. LibIni.au3 UTF-16 LE INI functions. LibStringFormatEx.au3 Modified StringFormat function. See http://www.autoitscript.com/forum/topic/139260-autoit-snippets/page__st__60#entry1010824 I18nAU3Text-Demo.en.lng English demo language file. I18nAU3Text-Demo.nl.lng Dutch demo language file. I18nAU3Text-Translation-HowTo.txt Basic translation instructions. ResAU3Text-Extractor.ico Pic unrelated :)A simple example of translating a string: #include 'LibAU3Text.au3' _AU3Text_BindTextSection('MESSAGES', 'nl') ; Set translations to dutch. ; ... Create a GUI. ; Translate a string: GUICtrlCreateLabel(_AU3Text('The flying dutchman flies again.', 'FLYING_DUTCHMAN'), -1, -1) ; De vliegende hollander vliegt alweer. ; Translate a string with plural variants: GUICtrlCreateLabel(StringFormat(_AU3Text_Plural('Deleted %i file.', 2, 'DELETED_FILES'), 2), -1, -1) ; 2 bestanden verwijdert. ; Using shorthand functions: GUICtrlCreateLabel(_('The flying dutchman flies again.', 'FLYING_DUTCHMAN'), -1, -1) GUICtrlCreateLabel(StringFormat(_P('Deleted %i file.', 2, 'DELETED_FILES'), 2), -1, -1) ; Let AU3Text generate the INI keys, keys are MD5 hashes of the messages. GUICtrlCreateLabel(_('The flying dutchman flies again.'), -1, -1) GUICtrlCreateLabel(StringFormat(_P('Deleted %i file.', 2), 2), -1, -1) ; ...The UDF: AU3Text.zip If you encounter any bugs or have any suggestions, requests or improvements, then please let me know. Happy coding! edit 1: zip added edit 2: If you compiled AU3Text-Extractor and want to test it, run it against AU3Text-Demo like this: AU3Text-Extractor.exe Au3Text-Demo.au3 beThis will create AU3Text-Demo.be.lng in the I18n directory.
- 14 replies
-
- internationalization
- i18n
-
(and 6 more)
Tagged with:
-
good morning sirs. please i have a request from you. i have an variable to Read a data from a file this data is Encrypted and when i read it i Decrypte it. for that i need a function to Write a ini data to string. ;#Function# ===================================================================================================================== ; Name............: _IniReadFromString ; Description.....: Returns the value of a key in a specific section of an ini-formatted string ; Syntax..........: _IniReadFromString($szInput, $szSection, $szKey, $Default) ; Parameters......: ; $szInput - The string that contains data in ini format ; $szSection - The sectionname (just as in IniRead) ; $szKey - The keyname (just as in IniRead) ; $Default - The default value if the key does not exist or reading failed (just as in IniRead) ; Return values ..: ; Success - Returns the read value ; Failure - Returns $Default ; Author .........: FichteFoll ; Remarks ........: Works for Unicode as well as for ANSI ; Related ........: IniRead, _IniReadSectionFromString ; Link ...........; See on top ; Example ........; $var = _IniReadFromString(StringFormat("[Sect]\r\nMyKey1=value1\r\nMyKey2=value2"), "Sect", "MyKey2", "no_value") ; =============================================================================================================================== Func _IniReadFromString($szInput, $szSection, $szKey, $Default) $szInput = StringStripCR($szInput) ;~ Local $aRegMl = StringRegExp($szInput, "\[" & __StringEscapeRegExp($szSection) & "\]\n+(?:[^\[].*?=.*\n)*" & __StringEscapeRegExp($szKey) & "=(.*)\n?(",3) Local $aRegMl = StringRegExp($szInput, "\[" & __StringEscapeRegExp($szSection) & "\]\n+(?:[^\[].*?=.*\n)*" & __StringEscapeRegExp($szKey) & "=(.*)\n?", 3) If @error Then Return SetError(1, 0, $Default) ; key not found Return $aRegMl[0] EndFunc;==>_IniReadFromString ; ############################################################################################################################### ; =============================================== ; = Internal Use Only ; =============================================== Func __StringEscapeRegExp($szExp) Return StringRegExpReplace($szExp, "([\(\)\[\]\{\}\\\/\?\.\\|\+])", "\\$1") ; ()[]{}\/?.|+ EndFunc;==>__StringEscapeRegExp like this function Read the ini from string. please ihelp me thanks in advance
-
hello sirs, i have searched allot about an function that can read the INI file as a string i mean function to read the ini files from string and not from the file directly. i finally found an UDF that do what i want but unfortunately all the functions work, but the function that i want it not working. this is the udf the function that i need is _IniReadFromString this is the function Func _IniReadFromString($szInput, $szSection, $szKey, $Default) $szInput = StringStripCR($szInput) Local $aRegMl = StringRegExp($szInput, "\[" & __StringEscapeRegExp($szSection) & "\]\n+(?:[^\[].*?=.*\n)*" & __StringEscapeRegExp($szKey) & "=(.*)\n?(", 3) If @error Then Return SetError(1, 0, $Default) ; key not found Return $aRegMl[0] EndFunc;==>_IniReadFromString i hope that any one can help me thank you in advance iniex.au3
-
hi dears am using an ini files as a History Sometimes the file size is be larger to 5 MB AutoIt does not recognize the full content of the file When I did a search to find out why, I discovered that INI files could not be read if they size larger than 64 KB. for that I preferred to ask here if is there any way to bypass this obstacle. The contents of the file are as follows [filesList] c:\...\...\f1.mp3=00:15:20 c:\...\...\f2.mp3=00:10:20 c:\...\...\f3.wav=00:59:20 ....... Etc This is the section for reading the file (adapted from my main script) case $continue Local $aArray = IniReadSection($WaitingListFile, StringEncrypt(true, "filesList", $MyPassword)) If Not @error Then Opt("GUICloseOnESC", 1) _GUICtrlListView_DeleteAllItems($scList) For $i = 1 To $aArray[0][0] $path = path_list(StringEncrypt(false, $aArray[$i][0], $MyPassWord), 1) if FileExists(StringEncrypt(false, $aArray[$i][0], $MyPassWord)) then GUICtrlCreateListViewItem(_GetFileName(FileGetLongName(StringEncrypt(false, $aArray[$i][0], $MyPassWord))) & Opt("GUIDataSeparatorChar") & " : " & Opt("GUIDataSeparatorChar") & FileGetLongName(StringEncrypt(false, $aArray[$i][0], $MyPassWord)), $scList) else $path = $path endIf Next GUISetState(@sw_disable, $hGUI) GUISetState(@sw_show, $hGUI2) GUICtrlSetState($SClist, $GUI_FOCUS) else if $accessibilitymode = 1 then speak(str("listEmpty")) endIf endIf Is there any way to solve this problem, please? am waiting your answers... Greetings to All
-
Hi, i'm just curious is there a way to sort an ini file after largest first? my inifiles writes itself like this 14=500 13=GREY 12=500 11=600 10=600 9=600 8=700 7=700 5=600 3=600 2=800 1=700 15=GREY 4=GREY but is there a way so i can get it sortet 15 14 13 12 etc?
-
Hi, i'm curious if this is even possible, i want to do an action if the ini file contains current values under a section. for my test i'm looking for 100,200,300,400,500 and if any of those excits i want to pop a msgbox with the number in the section. i can in my example find one, but it does not check everyone. why? what am i missing? Local $iscore810[5] = [100,200,300,400,500] Local $iMax800 = 5 While 1 ;~ Send("{pause}") ;;func les ini fil $var = IniReadSection("Area.ini", "modus") If @error Then MsgBox(4096, "Error", "Unable to read section.") Else For $number = 1 To $var[0][0] If $var[$number][1] == $iscore810[3] Then MsgBox($MB_SYSTEMMODAL, "FAnt den på", $var[$number][0], 5) EndIf Next EndIf exit WEnd
-
2 Action Button, Single Click vs Double Click
Pike posted a topic in AutoIt General Help and Support
Hello Everyone, New Guy here. This is a two-part question, hopefully easy enough though. I know it's ugly coding, this is because I have only a couple hours worth of coding experience and could really use some help. 1) When I single click the button I want one action (like playing a sound clip) and when I double click the button I want a different action (such as opening dialogue box to ask for soundclip directory address). At the bottom of the script I made a comment which one I would like single click versus double click. 2) I can not get the FileOpenDialogue to save the file address to the config.ini file at the 'One' position on the .ini. #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <MsgBoxConstants.au3> #include <FileConstants.au3> #include <AutoItConstants.au3> #include <Sound.au3> Opt('MustDeclareVars', 1) Opt("GUIOnEventMode", 1) Global $OneID _Main() Func _Main() GUICreate("Form1", 156, 86, 281, 276) $OneID = GUICtrlCreateButton("Button", 15, 17, 122, 37) GUICtrlSetOnEvent($OneID, "OnOne") GUISetOnEvent($GUI_EVENT_CLOSE, "OnExit") GUISetState() While 1 While 1 Sleep(1000) WEnd WEnd EndFunc ;---------------Functions------------- While 1 Sleep(100) WEnd Func OnOne() ; ******************Single Click for this action**************** $OneID = IniRead("config.ini", "Config", "One", $OneID) If $OneID = True Then SoundPlay($OneID, @HotKeyPressed) Else ; *******Double Click for this action*****And Help Saving File Address to config.ini 'One'*********** $OneID = FileOpenDialog("Select file", @WorkingDir, "All (*.*)") IniWrite("config.ini", "Config", "One", $OneID) $OneID = InputBox("Enter Information", "Short Name for File?", "") IniWrite("config.ini", "Config", "NameOne", $OneID) EndIf EndFunc Any help would be greatly appreciated, and if you need anymore clarity as to what exactly I'm trying to do, please do not hesitate to ask. Thanks so much! Pike -
Hi, i would like to know if there is a possible way to use subsections for ini files? For example, my ini file would look something like this: Clientname.ini [Info] Country=USA Type=Distributor [Costs] [[JAN]] <----- subsection cost1=---- cost2=---- [[FEB]] cost1=---- cost2=---- [Sales] [[JAN]] <----- subsection sale1=---- sale2=---- [[FEB]] sale1=---- sale2=---- [Profits] [[JAN]] <----- subsection prof1=---- prof2=---- [[FEB]] prof1=---- prof2=---- The sales would be inputed everyday by the script, and then whenever viewed, i would be using an array to view every sale/cost/profit under the subsection Thanks for your time!
- 3 replies
-
- ini
- subsection
-
(and 3 more)
Tagged with:
-
Hello, all.. My AutoIT is pretty terrible - but I get by with trawling here I came across an issue where i had to parse a large key in a large ini file, and found that I was victim of inireadsection's limit of "Only the first 32767 chars are read for legacy reasons." I've attempted to put together some terrible code that parses an ini section. It's absolutely nowhere near good, but I figured I'd put it here so that folk who know what they're doing can laugh at improve it. $Ini = @ScriptDir & "\bigini.ini" Dim $IniArray[0][2] $KeyName = "Person" $R = FileOpen($Ini, 0) $IniStr = FileRead($R) FileClose($R) $Start = StringInStr($iniStr, "[" & $KeyName & "]") If $Start = 0 then Msgbox(16, "Error", "String not found") Exit EndIf $Stop = StringInStr($IniStr, @CRLF & "[", 0, 1, ($Start + 1)) If $Stop = 0 then $Stop = StringLen($IniStr) EndIf $String = StringMid($IniStr, $Start, ($Stop - $Start)) $Split = StringSplit($String, @CRLF, 1) $KeyCount = 0 Dim $IniArray[65535][2] For $Loop = 1 to $Split[0] $Add = "Y" $Str = $Split[$Loop] $EQBreak = StringInStr($Str, "=") Select Case StringMid($Str, 1, 1) = ";" $Add = "N" Case $EQBreak = 0 $Add = "N" Case Else $Add = "Y" EndSelect If $Add = "Y" then $KeyCount = $KeyCount + 1 $Key = StringMid($Str, 1, ($EQBreak - 1)) $Val = StringMid($Str, ($EQBreak + 1)) $IniArray[$KeyCount][0] = $Key $IniArray[$KeyCount][1] = $Val EndIf Next Redim $IniArray[$KeyCount +1][2] ; Add the number of hits to 00 to match inireadsection $IniArray[0][0] = $KeyCount _ArrayDisplay($IniArray) ; Do stuff with the Array like you would inireadsection
-
Afternoon, I could very well be doing this wrong so feel free to totally advise otherwise - I'm wanting to use a GUI to first display a key from within an INI file, then secondly change the INI file by using a FileSelectFolder command but then I want to see the GUI change to reflect the change I've just made. #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 615, 437, 192, 124) $Input1 = GUICtrlCreateInput(Iniread(@WorkingDir & "\test.ini","Path","FilePath",""), 64, 80, 121, 21) $Button1 = GUICtrlCreateButton("Change", 200, 80, 75, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 $selectedFolder = FileSelectFolder("Select Log Path Directory",@WorkingDir,0) If NOT $selectedFolder = "" Then $newLogPath = IniWrite(@WorkingDir & "\test.ini","Path","FilePath",$selectedFolder) EndIf EndSwitch WEnd So 2 part question really: (1) Should I be using GUICtrlCreateInput to display my INI read from within the GUI? (2) How can I refresh the GUI to update that to read the new information I've just written to the GUI? Thanks!
-
I've made a program that relies on IniReadSectionNames. It reads (~3K) Autorun.inf files in the working folder and creates a GUI based on their contents. I made sure to revert to a default GUI upon @error. But someone (with Windows XP SP3 32-bit) reported to me he always gets the default menu. I sent him a FileRead command instead and it works! So seemingly there's no access problem to AutoRun.inf. In the following demo code, I always hit success, but he always ends up with semi-success: Local $hIniLocation = "Autorun.inf" Local $aSections = IniReadSectionNames($hIniLocation) If @error Then $aSections = FileRead($hIniLocation) if @error then msgbox(48, "Double error", "Alternative access failed too due to:" & @crlf & @error & @crlf & @extended) else msgbox(0, "Semi-success", "IniReadSectionNames failed, but alternativaly this file contains:" & @crlf & @crlf & $aSections) endif else msgbox(0, "Success", "IniReadSectionNames worked!") endif Why is that? Is there something further to check with him? Autorun.inf
-
Good morning community! I was working on a script which read the content of a .ini file to retrieve the file that has to open, and, based on the value of a second key stored in the .ini file, set the window on top, minimized or maximized... I did something like this, but seems to not work properly... Could anyone please tell me what I'm doing wrong? Thank you #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Outfile_x64=prova.exe #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <MsgBoxConstants.au3> #include <AutoItConstants.au3> ;#include <WinAPIEx.au3> #include <Array.au3> Local $sFileConfigurazione = @ScriptDir & "\configurazione_exe.ini" If(FileExists($sFileConfigurazione)) Then Local $aSezioneIni = IniReadSection($sFileConfigurazione, "CONFIGURAZIONE_EXE") If @error Then MsgBox($MB_ICONERROR, "Errore!", "Errore durante l'apertura del file: " & @CRLF & $sFileConfigurazione & @CRLF & "Errore: " & @error) Else ; Lancio dell'applicativo indicato nel file di configurazione Local $iPID = ShellExecute($aSezioneIni[1][1]) Local $hWnd If($iPID <> 0) Then Local $aWinList = WinList() For $i = 1 To $aWinList[0][0] If(WinGetProcess($aWinList[$i][1] = $iPID)) Then $hWnd = $aWinList[$i][1] EndIf Next Switch($aSezioneIni[2][1]) Case $aSezioneIni[2][1] = "MIN" ToolTip("MIN", 0, 0) WinSetState($hWnd, WinGetTitle($hWnd), @SW_MINIMIZE) Case $aSezioneIni[2][1] = "MAX" ToolTip("MAX", 0, 0) WinSetState($hWnd, WinGetTitle($hWnd), @SW_MAXIMIZE) Case $aSezioneIni[2][1] = "TOP" ToolTip("TOP", 0, 0) WinSetOnTop($hWnd, WinGetTitle($hWnd), $WINDOWS_ONTOP) EndSwitch EndIf EndIf EndIf And the .ini file is like this: [CONFIGURAZIONE_EXE] PercorsoExe=Here goes the path and the .exe to execute ModalitaAperturaExe=Here goes one of the value below /* TOP Shows the windows on top */ /* MIN Shows the window minimized */ /* MAX Shows the window maximized */
-
Hi, I am trying to create a list view wich shows the content of an ini file. There is a pulldown menu wich allows me to check a certain status in the ini file if the status is found it should read out the key and in every section the same key is located after that it should fill out the listview with all results found. $OVERZICHTGUI = GUICreate("RMA Overzicht", 1235, 742, -1, -1) GUICtrlCreateLabel("Ingelogd als: " & $NAAMMEDEWERKER, 8, 0) GUICtrlSetState(-1, $GUI_DISABLE) GUICtrlCreateGroup("", 8, 16, 185, 89) GUICtrlCreateLabel("Status:", 32, 40, 37, 17) $STATUS = GUICtrlCreateCombo("", 32, 64, 140, 25,BitOR($CBS_DROPDOWNLIST, $WS_VSCROLL)) GUICtrlSetData($STATUS, "Aangevraagd|Verzonden|Afgehandeld", "") GUICtrlCreateGroup("", -99, -99, 1, 1) $View = GUICtrlCreateListView("RMANR|RMANRLEV|DEBITNR|KLANT|STATUS|MODEL|SERIENR|AANGEMELDDOOR|AANMELDDATUM|VERZENDDATUM|RETOURDATUM|KLACHT|OPLOSSING", 8, 120, 1218, 614) $Exit = GUICtrlCreateButton("Hoofdmenu", 1104, 8, 123, 33) GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $EXIT $YesOrNo = msgBox(4,"","Terug naar het hoofdmenu?") If $YesOrNo = 6 then GUIDelete($OVERZICHTGUI) MAINMENU() ExitLoop EndIf Case $STATUS $GO = 1 $STATE = GUICtrlRead($STATUS) Local $aArray = IniReadSection(@ScriptDir & "\DB\rma.ini", "STATUS") _ArrayDisplay($aArray, "Gevonden") $FOUNDRMANR = _ArraySearch($aArray, $STATE) MsgBox(4096, "", $FOUNDRMANR) If $FOUNDRMANR = -1 Then MsgBox(4096, "Not Found", "No RMA requests with this status found.") $GO = 0 EndIf If $GO = 1 Then $VAR = IniRead(@ScriptDir & "\DB\rma.ini", "RMANR", $FOUNDRMANR, "Not found") MsgBox(4096, "", $VAR) EndIf EndSwitch WEnd rma-forum.ini
-
Hi, i a stuck with a hopefully a little problem. I know the value of a not yet known key in an ini file. I need to be able to find the key using the value. The value is a unique value in a section. Hope you guys can help me.
-
IniEx.au3 (INI File Processing Functions) solve many problems, such as the limits of AutoIt Default INI function, and add many other options, since all function work by reference so IniEx.au3 also use less memory, and provide a really good performance in speed #include-Once ; #INDEX# ======================================================================================================================= ; Title .........: IniEx ; AutoIt Version : v3.3.9.22++ ; Language ......: English ; Description ...: INI File Processing Functions ; Author(s) .....: DXRW4E ; =============================================================================================================================== ; #CURRENT# ===================================================================================================================== ;_IniClearCache() ;_IniCloseFileEx() ;_IniDeleteEx() ;_IniFileWriteEx() ;_IniGetFileInformationEx() ;_IniGetFileStringData() ;_IniGetSectionNumberEx() ;_IniOpenFileEx() ;_IniOpenFile() ;_IniReadEx() ;_IniReadSectionEx() ;_IniReadSectionNamesEx() ;_IniRenameSectionEx() ;_IniWriteEx() ;_IniWriteSectionEx() ; =============================================================================================================================== ; #INTERNAL_USE_ONLY# =========================================================================================================== ;__GetSeparatorCharacter() ;__IniFileWriteEx() ;__IniGetFileStringData() ;__IniReadSectionEx() ;__IniSaveCache() ;__IniWriteSectionEx() ; =============================================================================================================================== ; #CONSTANTS# =================================================================================================================== Global Const $INI_STRIPLEADING = 1 ; $STR_STRIPLEADING - strip leading white space Global Const $INI_STRIPTRAILING = 2 ; $STR_STRIPTRAILING - strip trailing white space Global Const $INI_STRIPLEADTRAILING = 3 ; BitOR($STR_STRIPLEADING, $STR_STRIPTRAILING) Global Const $INI_ARRAYDATA = 4 Global Const $INI_ARRAYDATA_NOCOUNT = 8 Global Const $INI_NOWRITEREADONLY = 16 Global Const $INI_FO_UNICODE = 32 ; $FO_UNICODE Global Const $INI_FO_UTF16_LE = 32 ; $FO_UTF16_LE Global Const $INI_FO_UTF16_BE = 64 ; $FO_UTF16_BE Global Const $INI_FO_UTF8 = 128 ; $FO_UTF8 Global Const $INI_FO_UTF8_NOBOM = 256 ; $FO_UTF8_NOBOM Global Const $INI_NOOCCURRENCE = 512 Global Const $INI_MERGE = 1024 Global Const $INI_NOCREATE = 2048 Global Const $INI_APPENDDATA = 4096 Global Const $INI_REPLACEONLY = 8192 Global Const $INI_FO_UTF8_FULL = 16384 ; $FO_UTF8_FULL Global Const $INI_NOOVERWRITE = 32768 Global Const $INI_OVERWRITEALL = 65536 Global Const $INI_IGNOREDUPLICATE = 131072 Global Const $INI_DELETE = 262144 Global Const $INI_RENAME = 524288 Global Const $INI_REMOVE = 1048576 ;Global Const $INI_RESERVED* = 2097152 ;Global Const $INI_RESERVED* = 4194304 ;Global Const $INI_RESERVED* = 8388608 Global Const $INI_OPEN_EXISTING = 16777216 Global Const $INI_CREATEPATH = 33554432 Global Const $INI_REPAIR_ERROR = 67108864 Global Const $INI_DISCARDCHANGES = 134217728 Global Const $INI_OPEN_FILEQUEUE = 268435456 ;Global Const $INI_RESERVED* = 536870912 Global Const $INI_2DARRAYFIELD = 1073741824 ;;;; THESE ARE SPECIAL FLAGS, ARE USED INTERNALLY ONLY ;;;; Global Const $INI_INTERNAL_USE_ONLY = 2147483648 Global Const $INI_FO_STYLE = BitOR(31, $INI_OPEN_EXISTING, $INI_CREATEPATH, $INI_REPAIR_ERROR, $INI_OPEN_FILEQUEUE) Global Const $INI_MERGE_NOOCCURRENCE = BitOR($INI_MERGE, $INI_NOOCCURRENCE) Global Const $INI_REMOVE_RENAME = BitOR($INI_REMOVE, $INI_RENAME) Global Const $INI_REMOVE_DELETE = BitOR($INI_REMOVE, $INI_DELETE) Global Const $INI_NOCREATE_REMOVE_DELETE = BitOR($INI_NOCREATE, $INI_REMOVE, $INI_DELETE) Global Const $INI_NOOCCURRENCE_IGNOREDUPLICATE = BitOr($INI_NOOCCURRENCE, $INI_IGNOREDUPLICATE) Global Const $INI_OVERWRITEALL_APPENDDATA = BitOR($INI_OVERWRITEALL, $INI_APPENDDATA) Global Const $NULL_REF = Null Global Const $sINI_OPENFILE_EX = @LF & "[]" & @LF ;;;; DO NOT EVER USE\CHANGE\EDIT THESE VARIABLES ;;;; ;;;; THESE VARIABLES ARE USED INTERNALLY ONLY ;;;; Global Static $INI_NULL_REF = Null Global Static $_HINI[11][11] = [[10, 0]] ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; =============================================================================================================================== ; #FUNCTION# ==================================================================================================================== ; Name...........: _IniOpenFileEx ; Description ...: The _IniOpenFileEx function opens an INI file and returns a handle to it. ; Syntax.........: _IniOpenFileEx($sFilePath[, $iFlags]]) ; Parameters ....: $sFilePath - INI File Path ; $iFlags - Optional, (add the flags together for multiple operations): ; This Flags will be ignored if the $INI_CREATEPATH is not set\used ; | A file may fail to open due to access rights or attributes. ; | The default mode when writing text is ANSI - use the unicode flags to change this. When writing unicode files ; | the Windows default mode (and the fastest in AutoIt due to the least conversion) is UTF16 Little Endian (mode 32). ; | $INI_FO_* Flags will be ignored if the $INI_CREATEPATH is not Set\Used ; |$INI_FO_UNICODE or $INI_UTF16_LE (32) - Use Unicode UTF16 Little Endian reading and writing mode. Reading does not override existing BOM. ; |$INI_FO_UTF16_BE (64) - Use Unicode UTF16 Big Endian reading and writing mode. Reading does not override existing BOM. ; |$INI_FO_UTF8 (128) - Use Unicode UTF8 (with BOM) reading and writing mode. Reading does not override existing BOM. ; |$INI_FO_UTF8_NOBOM (256) - Use Unicode UTF8 (without BOM) reading and writing mode. ; |$INI_FO_UTF8_FULL (16384) - When opening for reading and no BOM is present, use full file UTF8 detection. If this is not used then only the initial part of the file is checked for UTF8. ; ;;;;;;;;;;;; ; |$INI_OPEN_EXISTING (16777216) - If the INI File (Path) is Already Open use that (Handle) (Default Always Opens a New) ; |$INI_CREATEPATH (33554432) - Create INI File if does not exist (Default if file not exist Return Error) ; |$INI_REPAIR_ERROR (67108864) - If exist Error when Opening the INI File Repair Error, example as this line (@CRLF & [SectionName & @CRLF) repair in (@CRLF & [SectionName] & @CRLF), Default Return Error ; |$INI_OPEN_FILEQUEUE (268435456) - Open INI file from Memory\Variable, $sFilePath must contain String Text Data of INI file ; Return values .: Success - INI Handle ; Failure - Returns 0 or String\Text of error line (check @Extended for error line number) ; @Error - 0 = No error. ; |1 = File cannot be opened or found. ; |2 = Error when Opening the INI File ; Remarks .......: ; Author ........: DXRW4E ; =============================================================================================================================== Func _IniOpenFileEx($sFilePath, $iFlags = 0) If BitAND($iFlags, $INI_OPEN_EXISTING) Then For $i = 1 To $_HINI[0][0] If $_HINI[$i][2] = $sFilePath Then Return SetError(0, $i, $i) Next EndIf Local $sCS, $_sCS = "\r", $hFilePath, $iFileEncoding, $aFileData, $aErrorLine, $iFO_Style = BitXOR(BitOR($iFlags, $INI_FO_STYLE), $INI_FO_STYLE) If BitAND($iFlags, $INI_OPEN_FILEQUEUE) Then $aFileData = StringRegExpReplace($sINI_OPENFILE_EX & $sFilePath, '\r(?!\n)', @CRLF) ;;;;, '(?<!\r)\n', @CRLF) $sFilePath = "FileQueue" $iFileEncoding = $iFO_Style ;;(StringIsASCII($aFileData) ? 0 : 32) Else $hFilePath = FileOpen($sFilePath) If $hFilePath = -1 Then If Not FileExists($sFilePath) Then If Not BitAND($iFlags, $INI_CREATEPATH) Then Return SetError(1, 0, 0) $iFO_Style += 10 ;;$iFO_Style = 42 EndIf $hFilePath = FileOpen($sFilePath, $iFO_Style) If $hFilePath = -1 Then Return SetError(1, 0, 0) EndIf $aFileData = StringRegExpReplace($sINI_OPENFILE_EX & FileRead($hFilePath), '\r(?!\n)', @CRLF) ;;;;, '(?<!\r)\n', @CRLF) $iFileEncoding = FileGetEncoding($hFilePath) FileClose($hFilePath) EndIf $aErrorLine = StringRegExp($aFileData, '\n\K[\h\f\xb\x0]*\[[^\]\n]*(?:\n|$)', 1) If Not @Error Then Local $iErrorLine = @Extended - (StringLen($aErrorLine[0]) - 1) If Not BitAND($iFlags, $INI_REPAIR_ERROR) Then Return SetError(2, StringSplit(StringLeft($aFileData, $iErrorLine), @LF)[0] - 2, $aErrorLine[0]) $aFileData = StringRegExpReplace($aFileData, '(\n[\h\f\xb\x0]*\[[^\]\r\n]*)(?=[\r\n]|$)', "$1]") EndIf $sCS = __GetSeparatorCharacter($aFileData) If $sCS = @CR Then $_sCS = "" $aFileData = StringRegExpReplace($aFileData & @CRLF & "[", "\n\K(?>[" & $_sCS & "\n\h\f\xb\x0]*\n|\x0*)(?=[\h\f\xb\x0]*\[)", $sCS & "${0}" & $sCS) $aFileData = StringRegExp($aFileData & $sCS, $sCS & "([\h\f\xb\x0]*\[)([^\]\n]*)(\][^\n]*\n)((?>[" & $_sCS & "\n\h\f\xb\x0]*\n)*)([^" & $sCS & "]*)" & $sCS & "([^" & $sCS & "]*)", 3) $aFileData[0] = UBound($aFileData) - 1 If $aFileData[0] < 5 Then Return SetError(1, 0, 0) ; should not happen ever $aFileData[$aFileData[0]] = StringTrimRight($aFileData[$aFileData[0]], 2) For $iHINI = 1 To $_HINI[0][0] If Not $_HINI[$iHINI][0] Then ExitLoop Next If $iHINI > $_HINI[0][0] Then ReDim $_HINI[$iHINI + $iHINI][11] $_HINI[0][0] = $iHINI + $iHINI - 1 EndIf $aFileData[2] = $iHINI If Not $_sCS Then $aFileData[3] = StringAddCR($aFileData[3]) $aFileData[4] = StringAddCR($aFileData[4]) $aFileData[5] = StringAddCR($aFileData[5]) EndIf For $i = 7 To $aFileData[0] Step 6 $_HINI[$iHINI][5] &= @LF & $aFileData[$i] & @CR & $i If Not $_sCS Then $aFileData[$i + 1] = StringAddCR($aFileData[$i + 1]) $aFileData[$i + 2] = StringAddCR($aFileData[$i + 2]) $aFileData[$i + 3] = StringAddCR($aFileData[$i + 3]) $aFileData[$i + 4] = StringAddCR($aFileData[$i + 4]) EndIf Next $_HINI[0][1] += 1 ;;($_HINI[0][1] < 1) ? 1 : $_HINI[0][1] + 1 $_HINI[$iHINI][0] = $iHINI $_HINI[$iHINI][1] = $aFileData $_HINI[$iHINI][2] = $sFilePath $_HINI[$iHINI][3] = $iFileEncoding $_HINI[$iHINI][4] = ($aFileData[0] - 5) / 6 $_HINI[$iHINI][5] = StringReplace($_HINI[$iHINI][5], "\E", "\e", 0, 1) $_HINI[$iHINI][7] = Null Return $iHINI EndFunc ;==>_IniOpenFileEx ; #FUNCTION# ==================================================================================================================== ; Name...........: _IniOpenFile ; Description ...: The _IniOpenFile function opens an INI file and returns a handle to it. ; Parameters ....: the same as the _IniOpenFileEx(), See _IniOpenFileEx() ; Return values .: See _IniOpenFileEx() ; Author ........: DXRW4E ; Modified.......: ; Remarks .......: _IniOpenFile() is the same as the _IniOpenFileEx(), only that _IniOpenFile() force the check\repair of @CR or @LF in @CRLF ; performance\speed does not change much with _IniOpenFileEx(), _IniOpenFile() can only be about 1% or 5% or10% slower ; =============================================================================================================================== Func _IniOpenFile($sFilePath, $iFlags = 0) If BitAND($iFlags, $INI_OPEN_EXISTING) Then For $i = 1 To $_HINI[0][0] If $_HINI[$i][2] = $sFilePath Then Return SetError(0, $i, $i) Next EndIf Local $hFilePath, $iFileEncoding, $aFileData, $aErrorLine, $iFO_Style = BitXOR(BitOR($iFlags, $INI_FO_STYLE), $INI_FO_STYLE) If BitAND($iFlags, $INI_OPEN_FILEQUEUE) Then $aFileData = StringRegExpReplace($sINI_OPENFILE_EX & $sFilePath, '\r\n?', @LF) $sFilePath = "FileQueue" $iFileEncoding = $iFO_Style ;;(StringIsASCII($aFileData) ? 0 : 32) Else $hFilePath = FileOpen($sFilePath) If $hFilePath = -1 Then If Not FileExists($sFilePath) Then If Not BitAND($iFlags, $INI_CREATEPATH) Then Return SetError(1, 0, 0) $iFO_Style += 10 ;;$iFO_Style = 42 EndIf $hFilePath = FileOpen($sFilePath, $iFO_Style) If $hFilePath = -1 Then Return SetError(1, 0, 0) EndIf $aFileData = StringRegExpReplace($sINI_OPENFILE_EX & FileRead($hFilePath), '\r\n?', @LF) $iFileEncoding = FileGetEncoding($hFilePath) FileClose($hFilePath) EndIf $aErrorLine = StringRegExp($aFileData, '\n\K[\h\f\xb\x0]*\[[^\]\n]*(?:\n|$)', 1) If Not @Error Then Local $iErrorLine = @Extended - (StringLen($aErrorLine[0]) - 1) If Not BitAND($iFlags, $INI_REPAIR_ERROR) Then Return SetError(2, StringSplit(StringLeft($aFileData, $iErrorLine), @LF)[0] - 2, $aErrorLine[0]) $aFileData = StringRegExpReplace($aFileData, '(\n[\h\f\xb\x0]*\[[^\]\n]*)(?=\n|$)', "$1]") EndIf $aFileData = StringRegExpReplace($aFileData & @LF & "[", '\n\K(?>[\n\h\f\xb\x0]*\n|\x0*)(?=[\h\f\xb\x0]*\[)', @CR & "${0}" & @CR) $aFileData = StringRegExp($aFileData & @CR, '\r([\h\f\xb\x0]*\[)([^\]\n]*)(\][^\n]*\n)((?>[\n\h\f\xb\x0]*\n)*)([^\r]*)\r([^\r]*)', 3) $aFileData[0] = UBound($aFileData) - 1 If $aFileData[0] < 5 Then Return SetError(1, 0, 0) ; should not happen ever $aFileData[$aFileData[0]] = StringTrimRight($aFileData[$aFileData[0]], 1) For $iHINI = 1 To $_HINI[0][0] If Not $_HINI[$iHINI][0] Then ExitLoop Next If $iHINI > $_HINI[0][0] Then ReDim $_HINI[$iHINI + $iHINI][11] $_HINI[0][0] = $iHINI + $iHINI - 1 EndIf $aFileData[2] = $iHINI $aFileData[3] = StringAddCR($aFileData[3]) $aFileData[4] = StringAddCR($aFileData[4]) $aFileData[5] = StringAddCR($aFileData[5]) For $i = 7 To $aFileData[0] Step 6 $_HINI[$iHINI][5] &= @LF & $aFileData[$i] & @CR & $i $aFileData[$i + 1] = StringAddCR($aFileData[$i + 1]) $aFileData[$i + 2] = StringAddCR($aFileData[$i + 2]) $aFileData[$i + 3] = StringAddCR($aFileData[$i + 3]) $aFileData[$i + 4] = StringAddCR($aFileData[$i + 4]) Next $_HINI[0][1] += 1 ;;($_HINI[0][1] < 1) ? 1 : $_HINI[0][1] + 1 $_HINI[$iHINI][0] = $iHINI $_HINI[$iHINI][1] = $aFileData $_HINI[$iHINI][2] = $sFilePath $_HINI[$iHINI][3] = $iFileEncoding $_HINI[$iHINI][4] = ($aFileData[0] - 5) / 6 $_HINI[$iHINI][5] = StringReplace($_HINI[$iHINI][5], "\E", "\e", 0, 1) $_HINI[$iHINI][7] = Null Return $iHINI EndFunc ;==>_IniOpenFileEx ; #FUNCTION# ==================================================================================================================== ; Name...........: _IniCloseFileEx ; Description ...: The _IniCloseFileEx function closes the INI file opened by a call to _IniOpenFileEx. ; Syntax.........: _IniCloseFileEx($hIniFile[, $iFlags]) ; Parameters ....: $hIniFile - Handle or INI Path to the INI file to be closed, This parameter can be NULL (use the $NULL_REF to set NULL this parameter) ; if $hIniFile is NULL Function Close All Open Handle or INI Path ; $iFlags - Optional, Flag to indicate the type of action that should be performed (add the flags together for multiple operations): ; |Default - always Commits the changes that were made when the INI file was opened by _IniOpenFileEx() ; |$INI_DISCARDCHANGES (134217728) - Discards the changes that were made when the INI file was opened by _IniOpenFileEx() ; Return values .: NONE ; Author ........: DXRW4E ; Remarks .......: ; =============================================================================================================================== Func _IniCloseFileEx($hIniFile, $iFlags = 0) If $hIniFile = $NULL_REF Then For $i = 1 To $_HINI[0][0] If Not BitAND($iFlags, $INI_DISCARDCHANGES) And $_HINI[$i][2] <> "FileQueue" Then _IniFileWriteEx($i, $iFlags) For $y = 0 To 10 $_HINI[$i][$y] = "" Next Next $_HINI[0][1] = 0 Else $hIniFile = _IniGetFileInformationEx($hIniFile) If @Error Then Return SetError(1, 0, 0) If Not BitAND($iFlags, $INI_DISCARDCHANGES) And $_HINI[$hIniFile][2] <> "FileQueue" Then _IniFileWriteEx($hIniFile, $iFlags) For $i = 0 To 10 $_HINI[$hIniFile][$i] = "" Next $_HINI[0][1] -= 1 EndIf Return 0 EndFunc ;==>_IniCloseFileEx ; #FUNCTION# ==================================================================================================================== ; Name...........: _IniDeleteEx ; Description ...: Delete\Remove - Section\KeyName in INI File. ; Syntax.........: _IniDeleteEx(ByRef $hIniFile, $sSectionName[, $sKeyName[, $iFlags[, $scKeyName]]]) ; Parameters ....: $hIniFile - Handle to the INI file to query "see _IniOpenFileEx()" ; $sSectionName - The name of the section containing the Key\Value, This parameter can be NULL (use the $NULL_REF to set NULL this parameter) ; If $sSectionName is NULL, $hIniFile must be contain Section String\Key\Value\Data and $sKeyName the name of the key to delete ; $sKeyName - The key name to delete, If $INI_OVERWRITEALL if set\used, $sKeyName will be writte exactly as in $sKeyName (without Edit\Formatting) ; This parameter can be NULL (use the $NULL_REF to set NULL this parameter), If $sKeyName is NULL, $hIniFile must be contain INI String\Text Data and $sSectionName the name of the section to delete ; $iFlags - Optional, Flag to indicate the type of action that should be performed (add the flags together for multiple operations): ; |$INI_NOOCCURRENCE (512) - Check only first section if there are more than one ; |$INI_IGNOREDUPLICATE (131072) - Proceed\Execute (Add\Delete\Replace\Edit ect ect) Once Only (Ignore all other Duplicate\Occurrences of KeyName\Value\Data) ; |$INI_DELETE (262144) - Delete\Remove KeyName\Value\Data ; |$INI_REMOVE (1048576) - Remove\Delete Section ; $scKeyName - Optional, Key-Name separator character, Default is '=', This parameter can not be '"' or @CR or @LF ; Return values .: Returns a 0 (check @Extended for number of edit performed) ; @Error - 0 = No error. ; |1 = Invalid IniHandle. ; |3 = SectionName not found ; Remarks .......: $INI_MERGE (1024) - (Join section if more than one in INI file) is always set\used by default, to disable it just use the $INI_NOOCCURRENCE ; Author ........: DXRW4E ; =============================================================================================================================== Func _IniDeleteEx(ByRef $hIniFile, $sSectionName, $sKeyName = "", $iFlags = 0, $scKeyName = "=") If Not $scKeyName Then $scKeyName = "=" If $sSectionName = $NULL_REF Then Local $iOffSet = StringInStr($hIniFile, @LF, 1) If StringRegExp(StringLeft($hIniFile, $iOffSet), '^(?i)[\h\f\xb\x0]*(?>\Q"' & $sKeyName & '"\E|\Q' & $sKeyName & '\E)[\h\f\xb\x0]*' & $scKeyName & '[\h\f\xb\x0]*[^\n]*') Then If Not BitAND($iFlags, $INI_IGNOREDUPLICATE) Then $hIniFile = StringRegExpReplace($hIniFile, '\n[\h\f\xb\x0]*(?i)(?>\Q"' & $sKeyName & '"\E|\Q' & $sKeyName & '\E)[\h\f\xb\x0]*' & $scKeyName & '[\h\f\xb\x0]*[^\n]*', "") $hIniFile = StringTrimLeft($hIniFile, $iOffSet) SetExtended(1) Else $hIniFile = StringRegExpReplace($hIniFile, '\n[\h\f\xb\x0]*(?i)(?>\Q"' & $sKeyName & '"\E|\Q' & $sKeyName & '\E)[\h\f\xb\x0]*' & $scKeyName & '[\h\f\xb\x0]*[^\n]*', "", (BitAND($iFlags, $INI_IGNOREDUPLICATE) ? 1 : 0)) EndIf ElseIf $sKeyName = $NULL_REF Then ;Not Recommended (NOT SAFE), if the Section (contains) String\Text Data is greater than 4.5 MB, the Section will be ignored $hIniFile = StringTrimRight(StringRegExpReplace($hIniFile & @LF & "[", "(?is)\n[\h\f\xb\x0]*\[\Q" & StringReplace($sSectionName, "\E", "\e", 0, 1) & "\E\][^\n]*(?>\n?(?![\h\f\xb\x0]*\[))(.*?(?=\n[\h\f\xb\x0]*\[))", "", (BitAND($iFlags, $INI_IGNOREDUPLICATE) ? 1 : 0)), 2) Else If $hIniFile < 1 Or $hIniFile > $_HINI[0][0] Then Return SetError(1, 0, "") ;;;;If Not $sSectionName Then Return SetError(2, 0, "") ;Invalid Section Name If StringInStr($sSectionName, "\E", 1) Then $sSectionName = StringReplace($sSectionName, "\E", "\e", 0, 1) If Not $sKeyName Or BitAND($iFlags, $INI_REMOVE_DELETE) = $INI_REMOVE Then $iFlags = BitOr($iFlags, $INI_REMOVE) __IniWriteSectionEx($hIniFile, $sSectionName, $INI_NULL_REF, $iFlags, $INI_NULL_REF, $_HINI[$hIniFile][1]) Else $iFlags = BitOR(BitAND($iFlags, $INI_NOOCCURRENCE_IGNOREDUPLICATE), $INI_DELETE, $INI_MERGE) If $_HINI[$hIniFile][7] <> $sSectionName Or ($_HINI[$hIniFile][8] > 1 And BitAND($iFlags, $INI_MERGE_NOOCCURRENCE) <> BitAND($_HINI[$hIniFile][9], $INI_MERGE_NOOCCURRENCE)) Then __IniReadSectionEx($hIniFile, $sSectionName, $iFlags, $_HINI[$hIniFile][1]) If @Error Then Return SetError(3, 0, "") EndIf Local $aKeyValue[2][3] = [[1],[$sKeyName]] __IniWriteSectionEx($hIniFile, $sSectionName, $aKeyValue, $iFlags, $scKeyName, $_HINI[$hIniFile][1]) EndIf EndIf Return SetError(0, @Extended, 0) EndFunc ; #FUNCTION# ==================================================================================================================== ; Name...........: _IniReadEx ; Description ...: The _IniReadEx Retrieves a string from the specified section in an Ini file ; Syntax.........: _IniReadEx($hIniFile, $sSectionName, $sKeyName[, $sDefault[, $iFlags[, $scKeyName]]]) ; Parameters ....: $hIniFile - Handle to the INI file to query "see _IniOpenFileEx()" ; $sSectionName - The name of the section containing the key name, This parameter can be NULL (use the $NULL_REF to set NULL this parameter) ; If $sSectionName is NULL, $hIniFile must be contain Section String\Key\Value\Data ; $sKeyName - The name of the key whose associated string is to be retrieved ; $sDefault - The default value to return if the requested KeyName is not found. ; $iFlags - Optional, Flag to indicate the type of action that should be performed (add the flags together for multiple operations): ; |$INI_ARRAYDATA (4) - Read All KeyName and Return Array of ValueString ; |$INI_ARRAYDATA_NOCOUNT (8) - Disable the return count in the first element, This Flags will be ignored if the $INI_ARRAYDATA is not set\used ; |$INI_NOOCCURRENCE (512) - Read only first section if there are more than one ; |$INI_MERGE (1024) - Join section if more than one in INI file, This Flag will be ignored if the $INI_NOOCCURRENCE is set\used ; $scKeyName - Optional, Key-Name separator character, Default is '=', This parameter can not be '"' or @CR or @LF ; Return values .: The first occurrence of requested key value as a string Or Array of Value String ; Failure - Returns $sDefault parameter ; @Error - 0 = No error. ; |1 = Invalid IniHandle. ; |3 = SectionName not found ; |5 = Invalid KeyName ; |6 = KeyName not found ; Remarks .......: ; Author ........: DXRW4E ; =============================================================================================================================== Func _IniReadEx(ByRef $hIniFile, $sSectionName, $sKeyName, $sDefault = "", $iFlags = 0, $scKeyName = "=") ;;If Not $sKeyName Then Return SetError(5, 0, "") If StringInStr($sKeyName, "\E", 1) Then $sKeyName = StringReplace($sKeyName, "\E", "\e", 0, 1) Local $aValueString, $sValueString, $iArray = BitAND($iFlags, $INI_ARRAYDATA) If $sSectionName = $NULL_REF Then $aValueString = StringRegExp(StringLeft($hIniFile, StringInStr($hIniFile, @LF, 1)), '^(?i)[\h\f\xb\x0]*(?>\Q"' & $sKeyName & '"\E|\Q' & $sKeyName & '\E)(?>[\h\f\xb\x0]*' & $scKeyName & '[\h\f\xb\x0]*)(?|"([^\r\n]*)"|(.*?))[\h\f\xb\x0]*(?=[\r\n]|$)', 1) Else If $hIniFile < 1 Or $hIniFile > $_HINI[0][0] Then Return SetError(1, 0, "") If StringInStr($sSectionName, "\E", 1) Then $sSectionName = StringReplace($sSectionName, "\E", "\e", 0, 1) If $_HINI[$hIniFile][7] <> $sSectionName Or ($_HINI[$hIniFile][8] > 1 And BitAND($iFlags, $INI_MERGE_NOOCCURRENCE) <> BitAND($_HINI[$hIniFile][9], $INI_MERGE_NOOCCURRENCE)) Then _IniReadSectionEx($hIniFile, $sSectionName, BitOR($iFlags, $INI_STRIPLEADTRAILING)) If @Error Then Return SetError(3, 0, "") EndIf $aValueString = StringRegExp(StringLeft(($_HINI[$hIniFile][1])[$_HINI[$hIniFile][10]], StringInStr(($_HINI[$hIniFile][1])[$_HINI[$hIniFile][10]], @LF, 1)), '^(?i)[\h\f\xb\x0]*(?>\Q"' & $sKeyName & '"\E|\Q' & $sKeyName & '\E)(?>[\h\f\xb\x0]*' & $scKeyName & '[\h\f\xb\x0]*)(?|"([^\r\n]*)"|(.*?))[\h\f\xb\x0]*(?=[\r\n]|$)', 1) ;;;;$aValueString = StringRegExp(($sSectionName = $NULL_REF ? $hIniFile : ($_HINI[$hIniFile][1])[$_HINI[$hIniFile][10]]), '(?im)^[\h\f\xb\x0]*(?>\Q"' & $sKeyName & '"\E|\Q' & $sKeyName & '\E)[\h\f\xb\x0]*' & $scKeyName & '[\h\f\xb\x0]*(?|"([^\r\n]*)"|(.*?))[\h\f\xb\x0]*(?=[\r\n]|$)', 3) EndIf If Not @Error Then If Not $iArray Then Return $aValueString[0] $sValueString = $aValueString[0] & @LF EndIf $aValueString = StringRegExp(($sSectionName = $NULL_REF ? $hIniFile : ($_HINI[$hIniFile][1])[$_HINI[$hIniFile][10]]), '\n[\h\f\xb\x0]*(?i)(?>\Q"' & $sKeyName & '"\E|\Q' & $sKeyName & '\E)(?>[\h\f\xb\x0]*' & $scKeyName & '[\h\f\xb\x0]*)(?|"([^\r\n]*)"|(.*?))[\h\f\xb\x0]*(?=[\r\n]|$)', ($iArray ? 3 : 1)) If @Error Then Return SetError(6, 0, $sDefault) If Not $iArray Then Return $aValueString[0] For $i = 0 To UBound($aValueString) - 1 $sValueString &= $aValueString[$i] & @LF Next Return StringSplit(StringTrimRight($sValueString, 1), @LF, (BitAND($iFlags, $INI_ARRAYDATA_NOCOUNT) ? 3 : 1)) EndFunc ;==>_IniReadEx ; #FUNCTION# ==================================================================================================================== ; Name...........: _IniReadSectionEx ; Description ...: The _IniReadSectionEx Retrieves all the lines for the specified section ; Syntax.........: _IniReadSectionEx(ByRef $hIniFile, $sSectionName[, $iFlags[, $scKeyName]) ; Parameters ....: $hIniFile - Handle to the INI file to query "see _IniOpenFileEx()" ; $sSectionName - The name of the section containing the Key\Value, This parameter can be NULL (use the $NULL_REF to set NULL this parameter) ; If $sSectionName is NULL, $hIniFile must be contain Section String\Key\Value\Data ; $iFlags - Optional, Flag to indicate the type of action that should be performed (add the flags together for multiple operations): ; Default Return Section String\Text Data ; |$INI_NOOCCURRENCE (512) - Read only first section if there are more than one ; |$INI_MERGE (1024) - Join section if more than one in INI file, This Flag will be ignored if the $INI_NOOCCURRENCE is set\used ; |$INI_2DARRAYFIELD (1073741824) - Return 2DArray ; $aArray[0][0] = number of elements ; $aArray[0][1] = Key-Name separator character, Defaut is '=' ; $aArray[1][0] = "KeyName" ; $aArray[1][1] = "Value" ; $aArray[1][2] = "Unmodified contents of a line (example ' KeyName = Value')" ; $aArray[n][0] = "KeyName" ; $aArray[n][1] = "Value" ; $aArray[n][2] = "Unmodified contents of a line (example ' KeyName = Value')" ; $scKeyName - Optional, Key-Name separator character, Default is '=', This parameter can not be '"' or @CR or @LF ; Return values .: String\Text Data Or 2D Array ; @Error - 0 = No error. ; |1 = Invalid IniHandle. ; |3 = SectionName's not found ; |4 = Array is invalid, Key\Value not found ; Remarks .......: ; Author ........: DXRW4E ; =============================================================================================================================== Func _IniReadSectionEx(ByRef $hIniFile, $sSectionName, $iFlags = 0, $scKeyName = "=") If Not $scKeyName Then $scKeyName = "=" If $sSectionName = $NULL_REF Then Local $_aSectionData = StringRegExp($hIniFile, '(?m)^((?>[\h\f\xb\x0]*)((?>"[^"\r\n]+"|(?:[^"\s' & $scKeyName & '\x0]+|(?>[\h\f\xb\x0]+)(?!' & $scKeyName & '))*))(?>[\h\f\xb\x0]*' & $scKeyName & '[\h\f\xb\x0]*)(?|"([^\r\n]*)"|(.*?))[\h\f\xb\x0]*(?=[\r\n]|$))', 3) Else If $hIniFile < 1 Or $hIniFile > $_HINI[0][0] Then Return SetError(1, 0, "") If $_HINI[$hIniFile][7] <> $sSectionName Or ($_HINI[$hIniFile][8] > 1 And BitAND($iFlags, $INI_MERGE_NOOCCURRENCE) <> BitAND($_HINI[$hIniFile][9], $INI_MERGE_NOOCCURRENCE)) Then $iFlags = BitOR($iFlags, $INI_NOCREATE) __IniReadSectionEx($hIniFile, $sSectionName, $iFlags, $_HINI[$hIniFile][1]) If @Error Then Return SetError(3, 0, "") EndIf If Not BitAND($iFlags, $INI_2DARRAYFIELD) Then Return ($_HINI[$hIniFile][1])[$_HINI[$hIniFile][10]] Local $_aSectionData = StringRegExp(($_HINI[$hIniFile][1])[$_HINI[$hIniFile][10]], '(?m)^((?>[\h\f\xb\x0]*)((?>"[^"\r\n]+"|(?:[^"\s' & $scKeyName & '\x0]+|(?>[\h\f\xb\x0]+)(?!' & $scKeyName & '))*))(?>[\h\f\xb\x0]*' & $scKeyName & '[\h\f\xb\x0]*)(?|"([^\r\n]*)"|(.*?))[\h\f\xb\x0]*(?=[\r\n]|$))', 3) EndIf If @Error Then Return SetError(4, 0, "") Local $iaSectionData = UBound($_aSectionData), $aSectionData[$iaSectionData / 3 + 1][3] = [[0,$scKeyName,$iaSectionData - 1]] For $i = 0 To $aSectionData[0][2] Step 3 $aSectionData[0][0] += 1 $aSectionData[$aSectionData[0][0]][0] = $_aSectionData[$i + 1] $aSectionData[$aSectionData[0][0]][1] = $_aSectionData[$i + 2] $aSectionData[$aSectionData[0][0]][2] = $_aSectionData[$i] Next Return SetError(0, $aSectionData[0][0], $aSectionData) EndFunc ;==>_IniReadSectionEx ; #FUNCTION# ==================================================================================================================== ; Name...........: _IniReadSectionNamesEx ; Description ...: The _IniReadSectionNamesEx Retrieves the names of all sections in an INI file ; Syntax.........: _IniReadSectionNamesEx($hIniFile[, $iFlags]) ; Parameters ....: $hIniFile - Handle to the INI file to query "see _IniOpenFileEx()" ; $iFlags - Optional, Flag to indicate the type of action that should be performed ; |$INI_ARRAYDATA_NOCOUNT (8) - disable the return count in the first element ; |$NULL_REF (NULL) - $hIniFile must be contain INI String\Section\Key\Value\Data ; Return values .: Array of SectionNames String, and set @Extended = Number of Section's ; @Error - 0 = No error. ; |1 = Array is invalid, Invalid IniHandle. ; |3 = Array is invalid, SectionName's not found ; Remarks .......: ; Author ........: DXRW4E ; =============================================================================================================================== Func _IniReadSectionNamesEx(ByRef $hIniFile, $iFlags = 0) If $iFlags = $NULL_REF Then Local $aSectionNames, $iANC = BitAND($iFlags, $INI_ARRAYDATA_NOCOUNT) $aSectionNames = StringRegExp(($iANC ? @LF : @LF & "[]" & @LF) & $hIniFile, "\n[\h\f\xb\x0]*\[([^\r\n]*)\]", 3) If @Error Then Return SetError(1, 0, "") If $iANC Then Return SetError(0, UBound($aSectionNames), $aSectionNames) $aSectionNames[0] = UBound($aSectionNames) - 1 Return SetError(0, $aSectionNames[0], $aSectionNames) EndIf If $hIniFile < 1 Or $hIniFile > $_HINI[0][0] Then Return SetError(1, 0, "") If Not $_HINI[$hIniFile][4] Then Return SetError(3, 0, "") If BitAND($iFlags, $INI_ARRAYDATA_NOCOUNT) Then Return SetError(0, $_HINI[$hIniFile][4], StringRegExp($_HINI[$hIniFile][5], "\n([^\r\n]*)", 3)) Return SetError(0, $_HINI[$hIniFile][4], StringRegExp(@LF & $_HINI[$hIniFile][4] & $_HINI[$hIniFile][5], "\n([^\r\n]*)", 3)) EndFunc ;==>_IniReadSectionNamesEx ; #FUNCTION# ==================================================================================================================== ; Name...........: _IniRenameSectionEx ; Description ...: The _IniRenameSectionEx rename the sections in an INI file ; Syntax.........: _IniRenameSectionEx($hIniFile[, $iFlags]) ; Parameters ....: $hIniFile - Handle to the INI file to query "see _IniOpenFileEx()" ; $iFlags - Optional, Flag to indicate the type of action that should be performed (add the flags together for multiple operations): ; |$INI_NOOCCURRENCE (512) - Rename only first section if there are more than one ; |$INI_MERGE (1024) - Join section if more than one in INI\INI file, This Flag will be ignored if the $INI_NOOCCURRENCE is set\used ; |$NULL_REF (NULL) - $hIniFile must be contain INI String\Section\Key\Value\Data ; Return values .: Returns a 0 (check @Extended for number of edit performed) ; @Error - 0 = No error. ; |1 = Invalid IniHandle. ; |3 = SectionName's not found ; Remarks .......: ; Author ........: DXRW4E ; =============================================================================================================================== Func _IniRenameSectionEx(ByRef $hIniFile, $sSectionName, $sNewSectionName, $iFlags = 0) ;;;;If Not $sSectionName Or Not $sNewSectionName Then Return SetError(2, 0, "") ;Invalid Section Name If $iFlags = $NULL_REF Then $hIniFile = StringRegExpReplace($hIniFile, "(?mi)^[\h\f\xb\x0]*\[\K\Q" & StringReplace($sSectionName, "\E", "\e", 0, 1) & "\E(?=\])", StringReplace($sNewSectionName, "\", "\\", 0, 1), (BitAND($iFlags, $INI_NOOCCURRENCE) ? 1 : 0)) Else If $hIniFile < 1 Or $hIniFile > $_HINI[0][0] Then Return SetError(1, 0, "") If StringInStr($sSectionName, "\E", 1) Then $sSectionName = StringReplace($sSectionName, "\E", "\e", 0, 1) $iFlags = BitXOR(BitOR($iFlags, $INI_REMOVE_RENAME), $INI_REMOVE) If BitAND($iFlags, $INI_MERGE_NOOCCURRENCE) = $INI_MERGE And Not __IniReadSectionEx($hIniFile, $sSectionName, $iFlags, $_HINI[$hIniFile][1]) Then Return SetError(3, 0, 0) __IniWriteSectionEx($hIniFile, $sSectionName, $sNewSectionName, $iFlags, $INI_NULL_REF, $_HINI[$hIniFile][1]) EndIf Return SetError(@Error, @Extended, 0) EndFunc ;==>_IniRenameSectionEx ; #FUNCTION# ==================================================================================================================== ; Name...........: _IniWriteEx ; Description ...: Write\Add\Replace\Delete\Change\Edit a KeyName\Value\Data in INI File ; Syntax.........: _IniWriteEx(ByRef $hIniFile, $sSectionName, $sKeyName, $sValue[, $iFlags[, $scKeyName]]) ; Parameters ....: $hIniFile - Handle to the INI file to query "see _IniOpenFileEx()" ; $sSectionName - The name of the section containing the Key\Value, This parameter can be NULL (use the $NULL_REF to set NULL this parameter) ; If $sSectionName is NULL, $hIniFile must be contain Section String\Key\Value\Data ; $sKeyName - The key name in the in the .ini file. ; $sKeyName - The value to write/change. ; $iFlags - Optional, Flag to indicate the type of action that should be performed (add the flags together for multiple operations): ; |$INI_STRIPLEADING (1) - strip leading white space Section, This Flag will be ignored if the $INI_OVERWRITEALL or $INI_APPENDDATA is set\used ; |$INI_STRIPTRAILING (2) - trailing white space Section, This Flag will be ignored if the $INI_OVERWRITEALL or $INI_APPENDDATA is set\used ; |$INI_NOOCCURRENCE (512) - Check only first section if there are more than one ; |$INI_NOCREATE (2048) - Not Create New Section If Section Not Exist ; |$INI_APPENDDATA (4096) - Add KeyName\Value\Data (Append Mod) ; |$INI_REPLACEONLY (8192) - Add KeyName\Value\Data Only if Exist ; |$INI_NOOVERWRITE (32768) - Add KeyName\Value\Data Only if Not Exist ; |$INI_OVERWRITEALL (65536) - Overwrite All data in Section (Replaces all KeyName\Value\Data in the Section) ; |$INI_IGNOREDUPLICATE (131072) - Proceed\Execute (Add\Delete\Replace\Edit ect ect) Once Only (Ignore all other Duplicate\Occurrences of KeyName\Value\Data) ; |$INI_DELETE (262144) - Delete\Remove KeyName\Value\Data ; $scKeyName - Optional, Key-Name separator character, Default is '=', This parameter can not be '"' or @CR or @LF ; Return values .: Returns a 0 (check @Extended for number of edit performed) ; @Error - 0 = No error. ; |1 = Invalid IniHandle. ; |3 = SectionName's not found ; |5 = Invalid KeyName ; Author ........: DXRW4E ; Remarks .......: $INI_MERGE (1024) - (Join section if more than one in INI file) is always set\used by default, to disable it just use the $INI_NOOCCURRENCE ; =============================================================================================================================== Func _IniWriteEx(ByRef $hIniFile, $sSectionName, $sKeyName, $sValue, $iFlags = 0, $scKeyName = "=") ;;If Not $sKeyName Then Return SetError(5, 0, "") If Not $scKeyName Then $scKeyName = "=" If $sSectionName = $NULL_REF Then If BitAND($iFlags, $INI_OVERWRITEALL_APPENDDATA) Then If BitAND($iFlags, $INI_OVERWRITEALL) Then $hIniFile = "" $hIniFile &= $sKeyName & $scKeyName & $sValue & @CRLF Else Local $asKeyValue, $sKNPattern, $iOffSet = StringInStr($hIniFile, @LF, 1) $sKNPattern = '\n[\h\f\xb\x0]*(?i)(?>\Q"' & $sKeyName & '"\E|\Q' & $sKeyName & '\E)[\h\f\xb\x0]*' & $scKeyName & '[\h\f\xb\x0]*[^\n]*' If StringRegExp(StringLeft($hIniFile, $iOffSet), '^(?i)[\h\f\xb\x0]*(?>\Q"' & $sKeyName & '"\E|\Q' & $sKeyName & '\E)[\h\f\xb\x0]*' & $scKeyName & '[\h\f\xb\x0]*[^\n]*') Then If Not BitAND($iFlags, $INI_IGNOREDUPLICATE) Then $hIniFile = StringRegExpReplace($hIniFile, $sKNPattern, "") If BitAND($iFlags, $INI_DELETE) Then $hIniFile = StringTrimLeft($hIniFile, $iOffSet) ElseIf Not BitAND($iFlags, $INI_NOOVERWRITE) Then $hIniFile = $sKeyName & $scKeyName & $sValue & @CRLF & StringTrimLeft($hIniFile, $iOffSet) EndIf ElseIf BitAND($iFlags, $INI_DELETE) Then $hIniFile = StringRegExpReplace($hIniFile, $sKNPattern, "", (BitAND($iFlags, $INI_IGNOREDUPLICATE) ? 1 : 0)) Else $asKeyValue = StringRegExp($hIniFile, $sKNPattern, 1) $iOffSet = @Extended - 1 If Not @Error Then If BitAND($iFlags, $INI_NOOVERWRITE) Then If Not BitAND($iFlags, $INI_IGNOREDUPLICATE) Then $hIniFile = StringLeft($hIniFile, $iOffSet) & StringRegExpReplace(StringTrimLeft($hIniFile, $iOffSet), $sKNPattern, "") Else $hIniFile = StringLeft($hIniFile, $iOffSet + 1 - StringLen($asKeyValue[0])) & $sKeyName & $scKeyName & $sValue & @CR & (BitAND($iFlags, $INI_IGNOREDUPLICATE) ? StringTrimLeft($hIniFile, $iOffSet) : StringRegExpReplace(StringTrimLeft($hIniFile, $iOffSet), $sKNPattern, "")) EndIf ElseIf Not BitAND($iFlags, $INI_REPLACEONLY) Then $hIniFile &= $sKeyName & $scKeyName & $sValue & @CRLF Else Return SetError(0, 0, 0) EndIf EndIf EndIf Return SetError(0, 1, 0) Else If $hIniFile < 1 Or $hIniFile > $_HINI[0][0] Then Return SetError(1, 0, "") ;;;;If Not $sSectionName Then Return SetError(2, 0, "") ;Invalid Section Name If StringInStr($sSectionName, "\E", 1) Then $sSectionName = StringReplace($sSectionName, "\E", "\e", 0, 1) Local $aKeyValue[2][3] = [[1],[$sKeyName,"",$sKeyName & $scKeyName & $sValue]] $iFlags = BitOR(BitXOR($iFlags, BitAND($iFlags, $INI_REMOVE_RENAME)), $INI_MERGE) If $_HINI[$hIniFile][7] <> $sSectionName Or ($_HINI[$hIniFile][8] > 1 And BitAND($iFlags, $INI_MERGE_NOOCCURRENCE) <> BitAND($_HINI[$hIniFile][9], $INI_MERGE_NOOCCURRENCE)) Then __IniReadSectionEx($hIniFile, $sSectionName, $iFlags, $_HINI[$hIniFile][1]) If @Error Then Return SetError(3, 0, "") EndIf __IniWriteSectionEx($hIniFile, $sSectionName, $aKeyValue, $iFlags, $scKeyName, $_HINI[$hIniFile][1]) EndIf Return SetError(@Error, @Extended, 0) EndFunc ; #FUNCTION# ==================================================================================================================== ; Name...........: _IniWriteSectionEx ; Description ...: Add\Replace\Delete\Remove\Rename\Change\Edit a Section\KeyName\Value\Data in INI File. ; Syntax.........: _IniWriteSectionEx() ; Parameters ....: $hIniFile - Handle to the INI file to query "see _IniOpenFileEx()" ; $sSectionName - The name of the section containing the Key\Value\Data ; $aKeyValue - String\Text Data (example 'KeyName=Value 7 @LF & KeyName2=Value2') or an 2DArray is passed as data, the return Array of IniReadSectionEx() can be used immediately. ; If $aKeyValue is String\Text Data and $INI_OVERWRITEALL or $INI_APPENDDATA if Set\Used, $aKeyValue will be writte exactly as in $aKeyValue (without Edit\Formatting) ; $iFlags - Optional, Flag to indicate the type of action that should be performed (add the flags together for multiple operations): ; |$INI_STRIPLEADING (1) - strip leading white space Section, This Flag will be ignored if the $INI_OVERWRITEALL or $INI_APPENDDATA is set\used ; |$INI_STRIPTRAILING (2) - trailing white space Section, This Flag will be ignored if the $INI_OVERWRITEALL or $INI_APPENDDATA is set\used ; |$INI_NOOCCURRENCE (512) - Check only first section if there are more than one ; |$INI_NOCREATE (2048) - Not Create New Section If Section Not Exist ; |$INI_APPENDDATA (4096) - Add KeyName\Value\Data (Append Mod) ; |$INI_REPLACEONLY (8192) - Add KeyName\Value\Data Only if Exist ; |$INI_NOOVERWRITE (32768) - Add KeyName\Value\Data Only if Not Exist ; |$INI_OVERWRITEALL (65536) - Overwrite All data in Section (Replaces all KeyName\Value\Data in the Section) ; |$INI_IGNOREDUPLICATE (131072) - Proceed\Execute (Add\Delete\Replace\Edit ect ect) Once Only (Ignore all other Duplicate\Occurrences of KeyName\Value\Data) ; |$INI_DELETE (262144) - Delete\Remove KeyName\Value\Data ; |$INI_RENAME (524288) - Renames a section ; |$INI_REMOVE (1048576) - Remove\Delete Section ; $scKeyName - Optional, Key-Name separator character, Default is '=', This parameter can not be '"' or @CR or @LF ; Return values .: Returns a 0 (check @Extended for number of edit performed) ; @Error - 0 = No error. ; |1 = Invalid IniHandle. ; |3 = SectionName's not found ; |5 = Invalid KeyName ; Remarks .......: ; Author ........: DXRW4E ; Remarks .......: $INI_MERGE (1024) - (Join section if more than one in INI file) is always set\used by default, to disable it just use the $INI_NOOCCURRENCE ; =============================================================================================================================== Func _IniWriteSectionEx(ByRef $hIniFile, $sSectionName, $aKeyValue, $iFlags = 0, $scKeyName = "=") ;~ If $sSectionName = $NULL_REF Then ;~ If Not $scKeyName Then $scKeyName = "=" ;~ If IsArray($aKeyValue) Then ;~ Local $iCols = UBound($aKeyValue, 2) ;~ If UBound($aKeyValue, 0) <> 2 Or $iCols < 2 Then Return SetError(7, 0, "") ;~ If $iCols = 2 Then ;~ ReDim $aKeyValue[$aKeyValue[0][0] + 1][3] ;~ For $i = 1 To $aKeyValue[0][0] ;~ $aKeyValue[$i][2] = $aKeyValue[$i][0] & $scKeyName & $aKeyValue[$i][1] ;~ Next ;~ EndIf ;~ ElseIf Not BitAND($iFlags, $INI_OVERWRITEALL_APPENDDATA) Then ;~ $aKeyValue = _IniReadSectionEx($aKeyValue, Null, $INI_2DARRAYFIELD, $scKeyName) ;~ If @Error Then Return SetError(7, 0, "") ;~ EndIf ;~ If BitAND($iFlags, $INI_OVERWRITEALL_APPENDDATA) Then ;~ If BitAND($iFlags, $INI_OVERWRITEALL) Then $hIniFile = "" ;~ If IsArray($aKeyValue) Then ;~ For $i = 1 To $aKeyValue[0][0] ;~ $hIniFile &= $aKeyValue[$i][2] & @CRLF ;~ Next ;~ Else ;~ ;; KeyName\Value\Text Data will be writte exactly as in $aKeyValue (without Edit\Formatting ect ect) ;~ $hIniFile &= $aKeyValue & (StringRight($aKeyValue, 1) = @LF ? "" : @CRLF) ;~ EndIf ;~ Return SetError(0, 1, 0) ;~ Else ;~ Local $asKeyValue, $iKeyValue = 0, $sKNPattern, $iOffSet = StringInStr($hIniFile, @LF, 1) ;~ For $i = 1 To $aKeyValue[0][0] ;~ $sKNPattern = '\n[\h\f\xb\x0]*(?i)(?>\Q"' & $aKeyValue[$i][0] & '"\E|\Q' & $aKeyValue[$i][0] & '\E)[\h\f\xb\x0]*' & $scKeyName & '[\h\f\xb\x0]*[^\n]*' ;~ If StringRegExp(StringLeft($hIniFile, $iOffSet), '^(?i)[\h\f\xb\x0]*(?>\Q"' & $aKeyValue[$i][0] & '"\E|\Q' & $aKeyValue[$i][0] & '\E)[\h\f\xb\x0]*' & $scKeyName & '[\h\f\xb\x0]*[^\n]*') Then ;~ If Not BitAND($iFlags, $INI_IGNOREDUPLICATE) Then $hIniFile = StringRegExpReplace($hIniFile, $sKNPattern, "") ;~ If BitAND($iFlags, $INI_DELETE) Then ;~ $hIniFile = StringTrimLeft($hIniFile, $iOffSet) ;~ ElseIf Not BitAND($iFlags, $INI_NOOVERWRITE) Then ;~ $hIniFile = $aKeyValue[$i][2] & @CRLF & StringTrimLeft($hIniFile, $iOffSet) ;~ EndIf ;~ ElseIf BitAND($iFlags, $INI_DELETE) Then ;~ $hIniFile = StringRegExpReplace($hIniFile, $sKNPattern, "", (BitAND($iFlags, $INI_IGNOREDUPLICATE) ? 1 : 0)) ;~ Else ;~ $asKeyValue = StringRegExp($hIniFile, $sKNPattern, 1) ;~ $iOffSet = @Extended - 1 ;~ If Not @Error Then ;~ If BitAND($iFlags, $INI_NOOVERWRITE) Then ;~ If Not BitAND($iFlags, $INI_IGNOREDUPLICATE) Then $hIniFile = StringLeft($hIniFile, $iOffSet) & StringRegExpReplace(StringTrimLeft($hIniFile, $iOffSet), $sKNPattern, "") ;~ Else ;~ $hIniFile = StringLeft($hIniFile, $iOffSet + 1 - StringLen($asKeyValue[0])) & $aKeyValue[$i][2] & @CR & (BitAND($iFlags, $INI_IGNOREDUPLICATE) ? StringTrimLeft($hIniFile, $iOffSet) : StringRegExpReplace(StringTrimLeft($hIniFile, $iOffSet), $sKNPattern, "")) ;~ EndIf ;~ ElseIf Not BitAND($iFlags, $INI_REPLACEONLY) Then ;~ $hIniFile &= $aKeyValue[$i][2] & @CRLF ;~ Else ;~ $iKeyValue -= 1 ;~ EndIf ;~ EndIf ;~ $iKeyValue += 1 ;~ Next ;~ Return SetError(0, $iKeyValue, 0) ;~ EndIf ;~ EndIf If $hIniFile < 1 Or $hIniFile > $_HINI[0][0] Then Return SetError(1, 0, "") ;;;;If Not $sSectionName Then Return SetError(2, 0, "") ;Invalid Section Name If StringInStr($sSectionName, "\E", 1) Then $sSectionName = StringReplace($sSectionName, "\E", "\e", 0, 1) If BitAND($iFlags, $INI_REMOVE) Then __IniWriteSectionEx($hIniFile, $sSectionName, $INI_NULL_REF, $iFlags, $INI_NULL_REF, $_HINI[$hIniFile][1]) ElseIf BitAND($iFlags, $INI_RENAME) Then ;;;; $aKeyValue is New Section Name ;;If Not $aKeyValue Then Return SetError(5, 0, "") If BitAND($iFlags, $INI_MERGE_NOOCCURRENCE) = $INI_MERGE And Not __IniReadSectionEx($hIniFile, $sSectionName, $iFlags, $_HINI[$hIniFile][1]) Then Return SetError(3, 0, 0) __IniWriteSectionEx($hIniFile, $sSectionName, $aKeyValue, $iFlags, $INI_NULL_REF, $_HINI[$hIniFile][1]) Else If Not $scKeyName Then $scKeyName = "=" If IsArray($aKeyValue) Then Local $iCols = UBound($aKeyValue, 2) If UBound($aKeyValue, 0) <> 2 Or $iCols < 2 Then Return SetError(5, 0, "") If $iCols = 2 Then ReDim $aKeyValue[$aKeyValue[0][0] + 1][3] For $i = 1 To $aKeyValue[0][0] $aKeyValue[$i][2] = $aKeyValue[$i][0] & $scKeyName & $aKeyValue[$i][1] Next EndIf ElseIf Not BitAND($iFlags, $INI_OVERWRITEALL_APPENDDATA) Then $aKeyValue = _IniReadSectionEx($aKeyValue, Null, $INI_2DARRAYFIELD, $scKeyName) If @Error Then Return SetError(5, 0, "") EndIf $iFlags = BitOR($iFlags, $INI_MERGE) If $_HINI[$hIniFile][7] <> $sSectionName Or ($_HINI[$hIniFile][8] > 1 And BitAND($iFlags, $INI_MERGE_NOOCCURRENCE) <> BitAND($_HINI[$hIniFile][9], $INI_MERGE_NOOCCURRENCE)) Then __IniReadSectionEx($hIniFile, $sSectionName, $iFlags, $_HINI[$hIniFile][1]) If @Error Then Return SetError(3, 0, "") EndIf __IniWriteSectionEx($hIniFile, $sSectionName, $aKeyValue, $iFlags, $scKeyName, $_HINI[$hIniFile][1]) EndIf Return SetError(@Error, @Extended, 0) EndFunc ; #FUNCTION# ==================================================================================================================== ; Name...........: _IniGetSectionNumberEx ; Description ...: The _IniGetSectionNumberEx Retrieves the number of all sections in an INI file ; Syntax.........: _IniGetSectionNumberEx(Byref $hIniFile) ; Parameters ....: $hIniFile - Handle to the INI file to query "see _IniOpenFileEx()" ; Return values .: Number of Section's ; @Error - 0 = No error. ; |1 = Invalid IniHandle. ; |3 = SectionName's not found ; Remarks .......: ; Author ........: DXRW4E ; =============================================================================================================================== Func _IniGetSectionNumberEx(ByRef $hIniFile) If $hIniFile < 1 Or $hIniFile > $_HINI[0][0] Then Local $aSectionNames = StringRegExp(@LF & $hIniFile, "\n[\h\f\xb\x0]*\[[^\r\n]*\K\]", 3) ;StringRegExp($hIniFile, "(?m)^[\h\f\xb\x0]*\[[^\r\n]*\]", 3) Return SetError(@Error, 0, UBound($aSectionNames)) EndIf Return SetError(($_HINI[$hIniFile][4] ? 0 : 3), 0, $_HINI[$hIniFile][4]) EndFunc ;==>_IniGetSectionNumberEx ; #FUNCTION# =========================================================================================================== ; Name...........: _IniGetFileInformationEx ; Description ...: Returns information about an INI file ; Syntax.........: _IniGetFileInformationEx($hIniFile[, $iFlags]) ; Parameters ....: $hIniFile - Handle of INI file previously opened by _IniOpenFileEx, see _IniOpenFileEx() ; $iFlags - Optional ; |0 - Return INI Handle (Default) ; |1 - Return INI File Array Data (is array of arrays) ; |2 - Return INI File Path ; |3 - Return INI Encoding ; |4 - Return INI Section Number ; Return values .: See Flag parameter ; Author ........: DXRW4E ; Modified.......: ; Remarks .......: ; =============================================================================================================================== Func _IniGetFileInformationEx($hIniFile, $iFlags = 0) If Not $hIniFile Then Return SetError(1, 0, "") If $_HINI[0][1] < 0 Then $_HINI[0][1] = 0 Return SetError(1, 0, "") ElseIf IsString($hIniFile) Then ;;If StringIsDigit($hIniFile) And StringLeft($hIniFile, 1) <> "0" Then ;; $hIniFile = Number($hIniFile) ;;Else For $i = 1 To $_HINI[0][0] If $_HINI[$i][2] = $hIniFile Then ExitLoop Next $hIniFile = $i ;;EndIf EndIf If $hIniFile < 1 Or $hIniFile > $_HINI[0][0] Then Return SetError(1, 0, "") ; Or $hIniFile <> $_HINI[$hIniFile][0] If $iFlags < 1 Or $iFlags > 4 Then Return $hIniFile Return SetError(0, $hIniFile, $_HINI[$hIniFile][$iFlags]) EndFunc ;==>_IniGetFileInformationEx ; #FUNCTION# ==================================================================================================================== ; Name...........: _IniGetFileStringData ; Description ...: The _IniGetFileStringData Retrieves all INI Lines\String\Text Data ; Syntax.........: _IniGetFileStringData(ByRef $hIniFile[, $iFlags]) ; Parameters ....: $hIniFile - Handle to the INI file to query "see _IniOpenFileEx()" ; $iFlags - Optional, Flag to indicate the type of action that should be performed (add the flags together for multiple operations): ; |$INI_STRIPLEADING (1) - strip leading white space Section ; |$INI_STRIPTRAILING (2) - strip trailing white space Section ; Return values .: String\Text Data ; @Error - 0 = No error. ; |1 = Invalid IniHandle. ; Remarks .......: ; Author ........: DXRW4E ; =============================================================================================================================== Func _IniGetFileStringData(ByRef $hIniFile, $iFlags = 0) If $hIniFile < 1 Or $hIniFile > $_HINI[0][0] Then Return SetError(1, 0, "") ;;Local $sData, $iSL = BitAND($iFlags, $INI_STRIPLEADING), $iST = BitAND($iFlags, $INI_STRIPTRAILING) ;;$sData = ($iSL ? "" : ($_HINI[$hIniFile][1])[3]) & ($_HINI[$hIniFile][1])[4] & ($iST ? "" : ($_HINI[$hIniFile][1])[5]) ;;For $i = 6 To ($_HINI[$hIniFile][1])[0] Step 6 ;; $sData &= ($_HINI[$hIniFile][1])[$i] & ($_HINI[$hIniFile][1])[$i + 1] & ($_HINI[$hIniFile][1])[$i + 2] & ($iSL ? "" : ($_HINI[$hIniFile][1])[$i + 3]) & ($_HINI[$hIniFile][1])[$i + 4] & ($iST ? "" : ($_HINI[$hIniFile][1])[$i + 5]) ;;Next Local $sData = __IniGetFileStringData($hIniFile, $iFlags, $_HINI[$hIniFile][1]) Return SetError(0, $_HINI[$hIniFile][3], $sData) EndFunc ;==>_IniGetFileStringData ; #FUNCTION# ==================================================================================================================== ; Name...........: _IniClearCache ; Description ...: Clear INI File Processing Functions Cache ; Syntax.........: _IniClearCache(ByRef $aIniFile) ; Parameters ....: $hIniFile - Handle to the INI file to query "see _IniOpenFileEx()" ; Return values .: None ; Author ........: DXRW4E ; Modified.......: ; Remarks .......: This function is useful to Run after _IniRea*Ex Funcion's, only in the case when in the INI file are duplicated function ; and if the flag $INI_MERGE or $INI_NOOCCURRENCE is not set\used, because in this case the _IniReadEx\_IniReadSectionEx saves ; in cache the Function's\String\Data to be fast during the loop ect ect, so only in cases when you Get\Read Occurrence Function ; and the flag $INI_MERGE or $INI_NOOCCURRENCE is not set\used ; All other function as _IniDeleteEx or _IniWrite*Ex use by Default or Force the use of $INI_MERGE flag ; So in 99.9% of cases you do not Need\Have to run _IniClearCache(), because the INI File Processing Functions Work's only By Reference ; =============================================================================================================================== Func _IniClearCache(ByRef $hIniFile) If $hIniFile < 1 Or $hIniFile > $_HINI[0][0] Then Return SetError(1, 0, "") $_HINI[$hIniFile][6] = "" __IniSaveCache($hIniFile, $_HINI[$hIniFile][6], $INI_NULL_REF, $_HINI[$hIniFile][6], $_HINI[$hIniFile][6], $_HINI[$hIniFile][1]) Return 0 EndFunc ;==>_IniClearCache ; #FUNCTION# ==================================================================================================================== ; Name...........: _IniFileWrite ; Description ...: Write a Ini File ; Syntax.........: _IniFileWriteEx(ByRef $hIniFile[, $iFlags[, $sFilePath[, $iFileEncoding]]]) ; Parameters ....: $hIniFile - Handle to the INI file to query "see _IniOpenFileEx()" ; $iFlags - Optional, Flag to indicate the type of action that should be performed (add the flags together for multiple operations): ; |$INI_STRIPLEADING (1) - strip leading white space Section ; |$INI_STRIPTRAILING (2) - trailing white space Section ; |$INI_NOWRITEREADONLY (16) - Do not Write\Replace\Edit the ReadOnly file (Default Write\Replace\Edit the ReadOnly files) ; $sFilePath - Optional, use alternative FilePath, By Default always is used (Default) PathFile ; $iFileEncoding - Optional, use alternative FileEncoding, By Default always is used (Default) FileEncoding ; Return values .: Returns a 0 ; @Error - 0 = No error. ; |1 = Invalid IniHandle. ; |9 = Invalid FilePath ; |10 = A file may fail to open due to access rights or attributes. ; Remarks .......: ; Author ........: DXRW4E ; =============================================================================================================================== Func _IniFileWriteEx(ByRef $hIniFile, $iFlags = 0, $sFilePath = Default, $iFileEncoding = Default) If $hIniFile < 1 Or $hIniFile > $_HINI[0][0] Then Return SetError(1, 0, "") If $_HINI[$hIniFile][2] = "FileQueue" And Not $sFilePath Then Return SetError(9, 0, "") If $sFilePath = Default Then $sFilePath = $_HINI[$hIniFile][2] If $iFileEncoding = Default Then $iFileEncoding = $_HINI[$hIniFile][3] + 10 ;;Local $hFileOpen, $iSL = BitAND($iFlags, $INI_STRIPLEADING), $iST = BitAND($iFlags, $INI_STRIPTRAILING) ;;$hFileOpen = FileOpen($_HINI[$hIniFile][2], $_HINI[$hIniFile][3] + 10) ;; ;; Check if file opened for writing OK ;;If $hFileOpen = -1 Then ;; Return SetError(10, 0, 0) ;;EndIf ;;FileWrite($hFileOpen, ($iSL ? "" : ($_HINI[$hIniFile][1])[3]) & ($_HINI[$hIniFile][1])[4] & ($iST ? "" : ($_HINI[$hIniFile][1])[5])) ;;For $i = 6 To ($_HINI[$hIniFile][1])[0] Step 6 ;; FileWrite($hFileOpen, ($_HINI[$hIniFile][1])[$i] & ($_HINI[$hIniFile][1])[$i + 1] & ($_HINI[$hIniFile][1])[$i + 2] & ($iSL ? "" : ($_HINI[$hIniFile][1])[$i + 3]) & ($_HINI[$hIniFile][1])[$i + 4] & ($iST ? "" : ($_HINI[$hIniFile][1])[$i + 5])) ;;Next ;;FileClose($hFileOpen) __IniFileWriteEx($hIniFile, $iFlags, $sFilePath, $iFileEncoding, $_HINI[$hIniFile][1]) Return SetError(@Error, @Extended, 0) EndFunc ;==>_IniFileWriteEx ; #INTERNAL_USE_ONLY# =========================================================================================================== ; Name...........: __IniReadSectionEx ; Description ...: Support Function for _IniReadSectionEx ; Syntax.........: __IniReadSectionEx(ByRef $aIniFile, ByRef $sSectionName, ByRef $iFlags) ; Parameters ....: See _IniReadSectionEx() ; Return values .: See _IniReadSectionEx() ; Author ........: DXRW4E ; Modified.......: ; Remarks .......: This function is used internally by _IniReadSectionEx ; =============================================================================================================================== Func __IniReadSectionEx(ByRef $hIniFile, ByRef $sSectionName, ByRef $iFlags, ByRef $aIniFile) ;;;;If Not $sSectionName Then Return SetError(2, 0, "") ;Invalid Section Name If StringInStr($sSectionName, "\E", 1) Then $sSectionName = StringReplace($sSectionName, "\E", "\e", 0, 1) Local $sSectionData, $aSectionName, $iSectionName = 1 $aSectionName = StringRegExp($_HINI[$hIniFile][5], "\n(?is)\Q" & $sSectionName & "\E\r([^\n]+)", 3) If @Error Then If BitAND($iFlags, $INI_NOCREATE_REMOVE_DELETE) Then Return SetError(3, 0, "") $aIniFile[0] += 6 Redim $aIniFile[$aIniFile[0] + 1] $aIniFile[$aIniFile[0] - 5] = "[" $aIniFile[$aIniFile[0] - 4] = $sSectionName $aIniFile[$aIniFile[0] - 3] = "]" & @CRLF $_HINI[$hIniFile][4] += 1 $_HINI[$hIniFile][5] &= @LF & $sSectionName & @CR & ($aIniFile[0] - 4) $_HINI[$hIniFile][6] = $aIniFile[0] - 1 Else $_HINI[$hIniFile][6] = $aSectionName[0] + 3 $iSectionName = UBound($aSectionName) ;;If BitAND($iFlags, $INI_STRIPLEADTRAILING) = $INI_STRIPLEADTRAILING Then ;; BitOR($INI_STRIPLEADING, $INI_STRIPTRAILING) ;; $sSectionData = $aIniFile[$aSectionName[0] + 3] ;;ElseIf BitAND($iFlags, $INI_STRIPLEADING) Then ;; $sSectionData = $aIniFile[$aSectionName[0] + 3] & $aIniFile[$aSectionName[0] + 4] ;;ElseIf BitAND($iFlags, $INI_STRIPTRAILING) Then ;; $sSectionData = $aIniFile[$aSectionName[0] + 2] & $aIniFile[$aSectionName[0] + 3] ;;Else ;; $sSectionData = $aIniFile[$aSectionName[0] + 2] & $aIniFile[$aSectionName[0] + 3] & $aIniFile[$aSectionName[0] + 4] ;;EndIf If Not BitAND($iFlags, $INI_NOOCCURRENCE) And $iSectionName > 1 Then $sSectionData = $aIniFile[$aSectionName[0] + 3] For $i = 1 To $iSectionName - 1 $sSectionData &= $aIniFile[$aSectionName[$i] + 3] If BitAND($iFlags, $INI_MERGE) Then For $y = $aSectionName[$i] - 1 To $aSectionName[$i] + 4 $aIniFile[$y] = "" Next $_HINI[$hIniFile][5] = StringRegExpReplace($_HINI[$hIniFile][5], '\n(?is)\Q' & $sSectionName & '\E\r' & $aSectionName[$i], "") EndIf Next If BitAND($iFlags, $INI_MERGE) Then $aIniFile[$aSectionName[0] + 3] = $sSectionData EndIf EndIf __IniSaveCache($hIniFile, $sSectionData, $sSectionName, $iFlags, $iSectionName, $aIniFile) Return $iSectionName ;SetError(Not $iSectionName, $iSectionName, $sSectionData) EndFunc ;==>__IniReadSectionEx ; #INTERNAL_USE_ONLY# =========================================================================================================== ; Name...........: __IniWriteSectionEx ; Description ...: Support Function for _IniWriteSectionEx ; Syntax.........: __IniWriteSectionEx(ByRef $hIniFile, ByRef $sSectionName, ByRef $aKeyValue, ByRef $iFlags, ByRef $scKeyName, ByRef $aIniFile) ; Parameters ....: See _IniWriteSectionEx() ; Return values .: See _IniWriteSectionEx() ; Author ........: DXRW4E ; Modified.......: ; Remarks .......: This function is used internally by _IniWriteSectionEx ; =============================================================================================================================== Func __IniWriteSectionEx(ByRef $hIniFile, ByRef $sSectionName, ByRef $aKeyValue, ByRef $iFlags, ByRef $scKeyName, ByRef $aIniFile) If BitAND($iFlags, $INI_REMOVE) Then Local $iaSectionName, $aSectionName = StringRegExp($_HINI[$hIniFile][5], '\n(?is)\Q' & $sSectionName & '\E\r([^\n]+)', 3) If @Error Then Return SetError(3, 0, 0) $iaSectionName = UBound($aSectionName) - 1 If BitAND($iFlags, $INI_NOOCCURRENCE) Then $iaSectionName = 0 For $i = 0 To $iaSectionName For $y = $aSectionName[$i] - 1 To $aSectionName[$i] + 4 $aIniFile[$y] = "" Next Next $_HINI[$hIniFile][4] -= $iaSectionName + 1 $_HINI[$hIniFile][5] = StringRegExpReplace($_HINI[$hIniFile][5], '\n(?is)\Q' & $sSectionName & '\E\r[^\r\n]+', "", Int($iaSectionName = 0)) Return SetError(0, @Extended, 0) ElseIf BitAND($iFlags, $INI_RENAME) Then Local $iaSectionName, $aSectionName = StringRegExp($_HINI[$hIniFile][5], '\n(?is)\Q' & $sSectionName & '\E\r([^\n]+)', 3) If @Error Then Return SetError(3, 0, 0) $iaSectionName = UBound($aSectionName) - 1 If BitAND($iFlags, $INI_NOOCCURRENCE) Then $iaSectionName = 0 ;; $aKeyValue is New Section Name For $i = 0 To $iaSectionName $aIniFile[$aSectionName[$i]] = $aKeyValue Next $_HINI[$hIniFile][5] = StringRegExpReplace($_HINI[$hIniFile][5], '\n\K(?is)\Q' & $sSectionName & '\E(?=\r)', StringReplace(StringReplace($aKeyValue, "\", "\\", 0, 1), "\E", "\e", 0, 1), Int($iaSectionName = 0)) Return SetError(0, @Extended, 0) Else Local $iSN = $_HINI[$hIniFile][10] If BitAND($iFlags, $INI_OVERWRITEALL_APPENDDATA) Then If BitAND($iFlags, $INI_OVERWRITEALL) Then $aIniFile[$iSN] = "" If BitAND($iFlags, $INI_STRIPLEADING) Then $aIniFile[$iSN - 1] = "" If BitAND($iFlags, $INI_STRIPTRAILING) Then $aIniFile[$iSN + 1] = "" If IsArray($aKeyValue) Then For $i = 1 To $aKeyValue[0][0] $aIniFile[$iSN] &= $aKeyValue[$i][2] & @CRLF Next Else ;; KeyName\Value\Text Data will be writte exactly as in $aKeyValue (without Edit\Formatting ect ect) $aIniFile[$iSN] &= $aKeyValue & (StringRight($aKeyValue, 1) = @LF ? "" : @CRLF) EndIf Return SetError(0, 1, 0) Else Local $asKeyValue, $iKeyValue = 0, $sKNPattern, $iOffSet = StringInStr($aIniFile[$iSN], @LF, 1) For $i = 1 To $aKeyValue[0][0] $sKNPattern = '\n[\h\f\xb\x0]*(?i)(?>\Q"' & $aKeyValue[$i][0] & '"\E|\Q' & $aKeyValue[$i][0] & '\E)[\h\f\xb\x0]*' & $scKeyName & '[\h\f\xb\x0]*[^\n]*' If StringRegExp(StringLeft($aIniFile[$iSN], $iOffSet), '^(?i)[\h\f\xb\x0]*(?>\Q"' & $aKeyValue[$i][0] & '"\E|\Q' & $aKeyValue[$i][0] & '\E)[\h\f\xb\x0]*' & $scKeyName & '[\h\f\xb\x0]*[^\n]*') Then If Not BitAND($iFlags, $INI_IGNOREDUPLICATE) Then $aIniFile[$iSN] = StringRegExpReplace($aIniFile[$iSN], $sKNPattern, "") If BitAND($iFlags, $INI_DELETE) Then $aIniFile[$iSN] = StringTrimLeft($aIniFile[$iSN], $iOffSet) ElseIf Not BitAND($iFlags, $INI_NOOVERWRITE) Then $aIniFile[$iSN] = $aKeyValue[$i][2] & @CRLF & StringTrimLeft($aIniFile[$iSN], $iOffSet) EndIf ElseIf BitAND($iFlags, $INI_DELETE) Then $aIniFile[$iSN] = StringRegExpReplace($aIniFile[$iSN], $sKNPattern, "", (BitAND($iFlags, $INI_IGNOREDUPLICATE) ? 1 : 0)) Else $asKeyValue = StringRegExp($aIniFile[$iSN], $sKNPattern, 1) $iOffSet = @Extended - 1 If Not @Error Then If BitAND($iFlags, $INI_NOOVERWRITE) Then If Not BitAND($iFlags, $INI_IGNOREDUPLICATE) Then $aIniFile[$iSN] = StringLeft($aIniFile[$iSN], $iOffSet) & StringRegExpReplace(StringTrimLeft($aIniFile[$iSN], $iOffSet), $sKNPattern, "") Else $aIniFile[$iSN] = StringLeft($aIniFile[$iSN], $iOffSet + 1 - StringLen($asKeyValue[0])) & $aKeyValue[$i][2] & @CR & (BitAND($iFlags, $INI_IGNOREDUPLICATE) ? StringTrimLeft($aIniFile[$iSN], $iOffSet) : StringRegExpReplace(StringTrimLeft($aIniFile[$iSN], $iOffSet), $sKNPattern, "")) EndIf ElseIf Not BitAND($iFlags, $INI_REPLACEONLY) Then $aIniFile[$iSN] &= $aKeyValue[$i][2] & @CRLF Else $iKeyValue -= 1 EndIf EndIf $iKeyValue += 1 Next Return SetError(0, $iKeyValue, 0) EndIf EndIf EndFunc ; #INTERNAL_USE_ONLY# =========================================================================================================== ; Name...........: __IniFileWriteEx ; Description ...: Support Function for _IniFileWriteEx ; Syntax.........: __IniFileWriteEx(ByRef $hIniFile, ByRef $iFlags, ByRef $sFilePath, ByRef $iFileEncoding, ByRef $aIniFile) ; Parameters ....: See _IniFileWriteEx() ; Return values .: See _IniFileWriteEx() ; Author ........: DXRW4E ; Modified.......: ; Remarks .......: This function is used internally by _IniFileWriteEx ; =============================================================================================================================== Func __IniFileWriteEx(ByRef $hIniFile, ByRef $iFlags, ByRef $sFilePath, ByRef $iFileEncoding, ByRef $aIniFile) Local $hFileOpen, $iSL = BitAND($iFlags, $INI_STRIPLEADING), $iST = BitAND($iFlags, $INI_STRIPTRAILING), $iReadOnly = 0 $hFileOpen = FileOpen($sFilePath, $iFileEncoding) ; Check if file opened for writing OK If $hFileOpen = -1 Then If Not BitAND($iFlags, $INI_NOWRITEREADONLY) And StringInStr(FileGetAttrib($sFilePath), "R") Then FileSetAttrib($sFilePath, "-R") $iReadOnly = 1 $hFileOpen = FileOpen($sFilePath, $iFileEncoding) If $hFileOpen = -1 Then Return SetError(10, 0, 0) Else Return SetError(10, 0, 0) EndIf EndIf FileWrite($hFileOpen, ($iSL ? "" : $aIniFile[3]) & $aIniFile[4] & ($iST ? "" : $aIniFile[5])) For $i = 6 To $aIniFile[0] Step 6 FileWrite($hFileOpen, $aIniFile[$i] & $aIniFile[$i + 1] & $aIniFile[$i + 2] & ($iSL ? "" : $aIniFile[$i + 3]) & $aIniFile[$i + 4] & ($iST ? "" : $aIniFile[$i + 5])) Next FileClose($hFileOpen) If $iReadOnly Then FileSetAttrib($sFilePath, "+R") Return 0 EndFunc ;==>__IniFileWriteEx ; #INTERNAL_USE_ONLY# =========================================================================================================== ; Name...........: __IniGetFileStringData ; Description ...: Support Function for _IniGetFileStringData ; Syntax.........: __IniGetFileStringData(ByRef $hIniFile, ByRef $iFlags, ByRef $aIniFile) ; Parameters ....: See _IniGetFileStringData() ; Return values .: See _IniGetFileStringData() ; Author ........: DXRW4E ; Modified.......: ; Remarks .......: This function is used internally by _IniGetFileStringData ; =============================================================================================================================== Func __IniGetFileStringData(ByRef $hIniFile, ByRef $iFlags, ByRef $aIniFile) Local $sData, $iSL = BitAND($iFlags, $INI_STRIPLEADING), $iST = BitAND($iFlags, $INI_STRIPTRAILING) Local $sData = ($iSL ? "" : $aIniFile[3]) & $aIniFile[4] & ($iST ? "" : $aIniFile[5]) For $i = 6 To $aIniFile[0] Step 6 $sData &= $aIniFile[$i] & $aIniFile[$i + 1] & $aIniFile[$i + 2] & ($iSL ? "" : $aIniFile[$i + 3]) & $aIniFile[$i + 4] & ($iST ? "" : $aIniFile[$i + 5]) Next Return $sData EndFunc ;==>__IniGetFileStringData ; #INTERNAL_USE_ONLY# =========================================================================================================== ; Name...........: __IniSaveCache ; Description ...: Save in Cache last Read Section ; Syntax.........: __IniSaveCache(ByRef $hIniFile, ByRef $sSectionData, ByRef $sSectionName, ByRef $iFlags, ByRef $iSectionName, ByRef $aIniFile) ; Parameters ....: $hIniFile - Handle to the INI file to query "see _IniOpenFileEx()" ; $sSectionData - Section Strings text/data ; $sSectionName - Section Name ; $iFlags - Section Flags ; $iSectionName - Number of SectionName in INI File ; $aIniFile - Array of INI File ; Return values .: None ; Author ........: DXRW4E ; Modified.......: ; Remarks .......: This function is Internal Only ; =============================================================================================================================== Func __IniSaveCache(ByRef $hIniFile, ByRef $sSectionData, ByRef $sSectionName, ByRef $iFlags, ByRef $iSectionName, ByRef $aIniFile) $_HINI[$hIniFile][7] = $sSectionName $_HINI[$hIniFile][8] = (BitAND($iFlags, $INI_MERGE_NOOCCURRENCE) = $INI_MERGE) ? 1 : $iSectionName $_HINI[$hIniFile][9] = $iFlags If $iSectionName > 1 And Not BitAND($iFlags, $INI_MERGE_NOOCCURRENCE) Then $aIniFile[1] = $sSectionData $_HINI[$hIniFile][10] = 1 Else $aIniFile[1] = "" $_HINI[$hIniFile][10] = $_HINI[$hIniFile][6] EndIf Return 0 EndFunc ;==>__IniSaveCache ; #INTERNAL_USE_ONLY# =========================================================================================================== ; Name...........: __GetSeparatorCharacter ; Description ...: Get Separator Character (non present character) ; Syntax.........: __GetSeparatorCharacter(ByRef $sData) ; Parameters ....: $sData - INI String\Text Data ; Return values .: None ; Author ........: DXRW4E ; Modified.......: ; Remarks .......: For Internal Use Only ; =============================================================================================================================== Func __GetSeparatorCharacter(ByRef $sData) If Not StringInStr($sData, ChrW(8232), 1) Then Return ChrW(8232) If Not StringInStr($sData, ChrW(8233), 1) Then Return ChrW(8233) For $i = 1 To 31 If $i > 8 And $i < 14 Then ContinueLoop If Not StringInStr($sData, Chr($i), 1) Then Return Chr($i) Next $sData = StringRegExpReplace($sData, '\r\n?', @LF) Return @CR EndFunc ;==>__GetSeparatorCharacter example #include <IniEx.au3> #include <Array.au3> Local $sData = @CRLF, $aData, $iData, $iTimerDiff, $hIniFile FileDelete(@DesktopDir & "\Test.ini") For $i = 1 To 10 $sData &= "[SectionName_" & $i & "]" & @CRLF For $y = 1 to 100000 $sData &= "KeyName" & $y & " = Value" & $y & @CRLF Next Next FileWrite(@DesktopDir & "\Test.ini", $sData) ;25 MB - 1.000.000 Line, Key-Value $sData = "" $iTimerDiff = TimerInit() ;;_IniOpenFileEx() $hIniFile = _IniOpenFileEx(@DesktopDir & "\Test.ini") If @Error Then ConsoleWrite("Error - " & @Error & @LF) Exit EndIf $iTimerDiff = TimerDiff($iTimerDiff) ConsoleWrite("_IniOpenFileEx TimerDiff - " & $iTimerDiff & @LF) $iTimerDiff = TimerInit() ;;_IniGetSectionNumberEx() $iData = _IniGetSectionNumberEx($hIniFile) If @Error Then ConsoleWrite("Error - " & @Error & @LF) Exit EndIf $iTimerDiff = TimerDiff($iTimerDiff) ConsoleWrite("IniGetSectionNumberEx TimerDiff - " & $iTimerDiff & @LF) ConsoleWrite("SectionNumber - " & $iData & @LF & @LF) $iTimerDiff = TimerInit() ;;_IniRenameSectionEx() _IniRenameSectionEx($hIniFile, "SectionName_10", "SectionName_111") If @Error Then ConsoleWrite("Error - " & @Error & @LF) Exit EndIf $iTimerDiff = TimerDiff($iTimerDiff) ConsoleWrite("IniRenameSectionEx TimerDiff - " & $iTimerDiff & @LF & @LF) $iTimerDiff = TimerInit() ;;_IniReadSectionNamesEx() $aData = _IniReadSectionNamesEx($hIniFile) If @Error Then ConsoleWrite("Error - " & @Error & @LF) Exit EndIf $iTimerDiff = TimerDiff($iTimerDiff) ConsoleWrite("IniReadSectionNamesEx TimerDiff - " & $iTimerDiff & @LF & @LF) _ArrayDisplay($aData) $iTimerDiff = TimerInit() ;;_IniReadSectionEx() $sData = _IniReadSectionEx($hIniFile, "SectionName_8") $iTimerDiff = TimerDiff($iTimerDiff) ConsoleWrite("IniReadSectionEx TimerDiff - " & $iTimerDiff & @LF & @LF) ;;ConsoleWrite($sData & @LF & @LF) ;;MsgBox(0, "SectionName_8", $sData) $iTimerDiff = TimerInit() ;;_IniReadSectionEx() $aData = _IniReadSectionEx($hIniFile, "SectionName_8", $INI_2DARRAYFIELD) ;$INI_NOOCCURRENCE + $INI_MERGE + $INI_2DARRAYFIELD $iTimerDiff = TimerDiff($iTimerDiff) ConsoleWrite("IniReadSectionEx TimerDiff - " & $iTimerDiff & @LF & @LF) _ArrayDisplay($aData, "IniReadSectionEx") $iTimerDiff = TimerInit() ;;_IniReadEx() $sData = _IniReadEx($hIniFile, "SectionName_8", "KeyName99980") $iTimerDiff = TimerDiff($iTimerDiff) ConsoleWrite("IniReadEx TimerDiff - " & $iTimerDiff& @LF) ConsoleWrite($sData & @LF & @LF) $iTimerDiff = TimerInit() ;;_IniReadEx() $aData = _IniReadEx($hIniFile, "SectionName_8", "KeyName99988", "Default Return", $INI_ARRAYDATA) ;$INI_NOOCCURRENCE + $INI_MERGE + $INI_ARRAYDATA $iTimerDiff = TimerDiff($iTimerDiff) ConsoleWrite("IniReadEx TimerDiff - " & $iTimerDiff & @LF) ConsoleWrite($aData[1] & @LF & @LF) _ArrayDisplay($aData, "IniReadEx") $iTimerDiff = TimerInit() ;;_IniDeleteEx() _IniDeleteEx($hIniFile, "SectionName_8", "KeyName99988") ;$INI_IGNOREDUPLICATE + $INI_NOOCCURRENCE + $INI_REMOVE $iTimerDiff = TimerDiff($iTimerDiff) ConsoleWrite("IniDeleteEx TimerDiff - " & $iTimerDiff & @LF & @LF) $iTimerDiff = TimerInit() ;;_IniWriteSectionEx() _IniWriteSectionEx($hIniFile, "SectionName_8", "KeyNameX = ValueX") ; $INI_NOOCCURRENCE + $INI_IGNOREDUPLICATE + $INI_MERGE + $INI_REMOVE + $INI_OVERWRITEALL + $INI_APPENDDATA $iTimerDiff = TimerDiff($iTimerDiff) ConsoleWrite("IniWriteSectionEx TimerDiff - " & $iTimerDiff & @LF & @LF) ConsoleWrite(_IniReadEx($hIniFile, "SectionName_8", "KeyNameX") & @LF) $iTimerDiff = TimerInit() For $i = 1 To 5 _IniWriteSectionEx($hIniFile, "SectionName_8", "KeyNameX" & $i & " = ValueX" & $i) Next For $i = 6 To 10 _IniWriteEx($hIniFile, "SectionName_8", "KeyNameX" & $i, "ValueX" & $i) Next $iTimerDiff = TimerDiff($iTimerDiff) ConsoleWrite("IniWrite*Ex TimerDiff - " & $iTimerDiff & @LF) $iTimerDiff = TimerInit() ;;_IniReadEx() For $i = 1 To 10 ConsoleWrite(_IniReadEx($hIniFile, "SectionName_8", "KeyNameX" & $i) & @LF) Next $iTimerDiff = TimerDiff($iTimerDiff) ConsoleWrite("IniReadEx TimerDiff - " & $iTimerDiff & @LF) _IniCloseFileEx($hIniFile) Exit ;~ >Running:(3.3.11.3):C:\Program Files (x86)\AutoIt3\Beta\autoit3.exe "C:\Users\DXRW4E\Desktop\New AutoIt v3 Script.au3" ;~ --> Press Ctrl+Alt+F5 to Restart or Ctrl+Break to Stop ;~ _IniOpenFileEx TimerDiff - 2656.48548057389 ;~ IniGetSectionNumberEx TimerDiff - 0.0343594296492653 ;~ SectionNumber - 10 ;~ ;~ IniRenameSectionEx TimerDiff - 0.204971769976651 ;~ ;~ IniReadSectionNamesEx TimerDiff - 0.0584505240010489 ;~ ;~ IniReadSectionEx TimerDiff - 6.80316707055452 ;~ ;~ IniReadSectionEx TimerDiff - 1831.04639075913 ;~ ;~ IniReadEx TimerDiff - 24.1380917325683 ;~ Value99980 ;~ ;~ IniReadEx TimerDiff - 111.67841469541 ;~ Value99988 ;~ ;~ IniDeleteEx TimerDiff - 43.9488700091941 ;~ ;~ IniWriteSectionEx TimerDiff - 28.2560891228314 ;~ ;~ ValueX ;~ IniWrite*Ex TimerDiff - 261.353224415258 ;~ ValueX1 ;~ ValueX2 ;~ ValueX3 ;~ ValueX4 ;~ ValueX5 ;~ ValueX6 ;~ ValueX7 ;~ ValueX8 ;~ ValueX9 ;~ ValueX10 ;~ IniReadEx TimerDiff - 261.622965684803 ;~ +>00:07:21 AutoIt3.exe ended.rc:0 ;~ >Exit code: 0 Time: 5.914 ; $INI_OPEN_FILEQUEUE (268435456) - Open INI file from Memory\Variable, $sFilePath must contain String Text Data of INI file $hIniFile = _IniOpenFileEx(@DesktopDir & "\Test.ini") ;ect ect ect ;or $hIniFile = _IniOpenFileEx($sData, $INI_OPEN_FILEQUEUE) ;ect ect ect ;Or direct mode, without load ini or using handles ; $sSectionName - The name of the section containing the Key\Value, This parameter can be NULL (use the $NULL_REF to set NULL this parameter) ; If $sSectionName is NULL, $hIniFile must be contain Section String\Key\Value\Data ;; _IniDeleteEx($hIniFile, $sSectionName, $sKeyName) _IniDeleteEx($sData, $NULL_REF, $sKeyName) ;$NULL_REF = NULL ;; _IniReadEx($hIniFile, $sSectionName, $sKeyName) _IniDeleteEx($sData, $NULL_REF, $sKeyName) ;$NULL_REF = NULL ;; _IniReadSectionEx($hIniFile, $sSectionName, $sKeyName) _IniReadSectionEx($sData, $NULL_REF, $sKeyName) ;$NULL_REF = NULL ;; _IniWriteEx($hIniFile, $sSectionName, $sKeyName, $sValue) _IniWriteEx($sData, $NULL_REF, $sKeyName, $sValue) ;$NULL_REF = NULL ;;ect ect ect So for all other functions IniEx.au3
-
Hi guys, I'm facing a problem that I can't solve, despite trying hard. I have an .ini file with several sections: [Latitude E5440] URL=http://downloads.dell.com/published/pages/latitude-e5440-laptop.html [Latitude E5450] URL=http://downloads.dell.com/published/pages/latitude-e5450-laptop.html [Latitude E5470] URL=http://downloads.dell.com/published/pages/latitude-e5470-laptop.html [Latitude E7240] URL=http://downloads.dell.com/published/pages/latitude-e7240-ultrabook.html [Latitude E7250] URL=http://downloads.dell.com/published/pages/latitude-e7250-ultrabook.html [Latitude E7270] URL=http://downloads.dell.com/published/pages/latitude-e7270-ultrabook.html Then I collect the computer model name and try to look if it exists in the ini file. But, when performing the search, I only got the index in the array. For example, my computer model is a "Latitude E7240". An "_ArraySearch" gives me "4" as a result and because this is also the fourth place of my search in the ini file. It works well if I move the section anywhere else in the file and always give me the correct position. Question is: How can I convert the index number to the section name so I can tell my script that if it's found in the ini file, the download URL variable will be set to the corresponding key in the ini file. Here's my code so far: Can someone give me an hand on this? Thanks -31290-
-
I have a custom configuration file which has key-value pairs as in below format. BuildLocation:C:\Build BuildExe:setup.exe Release:r9.64.02 Silent:No InstallPath:default Compare :No MartUpgrade :Yes Bit:64 ERwinUpgrade:No I need to change the value of "BuildExe" using my program. Is there any inbuilt function already available for these kind of files?. Can any one help me how to do this.
-
I've never worked with an array or dropdown menu before and I can't seem to wrap it around my head this morning. Maybe I just need more coffee but I'm trying to populate a GUI dropdown menu with section names of a .ini file. Here is what I have for this part but I don't know where to go from here. The msgbox thing was only testing it but I kinda got stuck here. local $aSectionnames = IniReadSectionNames(@DesktopDir & "\Scripts\BatteryConfig.ini") if Not @error Then For $i = 1 to $aSectionnames[0] MsgBox($MB_SYSTEMMODAL, "Test", $aSectionnames[$i]) Next EndIf Here is my very basic dropdown menu I want to populate #include <ButtonConstants.au3> #include <ComboConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 413, 213, 192, 124) $Combo1 = GUICtrlCreateCombo("Combo1", 80, 24, 241, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL)) $Button1 = GUICtrlCreateButton("Button1", 152, 56, 75, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Thanks!
-
Hello, I've writing this code and I'm a little stuck in what i want to do. When I select the combobox I want to get the ini information inside the multiline input field. I know that what I'm doing now is wrong but maybe this helps to clearify things in what I want to do. Does somebody knows how to do this , or can help me? #include <ButtonConstants.au3> #include <ComboConstants.au3> #include <GUIConstantsEx.au3> #include <TabConstants.au3> #include <File.au3> #include <WindowsConstants.au3> #include <MsgBoxConstants.au3> #include <Array.au3> #include <Date.au3> check_file_exist() $Form1 = GUICreate("Form1", 320, 260, 192, 324);(b,h,,),30 $Tab1 = GUICtrlCreateTab(5, 5, 310, 250) ;(,,b,h) $TabSheet3 = GUICtrlCreateTabItem("Edit") $Label_tab_select = GUICtrlCreateLabel("select", 40, 50, 80, 25) $tab_select = GUICtrlCreateCombo(" tab 1", 40, 70, 80, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL)) GUICtrlSetData(-1, " tab 2") $Label_BtnSelect = GUICtrlCreateLabel("nr", 125, 50, 80, 25) $BtnSelect = GUICtrlCreateCombo(" 1", 125, 70, 60, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL)) GUICtrlSetData(-1, " 2 ") $Label_BtnName = GUICtrlCreateLabel("name", 190, 50, 80, 25) $BtName = GUICtrlCreateInput("", 190, 70, 80, 21) $multiline = GuiCtrlCreateEdit("this text needs to be changed at selection of combobox",15, 105, 290, 110) ;the next line is to clearify things :) ;$multiline = GuiCtrlCreateEdit(IniRead($ini_location_buttons, "btn00" & GUICtrlRead($BtnSelect), "text"),15, 105, 290, 110) $Btn301 = GUICtrlCreateButton("Cancel", 40, 220, 75, 25) $Btn302 = GUICtrlCreateButton("Save", 152, 220, 75, 25) GUICtrlCreateTabItem("") GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Btn301 Exit Case $Btn302 Exit EndSwitch WEnd Func check_file_exist() If FileExists(@SCRIPTDIR & "\ini.ini") Then Global $ini_location_buttons = @SCRIPTDIR & "\ini.ini" Else If Not _FileCreate(@SCRIPTDIR & "\buttons.ini") Then MsgBox($MB_SYSTEMMODAL, "Error", " Error Creating/Resetting ini. error:" & @error) Else Global $ini_location_buttons = @SCRIPTDIR & "\ini.ini" create_new_ini() EndIf EndIf EndFunc Func create_new_ini() $file = FileOpen($ini_location_buttons, 1) Local $i = 1 local $j = 0 Do if $i = 10 then $j = "" FileWrite($file, "[btn0" & $j & $i & "]"& @CRLF) FileWrite($file, "button_name=Button " & $i & @CRLF) FileWrite($file, "text=lorum ipsum" & $i & @CRLF) $i = $i + 1 Until $i = 3 FileClose($file) EndFunc
-
hello, I am having an issue were I am trying to pull everything under a section in a INI file into a combobox.Issue I have is it only selects 2 out of the list. Not sure why func _ReadHistory() Local Const $sFilePath = "history1.ini" Local $iFileExists = FileExists($sFilePath) ; If the INI file is not found, output error message If not $iFileExists Then msgbox(0,"Oh NO!", $sFilePath & " not found!") endif Local $aArray = IniReadSection($sFilePath, "RemoteHistory") ; Start the array loop and run robocopy If Not @error Then for $i = 0 to $aArray[0][0] _GUICtrlComboBox_InsertString($rdesktopInput, $aArray[$i][1], 0) $i = $i +1 next endif endfuncINI FILE Example [RemoteHistory] HOST=12.12.12.12 HOST=127.0.0.1 HOST=10.10.10.1 HOST=192.168.1.1 HOST=0.0.0.0
-
Hi All, Here is a little GUI I built a while back to learn how to use INI files to store information ( variables ) between opening and closing certain programs. I just recently pulled it back out and cleaned it up and debugged it, if you find any bugs please kill them. The FTP connection part was just so it would have purpose... To cut down on clutter there are no labels, hover mouse over to see what things are. cya, Bill
-
Hello everyone. Been browsing around a little bit through the forum, my brain spinning with ideas that I'm planning out as im typing here, so if anyone thinks that I have not spent enough time searching for the answer in an archive somewhere, blame it on my excitement at getting back to my desktop before I forget wth I was going to do! I ve been taking my time with an application that Im writing, scrapping things as new ideas come. Cant explain why really, but ive always liked the idea of incorporating both batch and Autoit in my programs so that's been the case with everything ive done to date. Currently I'm trying to focus on finishing through to a final result, I guess you could call it a 'wysiwyg' html webpage and css creation utility. Its been run a hundred times or more and scrapped only to rewrite a few lines here and there due to my overactive brain matter. most of the code was done in batch . Interactive commandline, echoing tags and strings into files blah blah blah. The autoit portion comes as the Nice Gui interface with all the options for a webpage or css then once chosen the gui scribbles a couple of lines into a file where the batch code comes in, reads the file then executes predefined directives based on what was specified. My question I swear! I would really like to try out Autoit for the entire app from gathering the user specs to creation along with ini and maybe inf files. Is it possible for Autoit to read and execute from an .ini? Thanks] Sorry folks. Just scrolled down after posting and WAM, there by Golly were a bunch of 'related' topics on ini's! but Ill still take any new input/ideas thanks
- 4 replies
-
- ini
- iniread ini
-
(and 2 more)
Tagged with:
-
Hello, i have question. How to save and read data from "GUICtrlCreateEdit" to ini file ?. Problem is: IniWrite write only first line of text and IniRead read only first line text. How to do it? Thanks for answer. $text = GUICtrlCreateEdit("Text", 20, 165, 120, 50) Func save() Local $ini_file, $workingdir ; save workingdir $workingdir = @WorkingDir ; save file dialog $ini_file = FileSaveDialog('Save', @ScriptDir, 'Ini (*.ini)|All (*.*)', 10, 'Config.ini', $Form1) ; check if return is valid If @error Or $ini_file == '' Then FileChangeDir($workingdir) Return SetError(1, 0, '') EndIf ; write to ini file IniWrite($ini_file, "Data", "Text", GUICtrlRead($Text)) EndFunc$text = GUICtrlCreateEdit("Text", 20, 165, 120, 50) Func load() ;natiahne nastavenia z .ini Local $ini_file, $workingdir ; save workingdir $workingdir = @WorkingDir ; open file dialog $ini_file = FileOpenDialog('Open', @ScriptDir, 'Ini (*.ini)|All (*.*)', 1, 'Config.ini', $Form1) ; check if return is valid If @error Or $ini_file == '' Then FileChangeDir($workingdir) Return SetError(1, 0, '') EndIf ; read from ini file GUICtrlSetData($text, IniRead($ini_file, "Data", "Text", "")) EndFuncThis not working, read and write only firt line