Sign in to follow this  
Followers 0
junkew

Treeview/listview linked to an (file) array updating

7 posts in this topic

#1 ·  Posted (edited)

I am looking for a good direction on how to solve the following problem (for a keyword testdriving file)

Edit: Alternative sample of usage: How to keep an AU3 source code file in sync while editing functions in treeview (hiding comments)?

How can I keep a treeview in sync with an array filled with a text file?

Treeview will be in a form with an add, delete button

Treeview is not the problem (multiple examples found on the forum)

Problem/solution is more

--keeping the array in sync (at a reasonable speed) and if I should use array or datadictionary object

--Finally having multiple files with keyword definitions

Details

1. I have a textfile

-- where some lines are commented out by having a ; sign in the beginning

-- The consecutive lines can have a hierarchical relationship for example

File looks something like this

;This is a text file with some keywords
;Keyword 1 is to open the browser
keyword keyword1 having parameters a, b, c
parameter a is a window := [TITLE:Rekenmachine]
parameter b is a control := [CLASS:Button; ID:81]
parameter c is a control := [CLASS:Button; ID:82]
;Keyword 2 is to logon 
keyword keyword2 having parameters d,e
; Keyword 3 is a combination of keyword 1 and keyword 2
keyword keyword3 calls keyword1, keyword2

2. I will load this

a. into an array (just all lines from the textfile)

b. want to load this into a treeview

-- Some logic, when its a parameter then its a new subtree

-- when its a keyword calling other keywords its a new subtree (an if clicked on it it will jump to other part in treeview)

c. Beeing able to add in the treeview a new keyword, parameter

Edited by junkew

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

you can make it as an INI file that's how you can use comments without having to leave it manually on reading by FileRead and by using INI Read Section you will out the value automatically into array , then with a for next loop you can add the treeviewitems , i can make you an example if you want

Edited by komalo

[font="Palatino Linotype"][size="3"]AutoIt Script Examples :[/size][/font][font="Palatino Linotype"][size="3"]_CaptureBehindWindowGlass CMD for Windows Vista/Seven[/size][/font][left][/left][font="Palatino Linotype"][size="3"]Non AutoIt Script programs : Border Skin - Aero Glass On XP[/size][/font]

Share this post


Link to post
Share on other sites

After updating the treeview by adding new elements I need to write the file back (including the comments as there where originally in the file).

INI files are hard in my belief as the following can happen

;my comment on keyword 1

keyword 1

parameter a

parameter b

;my comment on keyword 2

keyword 2

After editing in the treeview and saving the file should look like below

;my comment on keyword 1

keyword 1

parameter a

parameter b

parameter c

;my comment on keyword 2

keyword 2

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

well the comments are not affected when using IniWrite

example - that's your ini

;some comments
[BrowserOpen]
WindowTitle = [TITLE:Rekenmachine]
ControlClass1 = [CLASS:Button; ID:81]
ControlClass2 = [CLASS:Button; ID:82]

[Logon]
Username = admin
Password = pass

when using the iniwrite function like this

IniWrite("File.ini","BrowserOpen","WindowTitle","aaaa")

the result will be

;some comments

[browserOpen]

WindowTitle =aaaa

ControlClass1 = [CLASS:Button; ID:81]

ControlClass2 = [CLASS:Button; ID:82]

[Logon]

Username = admin

Password = pass

Edited by komalo

[font="Palatino Linotype"][size="3"]AutoIt Script Examples :[/size][/font][font="Palatino Linotype"][size="3"]_CaptureBehindWindowGlass CMD for Windows Vista/Seven[/size][/font][left][/left][font="Palatino Linotype"][size="3"]Non AutoIt Script programs : Border Skin - Aero Glass On XP[/size][/font]

Share this post


Link to post
Share on other sites

For the files to read from I see 3 options

a. textfile (with a certain formatting)

b. XML

c. INI file

All three file formats have some challenges to overcome.

With INI file I indeed can solve the comment problem but then as I do not know the number of parameters I do not know how to read them all back into the treeview.

A part of the solution is in

http://www.autoitscript.com/forum/index.ph...ateTreeViewItem

But still the main question is how to keep treeviewitems in sync with the file lines of data where some of the data is not shown in the treeview but after saving still should be there.

Share this post


Link to post
Share on other sites

But still the main question is how to keep treeviewitems in sync with the file lines of data where some of the data is not shown in the treeview but after saving still should be there.

what do you mean ?

if you prefer you can share your code here or an example for your problem


[font="Palatino Linotype"][size="3"]AutoIt Script Examples :[/size][/font][font="Palatino Linotype"][size="3"]_CaptureBehindWindowGlass CMD for Windows Vista/Seven[/size][/font][left][/left][font="Palatino Linotype"][size="3"]Non AutoIt Script programs : Border Skin - Aero Glass On XP[/size][/font]

Share this post


Link to post
Share on other sites

I will generalize the problem. (when I have my first code finished and generalized I will also post)

Suppose I have an .AU3 source file

#include ....
#include ....
; some comment 1
; some comment 2
; some comment 3
; some comment 4
func f1
.. Some code 1
end func
; some comment 5
func f2
.. Some code 2
end func

I then read this file and parse it into the treeview showing f1 and when I expand all sourcelines of some code 1 and f2

When I click F1 in the treeview I want to edit in a textbox the

.. Some code 1 part (inserting, deleting, adding, modifying lines)

after editing and pressing save it should also save #include, comments etc which are not shown in the treeview

Solution I am thinking of

1. Read and parse the file into some intermediate format in an array

2. Show the relevant parts in the treeview and have a link to the intermediate format (not clear how to do that part)

3. Add, Delete, Modify in the treeview (not clear how to do that part)

4. Save finally back the newly modified file based on whatever is in the treeview combined with the not shown parts in the intermediate format

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  
Followers 0