Jump to content
Sign in to follow this  

IniWriteSection "Invalid Data Type"

Recommended Posts


My first question before I start posting code and whatnot, is on the IniWriteSection the Failure returns 0 and sets @error to 1 for an invalid data type. Can anyone help me figure out what this certain invalid data type is, because the helpfile does not explain this is huge detail (I'm passing a 2d array with key value pairs).

Edited by JonBMN

Share this post

Link to post
Share on other sites


The Help file defines the required data pretty clearly as:


"The data to write. The data can either be a string or an array. If the data is a string, then each key=value pair must be delimited by @LF. If the data is an array, the array must be 2-dimensional and the second dimension must be 2 elements."

So it is either:

"key1=value1" & @LF & "key2=value2" & @LF & "key3=value3"
or an array

[[key1, value1], [key2, value2], [key3, value3]]
If what are you using as data does not match one of those two requirements, it is invalid. What are you trying to use? :huh:


Edit: I have just seen your edit - how do you construct this 2D array?

Edited by Melba23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:


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


Share this post

Link to post
Share on other sites

I figured it out, I had been trying to write values with a 2d array like so:



Come to find out I had been trying to use a 2d array with:



That was what was creating the invalid data type error.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Similar Content

    • VollachR
      By VollachR
      I'm creating a tool to edit some ini files that belong to a program I'm working on...
      Basically everything work fine except I can't find a way to check if the if the WriteIniSection operation was successful...
      For Example, let's say the INI file is by mistake or some other reason Read Only, or the user don't have the right permission to write to the file or the folder it's in... Right now, in such a case The INI file, as expected, won't get updated, but I when I perform an if error or if not error checks I always get the msgbox for the if not error.
      Here's the relevant code part:
      IniWriteSection(@ScriptDir & "\Settings\Settings.ini", "Conversion", $aConversion, 1) IniWriteSection(@ScriptDir & "\Settings\Settings.ini", "AIO", $aAIO, 1) IniWriteSection(@ScriptDir & "\Settings\Settings.ini", "Data", $aData, 1) IniWriteSection(@ScriptDir & "\Settings\Settings.ini", "Redist", $aRedist, 1) IniWriteSection(@ScriptDir & "\Settings\Settings.ini", "Split", $aSplit, 1) IniWriteSection(@ScriptDir & "\Settings\Settings.ini", "Autorun", $aAutorun, 1) If Not @error Then MsgBox($MB_ICONINFORMATION, "Success", "Settings.ini Saved Successfully") Else If @error Then MsgBox($MB_ICONERROR, "Failure", "Settings.ini Could Not Be Saved!" & @CRLF & @CRLF & "Please Check If The File Is ReadOnly And That You Have Permission To Change It Or Its Location") EndIf EndIf  
      How can I perform a check to see if the ini file was written to successfully?
    • Jibsbrown
      By Jibsbrown
      Hope someone can find what I've done wrong, because I have no idea. I'm sure its very simple fix.
      Currently after selecting the folder for files the Listview the path is recorded in the INI file this which works. After submitting the ListView changes with the loop the INI file is over written and the file section name is not being written.
      Any idea or examples for the solution? Forma searches and help file have not provided the answer(s). Or I'm just not seeing my mistake, which I'm sure is the real problem.
      #RequireAdmin #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Add_Constants=n #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** ; *** Start added by AutoIt3Wrapper *** #include <FileConstants.au3> #include <MsgBoxConstants.au3> ; *** End added by AutoIt3Wrapper *** #include <Array.au3> #include <File.au3> #include <FileConstants.au3> #include <ListViewConstants.au3> #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <WindowsConstants.au3> #include <GUIListViewEx.au3> ;User choses folder path Global $Path = FileSelectFolder("Select Upadates Folder", @ScriptDir) $upsPath = $Path ;MsgBox(0, "", $Path, 5) $fUpsList = "InstallList.ini" FileOpen($fUpsList) IniWriteSection($fUpsList, "Path", $Path) FileClose($fUpsList) Global $aUpdates = _FileListToArrayRec($Path, "*.*", $FLTAR_FILES) ; All files in folder loaded into array for LV $sFileCount = $aUpdates[0] ; Use file count for error checking - not added yet 3/29 ConsoleWrite($sFileCount & @CRLF) #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 615, 482, -1, -1) $Group1 = GUICtrlCreateGroup("Group1", 40, 24, 400, 377) $List1 = GUICtrlCreateListView("Update Files", 48, 72, 385, 305) _GUICtrlListView_SetColumnWidth($List1, 0, 385) $Submit = GUICtrlCreateButton("Submit", 400, 424, 75, 25) $Exit = GUICtrlCreateButton("Exit", 504, 424, 75, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### For $i = 1 To UBound($aUpdates) - 1 GUICtrlCreateListViewItem($aUpdates[$i], $List1) Next GUISetState() $lUps = _GUIListViewEx_Init($List1, $aUpdates, 0, 0, True) _GUIListViewEx_MsgRegister() While 1 $vRet = _GUIListViewEx_EventMonitor() ; Reread GLVEx Help doc If @error Then MsgBox($MB_SYSTEMMODAL, "Error", "Event error: " & @error) EndIf Switch @extended Case 0 Case 4 EndSwitch $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Submit $aContent = _GUIListViewEx_ReturnArray($lUps) _FileWriteFromArray($fUpsList, $aContent) ;this $error check returns 5 - Start index is greater than the $iUbound parameter ;So if the list is empty, it returns error 5 If @error = 5 Then FileOpen($fUpsList) IniWriteSection($fUpsList, "InstallOrder", "") FileClose($fUpsList) EndIf Exit Case $Exit Exit EndSwitch WEnd  
    • hackersarchangel
      By hackersarchangel
      Ok so here's my "evil plan" lol: I am working on making a test to help me study for the A+. The idea is that I want to make it modular so I can specify a battery of tests.

      My bright idea was to make an ini file generator, since that has built functions and a method for sorting. The generator is mostly done, it's a basic one to make multiple choice questions. Here's the tricky bit: I want to be able to mark each answer with 1, 2, 3, and 4 so I can then have the test program grab the answers at random, but still relevant to each question, and not show the numbers so it's harder to tell which ones are which.


      Q. Who founded Apple Computer, Inc?
      1) Steve Ballmer
      2)Steve Jobs and Steve Wozniak
      3) Bill Gates and Steve Jobs
      4) Tom Petty and the Heartbreakers

      but have that be in a different order everytime I take the test, so I can't cheat even though I'm writing the test lol. I have that figured out as far as how it's organized with the questions, just need to figure out how to grab the questions and answers, but do it in a way that it's not seen in the test, so I can randomize them. So far I'm sure I can randomize the question order, but still not sure on how to keep it from repeating a question.

      Here's my code so far for the ini generator, the Test portion I'll be working on as soon as I can think of a way to have it pick a question at random. Partially why I'm here

      #include <GUIConstantsEx.au3> ;Constants for GUI Events #include <WindowsConstants.au3> Global $Answer, $Answer_input[4], $counter = 0, $Build_bttn, $Question, $Question_input _Create_GUI() Func _Create_GUI() ;To implement a reset function, make everything in the GUI first, THEN put all the case stuff inside ;_Main(). HotKeySet("{F3}","_Main") ;A program reset switch, in case a function gets funky and doesn't process right. GUICreate("Question and Answer Generator Version 0.1",640,480) ;The code for adding questions and answers to the .ini file. $Question_input = GUICtrlCreateEdit("Question goes here",45,45, 250, 75) $Answer_input[0] = GUICtrlCreateInput("1)", 45, 150, 300, 20) $Answer_input[1] = GUICtrlCreateInput("2)", 45, 175, 300, 20) $Answer_input[2] = GUICtrlCreateInput("3)", 45, 200, 300, 20) $Answer_input[3] = GUICtrlCreateInput("4)", 45, 225, 300, 20) $Build_bttn = GUICtrlCreateButton("Add to File", 525,440) _Main() EndFunc Func _Main() GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $Gui_Event_Close Exit Case $Build_bttn $Question = GUICtrlRead($Question_input) $Answer = GUICtrlRead($Answer_input[0]) & @LF & GUICtrlRead($Answer_input[1]) & @LF & GUICtrlRead($Answer_input[2]) & @LF & GUICtrlRead($Answer_input[3]) If ($counter) < 10 Then $counter = $counter+1 IniWrite("AlphaTest.ini","Questions","Question_" & $counter, $Question) IniWriteSection("AlphaTest.ini","Answer_" & $counter,$Answer) EndIf EndSwitch WEnd EndFunc
      I understand this is a complicated project, one I'm willing to share back with the community of course since the idea is to make it a simple generator and then just point the Test exe to the q&a file