WM22 Android : Move item in table or looper October 15, 2018 02:01PM |
Registered: 5 years ago Posts: 54 |
Re: WM22 Android : Move item in table or looper October 15, 2018 03:41PM |
Registered: 5 years ago Posts: 38 |
Re: WM22 Android : Move item in table or looper October 15, 2018 03:49PM |
Registered: 5 years ago Posts: 74 |
Re: WM22 Android : Move item in table or looper October 15, 2018 05:36PM |
Registered: 5 years ago Posts: 54 |
// looper based on a query sorted on 'sort-order' decimal field // Locate the currently selected row glocaliRowSubscript1 is int = LooperSelect(LOOP_QRY_species2) // If it is the first row in looper nothing to do IF glocaliRowSubscript1 < 2 THEN RETURN END // If it is the 2nd row we swap the sort_order decimal IF glocaliRowSubscript1 = 2 THEN // copy GUID of selected row original_GUID is UNICODE string = LOOP_QRY_species2.ATT_settings_species_GUID original_sort is currency = LOOP_QRY_species2.ATT_sort_order // Select the row above LooperSelectPlus(LOOP_QRY_species2,1) sONE_ABOVE is UNICODE string = LOOP_QRY_species2.ATT_settings_species_GUID // locate original to update HReadSeek(settings_species,usGUIDsettings_species,sONE_ABOVE) swap_sort is currency = settings_species.sort_order settings_species.sort_order=original_sort HModify(settings_species) // swap to original HReadSeek(settings_species,usGUIDsettings_species,original_GUID) settings_species.sort_order=swap_sort HModify(settings_species) ELSE // find sort_order of the two rows above, add values together and divide by 2 for new sort_order original_GUID is UNICODE string = LOOP_QRY_species2.ATT_settings_species_GUID // Select the row above LooperSelectPlus(LOOP_QRY_species2,glocaliRowSubscript1 - 1) glocaliRowSubscript2 is int = LooperSelect(LOOP_QRY_species2) sONE_ABOVE is UNICODE string = LOOP_QRY_species2.ATT_settings_species_GUID // Select the 2ND row above the one selected by the user ready for the swap LooperSelectPlus(LOOP_QRY_species2,glocaliRowSubscript2 - 1) sTWO_ABOVE is UNICODE string = LOOP_QRY_species2.ATT_settings_species_GUID // get the sort-order of one above HReadSeek(settings_species,usGUIDsettings_species,sONE_ABOVE) cyOne_above is currency = settings_species.sort_order // get the sort order of two above HReadSeek(settings_species,usGUIDsettings_species,sTWO_ABOVE) cyTwo_above is currency = settings_species.sort_order // add together cyNCombined is currency = cyOne_above+cyTwo_above cyNCombined=cyNCombined/2 // update the selected record with the new sort_order HReadSeek(settings_species,usGUIDsettings_species,original_GUID) settings_species.sort_order=cyNCombined HModify(settings_species) END // refresh the looper HExecuteQuery(QRY_species_by_preset,hQueryDefault,gsPreset) LooperDisplay(LOOP_QRY_species2) // Select/highlight the row that was moved up in the table LooperSelectPlus(LOOP_QRY_species2,glocaliRowSubscript1-1)