Jump to content
Starstar

How can i get total of all keys of IniReadSection?

Recommended Posts

Starstar

 

For $i = 1 To 1000
$List = IniReadSection(@DesktopDir&"\AllsaleAmount.ini","DATA")
$Total = $List[1][1] ++ $List[1][$i]
Next
MsgBox(0,"total",$Total)

 

I am trying like this but i got error( Array variable has incorrect number of subscripts or subscript dimension range exceeded.:
$Total = $List[1][1] ++ $List[1][$i]) in console.

Edited by Starstar

Life is like a coin. You can spend it Anyway as you wish and for your kind information. "you can spend it only once."

Share this post


Link to post
Share on other sites
JLogan3o13

Can you please provide an example of what info out of the INI you're trying to get? Rather than the $i = 1 To 1000 route, why not use the 2d array returned from IniReadSection directly? $List[0][0] will tell you how many elements you have, And it is always in a key/value pair - [$i][0] = Key and [$i][1] = Value.

 

If you need to stick with this method, change your $List[1][$i] call around; the way you have it written, you would be looking for $List[1][999] at some point, which isn't going to exist of course.

  • Like 1

√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites
Melba23

Starstar,

From the Help file for IniReadSection:

The number of elements returned will be in $aArray[0][0]

M23

  • Like 1

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

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
JLogan3o13

Ha! 6 years and I finally beat you lol

  • Like 1

√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites
Melba23

JLogan3o13,

My most hearty congratulations on your achievement.

M23

  • Like 1

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

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
Starstar

Melba23

i want to get total value amount? not how many keys are written.


Life is like a coin. You can spend it Anyway as you wish and for your kind information. "you can spend it only once."

Share this post


Link to post
Share on other sites
Melba23

Starstar,

Assuming all the elements are numeric, you can do it like this:

$Total_Keys = 0
$Total_Values = 0
$List = IniReadSection(@DesktopDir & "\AllsaleAmount.ini", "DATA")
For $i = 1 To $List[0][0]
    $Total_Keys += $List[$i][0]
    $Total_Values += $List[$i][1]
Next
MsgBox(0, "total", $Total_Keys & @CRLF & $Total_Values)

M23

  • Like 1

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

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
Starstar

Starstar,

Assuming all the elements are numeric, you can do it like this:

$Total_Keys = 0
$Total_Values = 0
$List = IniReadSection(@DesktopDir & "\AllsaleAmount.ini", "DATA")
For $i = 1 To $List[0][0]
    $Total_Keys += $List[$i][0]
    $Total_Values += $List[$i][1]
Next
MsgBox(0, "total", $Total_Keys & @CRLF & $Total_Values)

M23

​Thanks to all and special thanks to Melba23 problem solved.........


Life is like a coin. You can spend it Anyway as you wish and for your kind information. "you can spend it only once."

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

×