Re: Undocumented 50g shortcuts ? Message #4 Posted by Glenn Shields on 4 Aug 2011, 12:21 p.m., in response to message #3 by Glenn Shields
One more thing, the 50g remains so interesting, and "deep" as Tim Wessman said in his recent Community post (about the "?" function).
After 2 years of being challenged by the AUR to modify the Phonelist program to add a "delete" routine, a solution presented itself (I have been using it as an organizer, along with the flash memory so nothing gets lost).
The main problem to solve is the fact that the choose box returns only the second item of the list {"name" "number}, so in order to modify the 'names' list to let POS search for the position of the item to delete, I added a routine to combine each element into one string, using DOLIST. Then with the result of POS, the original list can be broken down using SUB into two pieces (without the item to be deleted), then combined with "+" . The method of modifying 'names' and re-storing it is pretty inelegant, but is the method given in the AUR.
So, first add a third choose item, {"DELETE AN ENTRY" 3}, and a third CASE element, "c 3 ==", then copy the same "you must add a name" routine, then ELSE names 1 << obj-> drop " " swap + + 1 ->list >> DOLIST 'nms' STO
This rewrites 'names' into single-string items, to be operated on by POS.
This is entered between ELSE and WHILE. After WHILE comes "DELETE AN ENTRY" 1 CHOOSE REPEAT nms swap POS dup names swap 1 swap 1 - SUB names ROT 1 + swap dup SIZE rot swap SUB + 'names' STO.
This uses POS to pick out all entries up to (POS - 1), then uses SIZE to pick out (POS + 1 throuth SIZE).
As for the case if the entry is first or last on the list, it turns out that SUB is a very forgiving function -- if the indices fall outside the range of the list, it returns a blank list {}. How convienient!! Then throw a 'nms' purge at the end to clean up. What fun!!
|