Sign in to follow this  
Followers 0
dirtymafia

passing unknown array number

10 posts in this topic

I have a script which is creating a treeview and listbox according to an INI file, which users have the ability to add new entries to.

Problem is that I need to make a Select to find out what folder they are clicking on. Basically I need something like the following but am not sure how to declare it.

Where "x" is the un-known number. I could declare a Case for each possible "x" that could exsist but that would make "x" limited and I would like to be able to keep it "infinite". If you don't understand I will try to explain further.

CODE

While 1

$msg = GuiGetMsg()

Select

Case $msg = $sa["x"]

reflview($folname["x"])

Case $msg = $addbutton

addbutton()

Case $msg = $GUI_EVENT_CLOSE

ExitLoop

EndSelect

WEnd

Exit

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

1

i dont know if you are trying to select the treeview item or the listbox item

2

are they read into an $array from the ini?

3

better yet show us the full script

8)

Edited by Valuater

NEWHeader1.png

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

1

i dont know if you are trying to select the treeview item or the listbox item

2

are they read into an $array from the ini?

3

better yet show us the full script

8)

1) I'm selecting a treeview and then making a listbox populate

2) I already have everything working fine

Everything is working fine if I declare the following.

Like in the following code the script is limited to only 3 instances in the array

CODE
While 1

$msg = GuiGetMsg()

Select

Case $msg = $sa[1]

reflview($folname[1])

Case $msg = $sa[2]

reflview($folname[2])

Case $msg = $sa[3]

reflview($folname[3])

Case $msg = $addbutton

addbutton()

Case $msg = $GUI_EVENT_CLOSE

ExitLoop

EndSelect

WEnd

Exit

Where I go through and declare each instance of $sa[x] that could be declared it works fine. But then the script is limited to however many CASES I declare, and I would prefer to leave it open ended by being able to just have 1 case like Case $msg = $sa["x"] and then passing that x number to reflview($folname["x"]). Edited by dirtymafia

Share this post


Link to post
Share on other sites

the reason i asked was because if you have a "button" that is pressed when the user wants to "select" an item

you can use a guicontrolread() to get the item from the treeview

if not... maybe how you have accomplshed it will work

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

the reason i asked was because if you have a "button" that is pressed when the user wants to "select" an item

you can use a guicontrolread() to get the item from the treeview

if not... maybe how you have accomplshed it will work

8)

No its not a button just clicking on the value in the treeview updates the listbox with info. Just trying to make it so it is unlimited instead of having to write it all out in the select/endselect and also making it limited.

Share this post


Link to post
Share on other sites

ok.... i better at scripting then guessing

need to see the script to help you....

or you could pay someone you trust

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

here..

Not quite finished yet at all... Just working on the part mentioned for now.

NO error correcting for "no ini file found" so don't try to run.

CODE

#include <GuiConstants.au3>

GuiCreate("MyGUI", 392, 316,(@DesktopWidth-392)/2, (@DesktopHeight-316)/2 , $WS_OVERLAPPEDWINDOW + $WS_VISIBLE)

$itname = GuiCtrlCreateInput("Image Name", 80, 180,150,20) ;controlid3

$secname = Guictrlcreateinput("Image Category", 80, 205, 100,20);controlid4

$itfile = GuiCtrlCreateInput("Image File Path", 80, 230, 260, 20);controlid5

$addbutton = GuiCtrlCreateButton("Add", 80, 255, 80, 20)

$filemenu = guictrlcreatemenu("&File")

$openitem = GUICtrlCreateMenuitem ("Open",$filemenu,1)

GUICtrlCreateMenuitem ("",$filemenu,2)

$exititem = GUICtrlCreateMenuitem ("Exit",$filemenu,3)

$editmenu = guictrlcreatemenu("&Edit")

$additem = guictrlcreatemenuitem("&Add Image",$editmenu,1)

$remoitem = guictrlcreatemenuitem("&Remove Image",$editmenu,2)

$helpmenu = guictrlcreatemenu("&Help")

$helpitem = guictrlcreatemenuitem("&Help",$helpmenu,1)

guictrlcreatemenuitem("",$helpmenu,2)

$aboutitem = guictrlcreatemenuitem("&About PROGRAM",$helpmenu,3)

$fileview = Guictrlcreatelistview("Image Name|Path",130,30,200,100,bitor($LVS_SINGLESEL,$LVS_SHOWSELALWAYS,$LVS_NOSORTHEADER))

$winview = Guictrlcreatetreeview(20,30,100, 140,BitOr($TVS_HASBUTTONS,$TVS_DISABLEDRAGDROP,$TVS_SHOWSELALWAYS,$TVS_SINGLEEXPAND),$WS_EX_CLIENTEDGE)

$dummy = guictrlcreatedummy()

GUICtrlSetImage(-1,"shell32.dll",3,4); set an icon for the nonselected state in the tree

GUICtrlSetImage(-1,"shell32.dll",4,2); set an icon for the selected state in the tree

GuiSetState()

$s1 = IniReadSectionNames("data.dat")

Global $sa[$s1[0]+1]

Global $folname[$s1[0]+1]

reftview()

While 1

$msg = GuiGetMsg()

Select

Case $msg = $sa[1]

reflview($folname[1])

Case $msg = $sa[2]

reflview($folname[2])

Case $msg = $sa[3]

reflview($folname[3])

Case $msg = $addbutton

addbutton()

Case $msg = $GUI_EVENT_CLOSE

ExitLoop

EndSelect

WEnd

Exit

Func addbutton()

$imcat = guictrlread(4)

$path = GUICtrlRead(5) ; read Image PATH

$name = guictrlread(3) ; read Image NAME

write($imcat,$path,$name)

reftview()

EndFunc

Func write($l,$p,$n) ;appends the file with supplied data

IniWrite("data.dat",$l,$n,$p)

EndFunc

Func read($se) ;reads the specified section

$rr = IniReadSection("data.dat", $se)

RETURN $rr

EndFunc

func reftview()

Guictrldelete($winview)

$winview = Guictrlcreatetreeview(20, 30, 100, 140,BitOr($TVS_HASBUTTONS,$TVS_DISABLEDRAGDROP,$TVS_SHOWSELALWAYS,$TVS_SINGLEEXPAND),$WS_EX_CLIENTEDGE)

GUICtrlSetImage(-1,"shell32.dll",3,4); set an icon for the nonselected state in the tree

GUICtrlSetImage(-1,"shell32.dll",4,2); set an icon for the selected state in the tree

$s = IniReadSectionNames("data.dat")

$dimen = $s[0]+1

For $a = 1 To $s[0]

redim $folname[$s[0]+1]

redim $sa[$s[0]+1]

$folname[$a] = $s[$a]

$sa[$a] = Guictrlcreatetreeviewitem($s[$a],$winview)

Next

EndFunc

func reflview($s)

guictrldelete($fileview)

$fileview = Guictrlcreatelistview("Image Name|Path",130,30,200,100,bitor($LVS_SINGLESEL,$LVS_SHOWSELALWAYS,$LVS_NOSORTHEADER))

$refs = read($s)

For $i = 1 To $refs[0][0]

Guictrlcreatelistviewitem($refs[$i][0] & "|" & $refs[$i][1],$fileview)

Next

EndFunc

Edited by dirtymafia

Share this post


Link to post
Share on other sites

when i copy the way you posted i get one line ( everything is in one line)

please post with

[ code ] ; no spaces

; copy/paste here

[ /code ] ; no spaces

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

when i copy the way you posted i get one line ( everything is in one line)

please post with

[ code ] ; no spaces

; copy/paste here

[ /code ] ; no spaces

8)

I dunno why, when I copy it is fine.

Either way, I already figured it out.

Just changed the Select...endselect to the following

CODE
While 1

$msg = GuiGetMsg()

Select

Case $msg <> ""

For $zz=1 to $count

Select

Case $msg = $sa[$zz]

reflview($folname[$zz])

Case $msg = $GUI_EVENT_CLOSE

Exit

Case $msg = $addbutton

$count = addbutton()

EndSelect

Next

EndSelect

WEnd

Exit

Share this post


Link to post
Share on other sites

I dunno why, when I copy it is fine.

Either way, I already figured it out.

Just changed the Select...endselect to the following

CODE
While 1

$msg = GuiGetMsg()

Select

Case $msg <> ""

For $zz=1 to $count

Select

Case $msg = $sa[$zz]

reflview($folname[$zz])

Case $msg = $GUI_EVENT_CLOSE

Exit

Case $msg = $addbutton

$count = addbutton()

EndSelect

Next

EndSelect

WEnd

Exit

thats only a quick fix... if you add more buttons etc.. you will most likely have problems

anyway

good luck

8)


NEWHeader1.png

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