Jump to content

Determining listview column count based on data in ini file


Recommended Posts

Hello,
The "|" read in Value07 that I want to do about the code and sample ini file I shared. by finding the total of each data number between and creating columns in the form of R-001, R002 as much as this number, and writing each data in these columns, and writing this total value in the last total column.
The number of data in Value07 can be variable, that is, "1" or "40". But other than that, Value01, 02, 03 ,04, 05, 06 are all single values.
Thanks in advance to anyone who can help with this.

#include <File.au3>
#include <Array.au3>
#include <GUIConstants.au3>

Global $aArr, $aSect = ""
$File = FileOpenDialog("Select ini file", @ScriptDir&"\", "(*.ini)")
_FileReadToArray($File, $aArr)

$gui = GUICreate("ListView", 800, 300, 80, 5)
$Lview = GUICtrlCreateListView("DATE&VALUE|R-001|R-002|R-003|R-004|R-005|R-006|R-007|R-008|R-009|R-010|TOTAL", 10, 10, 780, 280)
GUICtrlSetState($Lview, $GUI_DROPACCEPTED)
GUISetState()

For $i = 1 To $aArr[0] Step 1
   GUICtrlCreateListViewItem($aArr[$i], $Lview)
Next
GUICtrlSendMsg($Lview, $LVM_SETCOLUMNWIDTH, 0, 100)

Do
    $msg = GUIGetMsg()
Until $msg = $GUI_EVENT_CLOSE
Quote

[18.08.2023]
Value01=Chıcken Doner
Value02=Rice
Value03=Coke
Value04=PC-KITCHEN
Value05=Administrator
Value06=18.08.2023 16:31:18
Value07=Micheal|Harry|Claire|Leon|Chris|Alice|Jill|Ashley

18.08.2023.ini file content

Link to comment
Share on other sites

if I understood correctly   :unsure:

#include <File.au3>
#include <Array.au3>
#include <GUIConstants.au3>

Global $aArr, $aSect = ""
$File = FileOpenDialog("Select ini file", @ScriptDir&"\", "(*.ini)")
_FileReadToArray($File, $aArr)

$aVal7 = StringSplit($aArr[8], "=")
$aVal7 = StringSplit($aVal7[2], "|")
ConsoleWrite("$aVal7[0]=" & $aVal7[0] & @CRLF)

$aArr[8] = StringStripWS(StringReplace($aArr[8], "=", "=|"), 3) & "|" & $aVal7[0]
ConsoleWrite("$aArr[8]=" & $aArr[8] & @CRLF)

$sHeader = ""
For $i = 1 To $aVal7[0]
    $sHeader &= "R-" & StringFormat("%03i", $i) & "|"
Next
ConsoleWrite("$sHeader=" & $sHeader & @CRLF)

$GuiData = "DATE&VALUE|" & $sHeader & "TOTAL"

$gui = GUICreate("ListView", 800, 300, 80, 5)
$Lview = GUICtrlCreateListView($GuiData, 10, 10, 780, 280)
GUICtrlSetState($Lview, $GUI_DROPACCEPTED)
GUISetState()

For $i = 1 To $aArr[0] Step 1
   GUICtrlCreateListViewItem($aArr[$i], $Lview)
Next
GUICtrlSendMsg($Lview, $LVM_SETCOLUMNWIDTH, 0, 100)

Do
    $msg = GUIGetMsg()
Until $msg = $GUI_EVENT_CLOSE

 

Edited by ioa747
add StringStripWS

I know that I know nothing

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