Jump to content

view the data of multiple sections in an INI


gcue
 Share

Recommended Posts

hello..

i have an INI that looks like this...

[TASK_TYPES]

Desktop Support=DSKSPT

General Admin=ADMIN-1

Mobile Support=MOBDEVSPT

[02/05/2009]

Thursday,February 05,2009=-

Desktop Support=00:05:00

Mobile Support=00:02:00

[02/04/2009]

Wednesday, February 04, 2009=-

Mobile Support=00:02:00

Desktop Support=00:05:00

i would like to view an _arraydisplay of all the sections EXCEPT "TASK_TYPES"

not sure what im doing wrong-here's what i have so far...

Local $temp_sum
    
    $temp_sum = IniReadSectionNames($tINI)
    If @error Then
        MsgBox(0, "Summary", "No time entries have been entered.")
        Return
    Else
        For $i = 1 To $temp_sum[0]
            $summary = IniReadSection($tINI, $temp_sum[$i])
            _ArrayConcatenate($summary, $temp_sum)
            _ArrayDelete($summary, $temp_sum)
        Next
        _ArrayDisplay($summary, "Summary")
    EndIf
Edited by gcue
Link to comment
Share on other sites

Where is $temp_sum[0] being assigned?

hello..

i have an INI that looks like this...

i would like to view an _arraydisplay of all the sections EXCEPT "TASK_TYPES"

not sure what im doing wrong-here's what i have so far...

Local $temp_sum
    
    $temp_summary = IniReadSectionNames($tINI)
    If @error Then
        MsgBox(0, "Summary", "No time entries have been entered.")
        Return
    Else
        For $i = 1 To $temp_sum[0]
            $summary = IniReadSection($tINI, $temp_sum[$i])
            _ArrayConcatenate($summary, $temp_sum)
            _ArrayDelete($summary, $temp_sum)
        Next
        _ArrayDisplay($summary, "Summary")
    EndIf
Link to comment
Share on other sites

Hi,

you have more problems. _ArrayConcatenate($summary, $temp_sum) works only with 1 dimension arrays, you got a two dimension.

If your ini file would look like, how it should:

[TASK_TYPES]

Desktop Support=DSKSPT

General Admin=ADMIN-1

Mobile Support=MOBDEVSPT

[02/05/2009]

Date=Thursday,February 05,2009=-

Desktop Support=00:05:00

Mobile Support=00:02:00

[02/04/2009]

Date=Wednesday, February 04, 2009=-

Mobile Support=00:02:00

Desktop Support=00:05:00

then:

#include <Array.au3>

$tINI = "c:\test.ini"
$temp_summary = IniReadSectionNames($tINI)
$f = $temp_summary [0]
local $summary [$f] [4]
$f = 1
For $i = 1 To $temp_summary[0]
    If StringInStr ($temp_summary [$i], "/") Then
        $summary [$f] [0] = $temp_summary[$i]
        $summary [$f] [1] = IniRead ($tINI, $temp_summary[$i], "Date", "Key not found")
        $summary [$f] [2] = IniRead ($tINI, $temp_summary[$i], "Desktop Support","Key not found")
        $summary [$f] [3] = IniRead ($tINI, $temp_summary[$i], "Mobile Support","Key not found")
        $f = $f + 1
    Else
        ContinueLoop
    EndIf
Next
_ArrayDisplay($summary, "Summary")
Link to comment
Share on other sites

Or (modified 99ojo's code):

#include <Array.au3>

$tINI = "c:\test.ini"
$temp_summary = IniReadSectionNames($tINI)
$f = $temp_summary [0]
local $summary [$f] [4]
$f = 1
For $i = 1 To $temp_summary[0]
    ; If StringInStr ($temp_summary [$i], "/") Then
    If $temp_summary [$i]<>"TASK_TYPES" Then
        $summary [$f] [0] = $temp_summary[$i]
        $summary [$f] [1] = IniRead ($tINI, $temp_summary[$i], "Date", "Key not found")
        $summary [$f] [2] = IniRead ($tINI, $temp_summary[$i], "Desktop Support","Key not found")
        $summary [$f] [3] = IniRead ($tINI, $temp_summary[$i], "Mobile Support","Key not found")
        $f = $f + 1
    ;Else
    ;   ContinueLoop
    EndIf
Next
_ArrayDisplay($summary, "Summary")

Link to comment
Share on other sites

not sure what im doing wrong-here's what i have so far...

First of all in _ArrayDelete($summary, $temp_sum) you should specify the element, not the whole array :)

And you trying to add a 1-dimentional array to a 2-dimentional, it will not work like this.

Try this:

#include <Array.au3>

$tINI = "Test.ini"

$aSectionNames = IniReadSectionNames($tINI)
Dim $aSummary_Sections[1000][3]

If @error Then
    MsgBox(64, "Summary", "No time entries have been entered.")
    ;Return
Else
    For $i = 1 To $aSectionNames[0]
        If $aSectionNames[$i] = "TASK_TYPES" Then ContinueLoop
        
        $aReadSection = IniReadSection($tINI, $aSectionNames[$i])
        If @error Then ContinueLoop
        
        For $j = 1 To $aReadSection[0][0]
            $aSummary_Sections[0][0] += 1
            
            $aSummary_Sections[$aSummary_Sections[0][0]][0] = $aReadSection[$j][0]
            $aSummary_Sections[$aSummary_Sections[0][0]][1] = $aReadSection[$j][1]
            $aSummary_Sections[$aSummary_Sections[0][0]][2] = $aSectionNames[$i]
        Next
    Next
    
    ReDim $aSummary_Sections[$aSummary_Sections[0][0]+1][3]
    
    ;$Arr[0][0] is the elements count
    ;$Arr[N][0] is the Key Name
    ;$Arr[N][1] is the Key Value
    ;$Arr[N][2] is the Section Name for current key
    _ArrayDisplay($aSummary_Sections, "Summary") 
EndIf

 

Spoiler

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

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

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

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

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

* === My topics === *

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

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

Or (modified 99ojo's code):

#include <Array.au3>

$tINI = "c:\test.ini"
$temp_summary = IniReadSectionNames($tINI)
$f = $temp_summary [0]
local $summary [$f] [4]
$f = 1
For $i = 1 To $temp_summary[0]
    ; If StringInStr ($temp_summary [$i], "/") Then
    If $temp_summary [$i]<>"TASK_TYPES" Then
        $summary [$f] [0] = $temp_summary[$i]
        $summary [$f] [1] = IniRead ($tINI, $temp_summary[$i], "Date", "Key not found")
        $summary [$f] [2] = IniRead ($tINI, $temp_summary[$i], "Desktop Support","Key not found")
        $summary [$f] [3] = IniRead ($tINI, $temp_summary[$i], "Mobile Support","Key not found")
        $f = $f + 1
    ;Else
    ;   ContinueLoop
    EndIf
Next
_ArrayDisplay($summary, "Summary")
:)
Link to comment
Share on other sites

mr creator, how can i get rid of the 3rd column?

other than that - it looks great!!

i commented this line but still get an empty column

;$aSummary_Sections[$aSummary_Sections[0][0]][2] = $aSectionNames[$i]

many thanks!

Edited by gcue
Link to comment
Share on other sites

MC just stuck the redim at the end of the loop as an optional cleanup to free up the unused portion of the 1000 elements he iniitially allocated. So, of course, to keep things clean, you'd want to decrease the second subscript of the first dim statement to 2 as well.

Link to comment
Share on other sites

#include <Array.au3>

$tINI = "Test.ini"

$aSectionNames = IniReadSectionNames($tINI)
Dim $aSummary_Sections[1000][2]

If @error Then
    MsgBox(64, "Summary", "No time entries have been entered.")
    ;Return
Else
    For $i = 1 To $aSectionNames[0]
        If $aSectionNames[$i] = "TASK_TYPES" Then ContinueLoop
        
        $aReadSection = IniReadSection($tINI, $aSectionNames[$i])
        If @error Then ContinueLoop
        
        For $j = 1 To $aReadSection[0][0]
            $aSummary_Sections[0][0] += 1
            
            $aSummary_Sections[$aSummary_Sections[0][0]][0] = $aReadSection[$j][0]
            $aSummary_Sections[$aSummary_Sections[0][0]][1] = $aReadSection[$j][1]
        Next
    Next
    
    ReDim $aSummary_Sections[$aSummary_Sections[0][0]+1][2]
    
    ;$Arr[0][0] is the elements count
    ;$Arr[N][0] is the Key Name
    ;$Arr[N][1] is the Key Value
    _ArrayDisplay($aSummary_Sections, "Summary") 
EndIf

Edited by MrCreatoR

 

Spoiler

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

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

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

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

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

* === My topics === *

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

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

hello...

this is working great!! thanks again!

would it be at all possible to pull in the IDs that are being referenced in "TASK TYPES" ?

currently heres what a value looks like

[2]|General Admin|00:30:00

in the "TASK_TYPES" section (as shown in my first post) General Admin=ADMIN-1

so i'd like the array display to look like this if possible

[2]|General Admin|ADMIN-1|00:30:00

many thanks!

Link to comment
Share on other sites

hello...

this is working great!! thanks again!

would it be at all possible to pull in the IDs that are being referenced in "TASK TYPES" ?

currently heres what a value looks like

[2]|General Admin|00:30:00

in the "TASK_TYPES" section (as shown in my first post) General Admin=ADMIN-1

so i'd like the array display to look like this if possible

[2]|General Admin|ADMIN-1|00:30:00

many thanks!

I am not sure i following... You want to add the first «key=value» of «TASK TYPES» section to each key in other sections? show the whole output that should be displayed in the array.

 

Spoiler

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

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

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

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

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

* === My topics === *

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

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

here's what the current arraydisplay looks like:

http://www.postimage.org/image.php?v=Pq1jZJLS

here's the INI that it comes from:

http://www.postimage.org/image.php?v=aV1fsPLr

for example, i would like to insert the value of General Admin found in the "TASK_TYPES" section above into the arraydisplay

so that it looks like this:

General Admin (entry from [02/08/2009]) | ADMIN-1 (references "General Admin" in "TASK_TYPES" to get this value | 00:30:00 (entry from [02/08/2009])

essentially the first and the 3rd column remain the same but i want to add the one in the middle...

hope this makes sense!!!

thanks again =)

Link to comment
Share on other sites

Like this:

#include <Array.au3>

$tINI = "Test.ini"

$aSectionNames = IniReadSectionNames($tINI)
Dim $aSummary_Sections[1000][3]

If @error Then
    MsgBox(64, "Summary", "No time entries have been entered.")
    ;Return
Else
    For $i = 1 To $aSectionNames[0]
        If $aSectionNames[$i] = "TASK_TYPES" Then ContinueLoop
        
        $aReadSection = IniReadSection($tINI, $aSectionNames[$i])
        If @error Then ContinueLoop
        
        For $j = 1 To $aReadSection[0][0]
            $aSummary_Sections[0][0] += 1
            
            $aSummary_Sections[$aSummary_Sections[0][0]][0] = $aReadSection[$j][0]
            $aSummary_Sections[$aSummary_Sections[0][0]][1] = IniRead($tINI, "TASK_TYPES", $aReadSection[$j][0], "")
            $aSummary_Sections[$aSummary_Sections[0][0]][2] = $aReadSection[$j][1]
        Next
    Next
    
    ReDim $aSummary_Sections[$aSummary_Sections[0][0]+1][3]
    
    ;$Arr[0][0] is the elements count
    ;$Arr[N][0] is the Key Name
    ;$Arr[N][1] is the Key Value from "TASK_TYPES" section
    ;$Arr[N][2] is the Key Value from current section
    _ArrayDisplay($aSummary_Sections, "Summary") 
EndIf

?

 

Spoiler

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

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

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

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

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

* === My topics === *

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

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

Create an account or sign in to comment

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

Create an account

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

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

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