Jump to content

Implementing a data structure


Recommended Posts

  • Moderators

dushkin,

Looks like an ini file will suffice: :)

[Item 1]
Key=Val
Key=Val
Key=Val
Key=Val
[Item 2]
Key=Val
Key=Val
[Item 3]
Key=Val
Key=Val
Key=Val
M23

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:

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

 

Link to comment
Share on other sites

  • Moderators

dushkin,

I see. Then perhaps an array of arrays: :)

; 3 "Item"s
$aData_Outer[4]

; Now add the "Key/Val" pairs as arrays held within each item
$aData_Outer[1] = $aData_Inner_1[5][2]
;$aData_inner_1[1][0] = Key1
$aData_inner_1[1][1] = Value1
$aData_inner_1[2][0] = Key2
$aData_inner_1[2][1] = Value2
$aData_inner_1[3][0] = Key3
$aData_inner_1[3][1] = Value3
$aData_inner_1[4][0] = Key4
$aData_inner_1[5][1] = Value4
;
$aData_Outer[2] = $aData_Inner_2[3][2]
$aData_inner_2[1][0] = Key1
$aData_inner_2[1][1] = Value1
$aData_inner_2[2][0] = Key2
$aData_inner_2[2][1] = Value2
;
$aData_Outer[3] = $aData_Inner_1[4][2]
$aData_inner_3[1][0] = Key1
$aData_inner_3[1][1] = Value1
$aData_inner_3[2][0] = Key2
$aData_inner_3[2][1] = Value2
$aData_inner_3[3][0] = Key3
$aData_inner_3[3][1] = Value3
M23

;

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:

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

 

Link to comment
Share on other sites

Melba - Thanks. I will considerate it.

Pinco - suppose I want to read from a file that holds the list of all car vendors that sells in a certain country, and then the models and their prices.

So, for example:

Honda

Civic-50000

Toyota

Corolla - 40000

Yaris - 25000

Hyundai

i30-30000

i35-40000

etc.

The number of the vendors and the models are unknown, unless I perform 2 passes on the file (and I prefer not to)

Thanks.

Edited by dushkin
Link to comment
Share on other sites

Thanks Firefox. It is an HTML. The values are not in english, and even not in latin charachters :-)

Will it still be helpfull?

Aren't the concept and the example clear enough?

Edited by dushkin
Link to comment
Share on other sites

An array example was given to you, which is exactly what you're looking for.

For the unknown count, use ReDim if necessary with a step; but since it's a html, I'm not sure it will be necessary.

I asked you this if you want us to build you a full working example.

Br, FireFox.

Edited by FireFox
Link to comment
Share on other sites

Melba - Thanks. I will considerate it.

Pinco - suppose I want to read from a file that holds the list of all car vendors that sells in a certain country, and then the models and their prices.

So, for example:

Honda

Civic-50000

Toyota

Corolla - 40000

Yaris - 25000

Hyundai

i30-30000

i35-40000

etc.

The number of the vendors and the models are unknown, unless I perform 2 passes on the file (and I prefer not to)

Thanks.

 

something like this could do

#include <File.au3>
#include <array.au3>
Local $output[1][2], $x = 0, $i
Local $aArray
_FileReadToArray(".\data.txt", $aArray)
; _ArrayDisplay($aArray)
For $i = 1 To $aArray[0]
    ; check for empty lines
    If StringStripWS(StringStripCR($aArray[$i]), 7) <> "" Then
        If Not StringInStr($aArray[$i], "-") Then
            ReDim $output[UBound($output)][$x + 2]
            $output[0][$x] = StringStripWS($aArray[$i], 3)
            $x += 2 ; will be next column
            $y = 1
        Else
            If $y = UBound($output) Then
                ReDim $output[UBound($output) + 1][UBound($output, 2)]
            EndIf
            $temp = StringSplit($aArray[$i], "-", 2)
            $output[$y][$x - 2] = StringStripWS($temp[0], 3)
            $output[$y][$x - 1] = StringStripWS($temp[1], 3)
            $y += 1
        EndIf
    EndIf
Next
_ArrayDisplay($output)

anyway, if data is on an internet site, then you could grab data directly from the web page using _ie* function instead of pass through disk files

Bye

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

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

×
×
  • Create New...