Jump to content

remove items from list


Recommended Posts

I have a script that reads a text file into an array, and then reads the text file into a list to display on screen.

You can select items in the list

but with the function

$ret = _GUICtrlListDeleteItem ($mylist, 1)

To remove an item, it removes just items from the top down.

I can't work out how on earth to remove the selected item from the list and the array.

Somehow I guess I need to know the name of the item selected or the number of it in the array...

Im stuck, maybe someone can help me?

Link to comment
Share on other sites

I have a script that reads a text file into an array, and then reads the text file into a list to display on screen.

You can select items in the list

but with the function

$ret = _GUICtrlListDeleteItem ($mylist, 1)

To remove an item, it removes just items from the top down.

I can't work out how on earth to remove the selected item from the list and the array.

Somehow I guess I need to know the name of the item selected or the number of it in the array...

Im stuck, maybe someone can help me?

$ret = _GUICtrlListDeleteItem ($mylist, _GUICtrlListSelectedIndex ($mylist))

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

Hi,

Look up "_GUICtrlListSelectedIndex "?

Best, Randall

[Woops - see above post]

Hey BIG THANK YOU!

I did that and that works fine!

I can now add and remove things from the list and array and write to text file.

However I got a piece of code from the examples on removing duplicates from an array which worked perfectly until I added the code to remove items. Now when you remove items the array dupe code gives an error.

Array variable has incorrect number of subscripts

I've attached the code....

If anyone can assist I would be extremely gratefull

Nick

wizard_screen_1.au3

Link to comment
Share on other sites

your problem lies in this part:

$TempArray[0][0] = $InArray[0]
   For $x = 1 To $InArray[0]
      $TempArray[$x][0] = $InArray[$x]
      $TempArray[$x][1] = $x
   Next

$InArray[0] doesn't have the size of the array in it because you deleted index 0 at the beginning of the script

want to take it from there what is going to happen?

Edited by gafrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

take a look at this

Im still not sure what has gone on...

And you say its a mistake at the top, but the code worked absolutely perfectly until I added the remove button code so I dont see how its a mistake anywhere else other than here because the remove dupes works perfectly if you dont press the remove button and run this beforehand =>

Case $msg = $removebutton

$ret = _GUICtrlListGetSelItemsText ($mylist)

If (Not IsArray($ret)) Then

MsgBox(16, "Error", "Unknown error from _GUICtrlListGetSelItemsText")

Else

For $i = 1 To $ret[0]

MsgBox(0, "Selected", $ret[$i])

Next

EndIf

$ret = _GUICtrlListSelectedIndex ($mylist)

MsgBox(16, "Error", $ret)

$aret=( $ret + 1 )

_ArrayDelete ( $folders, $aret )

_GUICtrlListDeleteItem($mylist, $ret)

Link to comment
Share on other sites

Im still not sure what has gone on...

And you say its a mistake at the top, but the code worked absolutely perfectly until I added the remove button code so I dont see how its a mistake anywhere else other than here because the remove dupes works perfectly if you dont press the remove button and run this beforehand =>

Case $msg = $removebutton

$ret = _GUICtrlListGetSelItemsText ($mylist)

If (Not IsArray($ret)) Then

MsgBox(16, "Error", "Unknown error from _GUICtrlListGetSelItemsText")

Else

For $i = 1 To $ret[0]

MsgBox(0, "Selected", $ret[$i])

Next

EndIf

$ret = _GUICtrlListSelectedIndex ($mylist)

MsgBox(16, "Error", $ret)

$aret=( $ret + 1 )

_ArrayDelete ( $folders, $aret )

_GUICtrlListDeleteItem($mylist, $ret)

by the way whatever you modified has re introduced a bug that i eliminated by ignoring value [0] of the array

now it puts numbers in the list on weird occasions where it has no string

5

c:\my folder

c:\temp

next time you run it

6

5

c:\my folder

c:\temp

Link to comment
Share on other sites

by the way whatever you modified has re introduced a bug that i eliminated by ignoring value [0] of the array

now it puts numbers in the list on weird occasions where it has no string

5

c:\my folder

c:\temp

next time you run it

6

5

c:\my folder

c:\temp

God only knows why, i hate this about programming

I moved the line _Arraydelete out of the "remove" button and stuck it in the Function (SAVE) section instead and now it works perfectly.

Nothing else changed

How fucked up is that?

Link to comment
Share on other sites

  • Moderators

How xxxxed up is that?

FYI... Kids do read the board...

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

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