Welcome! Log In Create A New Profile

Advanced

Sammy Broeders: List box question

Posted by harvey68 
Sammy Broeders: List box question
September 08, 2018 05:57PM
Autor: Sammy Broeders

Link zum Beitrag: [27130.foren.mysnip.de]

Hello all,

I have a list box filled with a data file, now i want to select one or
more items in this list box and delete it from this list box/datafile to
another list box/datafile. I use the code below but it is not working
ok, most of the time other rows who are not selected converted to the
other listbox.

FOR EACH SELECTED ROW OF LIST_all
HReadSeek(VoertuigSoort,Nummer,LIST_all)
VoertuigSoortGroep1 = VoertuigSoort
HAdd(VoertuigSoortGroep1)
HDelete(VoertuigSoort)
END

ListDisplay(LIST_all)
ListDisplay(LIST_filter1)
Piet van Zanten: List box question
September 08, 2018 05:58PM
Autor: Piet van Zanten

Link zum Beitrag: [27130.foren.mysnip.de]

Hi Sammy,

If you delete stuff in a for each loop, you always have to do it in
reverse order FOR Each xxx FromEnd, otherwise the delete will interfere
with the browse.
And do a listdisplay(xxx, taInit) afterwards.

Kind regards,
Piet
Sammy Broeders: List box question
September 08, 2018 06:03PM
Autor: Sammy Broeders

Link zum Beitrag: [27130.foren.mysnip.de]

Thanks Piet,

But where can i place ''fromend'' ?

Sammy
DW: List box question
September 08, 2018 06:04PM
Autor: DW

Link zum Beitrag: [27130.foren.mysnip.de]

Sammy

something like this:

//Get the count of selected rows
nCount is int = TableSelectCount(TABLE_Orders)
nRow is int

//Make sure you have at least 1 row
IF nCount > 0 THEN
//Now we step form back to front of the table
FOR i = nCount TO 1 STEP -1
//Select the last row first and move 1 by 1 to
the first
nRow = TableSelect(TABLE_Orders,i)
//Do your magic here
END
END
END
ELSE
Info("You must select at least one row to preform this operation! ")
END



DW
Piet van Zanten: List box question
September 08, 2018 06:05PM
Autor: Piet van Zanten

Link zum Beitrag: [27130.foren.mysnip.de]

Hi Sammy,

I see now that there is no FromEnd for "FOR EACH Selected".
A very simple solution would be to gather the IDs first:

ar_Selection is array of int
FOR EACH SELECTED ROW OF LIST_all
ArrayAdd(ar_Selection,LIST_all)
END
FOR EACH ID OF ar_Selection
HReadSeek(VoertuigSoort,Nummer,ID)
VoertuigSoortGroep1 = VoertuigSoort
HAdd(VoertuigSoortGroep1)
HDelete(VoertuigSoort)
END
ListDisplay(LIST_all)
ListDisplay(LIST_filter1)
Kind regards,
Piet
Sammy Broeders: List box question
September 08, 2018 06:06PM
Autor: Sammy Broeders

Link zum Beitrag: [27130.foren.mysnip.de]

Piet,

Your first solution works ok, the second post gives the same problem as
i had.

Thanks
Piet van Zanten: List box question
September 08, 2018 06:07PM
Autor: Piet van Zanten

Link zum Beitrag: [27130.foren.mysnip.de]

Hi Sammy,

You probably mean DW's solution or did the FromEnd work?
Just wondering: is the list a simple list or is it a list with a
returned value?
IOW, does it return the list index or the linked value?

Kind regards,
Piet
Sammy Broeders: List box question
September 08, 2018 06:22PM
Autor: Sammy Broeders

Link zum Beitrag: [27130.foren.mysnip.de]

Sorry your right, i mean DW`s solution.
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: