Re: Deleting a record from a listbox
Aloha Carl and Keith! Thanks! That’s just what I needed. I see both options will work. The key is the LONGINT ARRAY FROM SELECTION and/or BOOLEAN ARRAY FROM SET. Much appreciated. Sannyasin Siddhanathaswami On Jul 3, 2019, 11:16 AM -1000, Carl Aage Wangel via 4D_Tech <4d_tech@lists.4d.com>, wrote: This is from 4D Knowledge Base and might help you: // Method: listboxDeleteSelectedRecords ** 4D Internet Users Group (4D iNUG) Archive: http://lists.4d.com/archives.html Options: https://lists.4d.com/mailman/options/4d_tech Unsub: mailto:4d_tech-unsubscr...@lists.4d.com **
Re: Deleting a record from a listbox
Here is a version with all the parts in the right place, although it seems like Carl's example from the manual, searching a boolean array, would be faster. LONGINT ARRAY FROM SELECTION($tablePtr->;$aBefore) USE SET($highlightSet) LONGINT ARRAY FROM SELECTION($tablePtr->;$aAfter) DELETE SELECTION($tablePtr->) $size:=Size of array($aAfter) For ($i;$size;1;-1) $pos:=Find in array($aBefore;$aAfter{$i}) If ($pos#-1) DELETE FROM ARRAY($aBefore;$pos) End if End for CREATE SELECTION FROM ARRAY($tablePtr->;$aBefore) Keith - CDI > On Jul 3, 2019, at 2:05 PM, Sannyasin Siddhanathaswami via 4D_Tech > <4d_tech@lists.4d.com> wrote: > > Aloha, > > I’m trying to update my "delete selection of records from a listbox" code. > I’m trying to keep the sort order so that when someone clicks to delete, the > only thing they see is the lines they select, get deleted. > > Here’s the basic code. Of course, deleting a record in this scenario, leaves > an empty record in the listbox. > > COPY NAMED SELECTION($tablePtr->;"TempCurrentSet") > USE SET($highlightSet) > DELETE SELECTION($tablePtr->) > USE NAMED SELECTION("TempCurrentSet") > CLEAR NAMED SELECTION("TempCurrentSet") > > I haven’t been able to figure out how to keep the sort, and get rid of the > deleted records (now showing as blank). > > Any ideas? > > > > Sannyasin Siddhanathaswami > ** > 4D Internet Users Group (4D iNUG) > Archive: http://lists.4d.com/archives.html > Options: https://lists.4d.com/mailman/options/4d_tech > Unsub: mailto:4d_tech-unsubscr...@lists.4d.com > ** ** 4D Internet Users Group (4D iNUG) Archive: http://lists.4d.com/archives.html Options: https://lists.4d.com/mailman/options/4d_tech Unsub: mailto:4d_tech-unsubscr...@lists.4d.com **
SV: Deleting a record from a listbox
This is from 4D Knowledge Base and might help you: // Method: listboxDeleteSelectedRecords // Description: Delete all records selected in the selection based listbox // Parameters: $1 - List Box Object Name // C_TEXT($1) If (Count parameters>=1) C_LONGINT($tableNum_l) C_TEXT($tableName_t;$highlightedSet_t) LISTBOX GET TABLE SOURCE(*;$1;$tableNum_l;$tableName_t;$highlightedSet_t) If ($tableNum_l>0) ARRAY LONGINT($recordNumber_al;0) LONGINT ARRAY FROM SELECTION(Table($tableNum_l)->;$recordNumber_al) End if ARRAY BOOLEAN($recordSelected_ab;0) BOOLEAN ARRAY FROM SET($recordSelected_ab;$highlightedSet_t) USE SET($highlightedSet_t) DELETE SELECTION(Table($tableNum_l)->) C_LONGINT($foundat_l) Repeat $foundat_l:=Find in array($recordSelected_ab;True) If ($foundat_l#-1) $recordSelected_ab{$foundat_l}:=False $foundat_l:=Find in array($recordNumber_al;$foundat_l) DELETE FROM ARRAY($recordNumber_al;$foundat_l) End if Until ($foundat_l=-1) CREATE SELECTION FROM ARRAY(Table($tableNum_l)->;$recordNumber_al) End if Regards Carl Aage Wangel >Date: Wed, 3 Jul 2019 19:05:08 + >From: Sannyasin Siddhanathaswami >To: 4D Tech <4d_tech@lists.4d.com> >Subject: Deleting a record from a listbox >Message-ID: <266d3f59-1b50-45a1-8145-7add78ddcc84@Spark> >Content-Type: text/plain; charset="utf-8" >I’m trying to update my "delete selection of records from a listbox" code. I’m >trying to keep the sort order so that when someone clicks to delete, the only >thing they see is the lines they select, get deleted. >Here’s the basic code. Of course, deleting a record in this scenario, leaves >an empty record in the listbox. >COPY NAMED SELECTION($tablePtr->;"TempCurrentSet") >USE SET($highlightSet) >DELETE SELECTION($tablePtr->) >USE NAMED SELECTION("TempCurrentSet") >CLEAR NAMED SELECTION("TempCurrentSet") >I haven’t been able to figure out how to keep the sort, and get rid of the >deleted records (now showing as blank). >Any ideas? >Sannyasin Siddhanathaswami * ** 4D Internet Users Group (4D iNUG) Archive: http://lists.4d.com/archives.html Options: https://lists.4d.com/mailman/options/4d_tech Unsub: mailto:4d_tech-unsubscr...@lists.4d.com **
Re: Deleting a record from a listbox
Sorry, I meant delete from the Before array. This is untested, but should show the idea. LONGINT ARRAY FROM SELECTION($tablePtr->;$aBefore) USE SET($highlightSet) LONGINT ARRAY FROM SELECTION($tablePtr->;$aAfter) DELETE SELECTION($tablePtr->) $size:=Size of array($aBefore) For ($i;$size;1;-1) $pos:=Find in array($aBefore{$i};$aAfter) If ($pos=-1) DELETE FROM ARRAY($aBefore;$pos) End if End for CREATE SELECTION FROM ARRAY($tablePtr->;$aBefore Keith - CDI > On Jul 3, 2019, at 3:03 PM, Keith Culotta via 4D_Tech <4d_tech@lists.4d.com> > wrote: > > I recall there being a bit more work in between these two lines, but LONGINT > ARRAY FROM SELECTION will create ordered arrays representing the records. > Then delete the missing records from the after array, and used CREATE > SELECTION FROM ARRAY to get the new selection. > > Keith - CDI > >> On Jul 3, 2019, at 2:05 PM, Sannyasin Siddhanathaswami via 4D_Tech >> <4d_tech@lists.4d.com> wrote: >> >> Aloha, >> >> I’m trying to update my "delete selection of records from a listbox" code. >> I’m trying to keep the sort order so that when someone clicks to delete, >> the only thing they see is the lines they select, get deleted. >> >> Here’s the basic code. Of course, deleting a record in this scenario, leaves >> an empty record in the listbox. >> >> COPY NAMED SELECTION($tablePtr->;"TempCurrentSet") >> USE SET($highlightSet) >> DELETE SELECTION($tablePtr->) >> USE NAMED SELECTION("TempCurrentSet") >> CLEAR NAMED SELECTION("TempCurrentSet") >> >> I haven’t been able to figure out how to keep the sort, and get rid of the >> deleted records (now showing as blank). >> >> Any ideas? >> >> ** 4D Internet Users Group (4D iNUG) Archive: http://lists.4d.com/archives.html Options: https://lists.4d.com/mailman/options/4d_tech Unsub: mailto:4d_tech-unsubscr...@lists.4d.com **
Re: Deleting a record from a listbox
I recall there being a bit more work in between these two lines, but LONGINT ARRAY FROM SELECTION will create ordered arrays representing the records. Then delete the missing records from the after array, and used CREATE SELECTION FROM ARRAY to get the new selection. Keith - CDI > On Jul 3, 2019, at 2:05 PM, Sannyasin Siddhanathaswami via 4D_Tech > <4d_tech@lists.4d.com> wrote: > > Aloha, > > I’m trying to update my "delete selection of records from a listbox" code. > I’m trying to keep the sort order so that when someone clicks to delete, the > only thing they see is the lines they select, get deleted. > > Here’s the basic code. Of course, deleting a record in this scenario, leaves > an empty record in the listbox. > > COPY NAMED SELECTION($tablePtr->;"TempCurrentSet") > USE SET($highlightSet) > DELETE SELECTION($tablePtr->) > USE NAMED SELECTION("TempCurrentSet") > CLEAR NAMED SELECTION("TempCurrentSet") > > I haven’t been able to figure out how to keep the sort, and get rid of the > deleted records (now showing as blank). > > Any ideas? > > > > Sannyasin Siddhanathaswami > ** > 4D Internet Users Group (4D iNUG) > Archive: http://lists.4d.com/archives.html > Options: https://lists.4d.com/mailman/options/4d_tech > Unsub: mailto:4d_tech-unsubscr...@lists.4d.com > ** ** 4D Internet Users Group (4D iNUG) Archive: http://lists.4d.com/archives.html Options: https://lists.4d.com/mailman/options/4d_tech Unsub: mailto:4d_tech-unsubscr...@lists.4d.com **
Re: Deleting a record from a listbox
if the sort is based on the listbox headers then the solutions to determine which header the listbox is sorted on, and then resort using the same header. if you sort the listbox some other way, and can track the sort criteria then you could use that to re-sort after deleting. I can't be of more help, as I do not generally allow deletion in my system On Wed, 3 Jul 2019 19:05:08 +, Sannyasin Siddhanathaswami via 4D_Tech wrote: > Aloha, > > I’m trying to update my "delete selection of records from a listbox" > code. I’m trying to keep the sort order so that when someone clicks > to delete, the only thing they see is the lines they select, get > deleted. > > Here’s the basic code. Of course, deleting a record in this scenario, > leaves an empty record in the listbox. > > COPY NAMED SELECTION($tablePtr->;"TempCurrentSet") > USE SET($highlightSet) > DELETE SELECTION($tablePtr->) > USE NAMED SELECTION("TempCurrentSet") > CLEAR NAMED SELECTION("TempCurrentSet") > > I haven’t been able to figure out how to keep the sort, and get rid > of the deleted records (now showing as blank). > > Any ideas? > > > > Sannyasin Siddhanathaswami > ** > 4D Internet Users Group (4D iNUG) > Archive: http://lists.4d.com/archives.html > Options: https://lists.4d.com/mailman/options/4d_tech > Unsub: mailto:4d_tech-unsubscr...@lists.4d.com > ** --- Gas is for washing parts Alcohol is for drinkin' Nitromethane is for racing ** 4D Internet Users Group (4D iNUG) Archive: http://lists.4d.com/archives.html Options: https://lists.4d.com/mailman/options/4d_tech Unsub: mailto:4d_tech-unsubscr...@lists.4d.com **
Deleting a record from a listbox
Aloha, I’m trying to update my "delete selection of records from a listbox" code. I’m trying to keep the sort order so that when someone clicks to delete, the only thing they see is the lines they select, get deleted. Here’s the basic code. Of course, deleting a record in this scenario, leaves an empty record in the listbox. COPY NAMED SELECTION($tablePtr->;"TempCurrentSet") USE SET($highlightSet) DELETE SELECTION($tablePtr->) USE NAMED SELECTION("TempCurrentSet") CLEAR NAMED SELECTION("TempCurrentSet") I haven’t been able to figure out how to keep the sort, and get rid of the deleted records (now showing as blank). Any ideas? Sannyasin Siddhanathaswami ** 4D Internet Users Group (4D iNUG) Archive: http://lists.4d.com/archives.html Options: https://lists.4d.com/mailman/options/4d_tech Unsub: mailto:4d_tech-unsubscr...@lists.4d.com **