lock recent

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

marksmithhfx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 931
Joined: Thu Nov 13, 2008 6:48 am
Location: London, UK

lock recent

Post by marksmithhfx » Tue Dec 22, 2020 2:11 pm

Hi, I am trying to figure how lock recent works since I want to prevent a card from going into the recents list. I've created a stack with 3 cards; A, B, C. Anytime I go to B, whether it is directly as in "go card B" or indirect via "go back" or "go previous" I use lock recent. Anytime I open any of the cards I display the list of recent cards. What I find is, the "B" card is never listed in the list of recents, HOWEVER, when I do go back (from C) it still goes to B even though it is not in the list of recents.

Is anyone else getting the same result? I've attached the stack. If you see an error please let me know.

Thanks
Mark
Attachments
Untitled 1.livecode.zip
(1.27 KiB) Downloaded 150 times
macOS 12.6.5 (Monterey), Xcode 14.2, LC 10.0.0, iOS 15.6.1
Targets: Mac, iOS

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9287
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: lock recent

Post by richmond62 » Tue Dec 22, 2020 2:54 pm

Um . . .

go previous goes to the previous card visited, and lock recent should stop a card showing up in the previous list.

go back will go back to the card directly before the one containing an object with that command in a stack.

So go back will not tak tent of lock recent.

Oh, and while I'm here, why, when I type go back into the dictionary (both in 8.2.0 and 9.6.1) do I only
get go in widget listed? That's a load of old cobblers.

macOS 11.2 beta, LC 8.20 and 9.61

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9802
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: lock recent

Post by FourthWorld » Tue Dec 22, 2020 4:54 pm

I haven't used anything *recent in a long time so double check this, but I believe "go recent" will do what you're looking for.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9580
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: lock recent

Post by dunbarx » Tue Dec 22, 2020 5:58 pm

These gadgets go back to HC 1. I never used them.

Anyway, can you put a "preOpenCard" handler in the stack script that will prevent the user from accessing card "B"? Something like:

Code: Select all

on preOpenCard
   if the name of this cd = "B" and the optionKey is up then go cd "C"
end preOpenCard
This could use a bit of enhancement, but will prevent going to cd "B" unless the optionKey is down.

Craig

marksmithhfx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 931
Joined: Thu Nov 13, 2008 6:48 am
Location: London, UK

Re: lock recent

Post by marksmithhfx » Sat Apr 17, 2021 7:58 pm

FourthWorld wrote:
Tue Dec 22, 2020 4:54 pm
I haven't used anything *recent in a long time so double check this, but I believe "go recent" will do what you're looking for.
I did eventually figure this out, but I can't with any certainty give you a formula for how it works. I just think it's trial and error using the terms previous, back and recent to get the effect you want (with lock recent). Even in the attached stack, which is the barest minimalist example, there are places where if you use "recent" instead of "previous" you will not get the expected behavior. Also, even though this example now works the way I want (you can go from A -> B -> C and the it returns to "A" when you go recent, and returns to "C" when you go recent after that ie. it looks like "B" card is not in the list of recents there are problems. For one thing after going back and forth a few times you'll notice you have to click the "go recent" button on the "C" card quite a few times before it goes back to the card it came from. (In all likelihood it is going to itself? But I did not test this). Also, be warned, if you change anything on "B" that will immediately put the card in the list of recents and you won't be able to test if your "algorithm" is working. You have to completely dump LC (since the "recents" appears to be a property of livecode and not any particular card or stack). The whole thing is so convoluted to figure out (for example, each and every path to a card has to be blocked by "lock recent" otherwise, one slip up and the card will be added to the list of recents). Anyway, getting back to what I was saying I have found this so challenging to just have 1 card that is not in your list of recents that I am going to make a feature request to make a "block recent" property of a card, so when that property is set the card will not be added to the list of recents no matter what. You set it and forget it.

Let me know what you think before I do that.

Mark
Attachments
test recent.livecode.zip
(1.23 KiB) Downloaded 143 times
macOS 12.6.5 (Monterey), Xcode 14.2, LC 10.0.0, iOS 15.6.1
Targets: Mac, iOS

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7215
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: lock recent

Post by jacque » Sun Apr 18, 2021 5:03 pm

I needed to do a similar thing in my current project but rather than block a card from the recents list, I just filtered it out when I needed to use it.

From memory, so test it:

Code: Select all

get the recentcards
filter it without "*<card name>*"
go (line 2 of it) 
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

marksmithhfx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 931
Joined: Thu Nov 13, 2008 6:48 am
Location: London, UK

Re: lock recent

Post by marksmithhfx » Sun Apr 18, 2021 11:31 pm

jacque wrote:
Sun Apr 18, 2021 5:03 pm
I needed to do a similar thing in my current project but rather than block a card from the recents list, I just filtered it out when I needed to use it.

From memory, so test it:

Code: Select all

get the recentcards
filter it without "*<card name>*"
go (line 2 of it) 
Thanks Jacque, that looks very handy to know. I was not aware of the "filter" command. Something new everyday :)

Although I'll test this clever workaround I still like the idea of being able to say "just block this card from the recents list". I guess it doesn't hurt to ask.

Cheers,
Mark
macOS 12.6.5 (Monterey), Xcode 14.2, LC 10.0.0, iOS 15.6.1
Targets: Mac, iOS

marksmithhfx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 931
Joined: Thu Nov 13, 2008 6:48 am
Location: London, UK

Re: lock recent

Post by marksmithhfx » Mon Jul 19, 2021 8:55 pm

jacque wrote:
Sun Apr 18, 2021 5:03 pm
From memory, so test it:

Code: Select all

get the recentcards
filter it without "*<card name>*"
go (line 2 of it) 
Jacque, I'd like to do something like this but recentcards returns a list of card ID numbers
card id 405771 of stack "long address of stack"
What I would like to do is filter the list based on a list of ID numbers I don't want the lines for. Something like

Code: Select all

filter lines of it where each does not contain (405764, 405766, 407568, 405771)
the idea being that it would return a list of recent cards with those 4 in particular removed from the list.

I'm struggling to think of how I could express that properly. Any suggestions?

Thanks
Mark
macOS 12.6.5 (Monterey), Xcode 14.2, LC 10.0.0, iOS 15.6.1
Targets: Mac, iOS

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7215
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: lock recent

Post by jacque » Tue Jul 20, 2021 7:23 pm

Right, the list is made up of long IDs, which I'd forgotten when I wrote from memory. In my case I wanted to filter out all the cards in a substack so I filtered on the name of the stack rather than individual cards.

Since you want to exclude specific cards, I think you'd need to filter out each one separately, something like this:

Code: Select all

put the recentcards into tList
repeat for each item i in "405764, 405766, 407568, 405771"
  filter tList without "*" & i & "*"
end repeat
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

marksmithhfx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 931
Joined: Thu Nov 13, 2008 6:48 am
Location: London, UK

Re: lock recent

Post by marksmithhfx » Tue Jul 20, 2021 8:58 pm

jacque wrote:
Tue Jul 20, 2021 7:23 pm
Since you want to exclude specific cards, I think you'd need to filter out each one separately, something like this:

Code: Select all

put the recentcards into tList
repeat for each item i in "405764, 405766, 407568, 405771"
  filter tList without "*" & i & "*"
end repeat
But you can't actually filter recentcards? Hmmm, I don't think that is going to work. I want to actually totally avoid those cards after I do the filtering. Don't get me wrong, your code works perfectly as illustrated (i print the list before, each item as I am filtering, and then after). But that is in tList not recentCards so when I say "go back" or "go recent" it's still going to be reading the recentCards list, not my filtered version?
tList Before
card id 405771 of stack "/Users/marksmith
card id 405768 of stack "/Users/marksmith
card id 405766 of stack "/Users/marksmith
card id 405764 of stack "/Users/marksmith
card id 361085 of stack "/Users/marksmith
card id 1002 of stack "/Users/marksmith 1
card id 693213 of stack "/Users/marksmith

filter 405764
filter 405766
filter 405768
filter 405771

tList After
card id 361085 of stack "/Users/marksmith
card id 1002 of stack "/Users/marksmith 1
card id 693213 of stack "/Users/marksmith
What I'd like to do is filter recentCards so those card id's do not exist in it anymore.
Last edited by marksmithhfx on Wed Jul 21, 2021 7:33 am, edited 1 time in total.
macOS 12.6.5 (Monterey), Xcode 14.2, LC 10.0.0, iOS 15.6.1
Targets: Mac, iOS

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7215
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: lock recent

Post by jacque » Tue Jul 20, 2021 9:48 pm

No, you can't permanently filter out entries in the recentCards list, but you can turn off adding those cards before you go to them. That will prevent them from being included. I see you've tried "lock recent" which is the only way I know of, but if it's still including those cards then maybe the timing is wrong? Do you lock recents before navigating to the card?

Edit: I'm thinking "go back" and "go recent" are different commands. If you use "go recent" I think you'll get what you want. The "go back" command apparently goes to the previously-visited card no matter whether it's in the recents list or not. On the other hand, if the user never visits a card, how come "go back" gets there?
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

marksmithhfx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 931
Joined: Thu Nov 13, 2008 6:48 am
Location: London, UK

Re: lock recent

Post by marksmithhfx » Wed Jul 21, 2021 7:47 am

jacque wrote:
Tue Jul 20, 2021 9:48 pm
No, you can't permanently filter out entries in the recentCards list, but you can turn off adding those cards before you go to them. That will prevent them from being included. I see you've tried "lock recent" which is the only way I know of, but if it's still including those cards then maybe the timing is wrong? Do you lock recents before navigating to the card?
No, I didn't use "lock recent" on those cards. Maybe I need to take a step back and explain what I want to do.

I have a main area of the program that consists of three cards: home, categories and settings. The latter 2 play a supporting role for the home card where the user spends the bulk of their time/activity. Now, off of the settings page is a 4-page user guide. Within the user guide you can navigate back and forth. I recently added an exit strategy from any UG card back to settings... a big X on the page. Tap that and you go from the UG back to the settings page. Now, given that you have exited the UG, pressing back on the settings page should not take you back into the UG (it feels really unnatural), it should take you back to wherever you came from BEFORE you selected the settings page (some may argue, but there still is the option to select the UG if that is what you want). So what I was hoping to do was "pop" those "recent" cards from the recents list. (That will probably be the thrust of my feature request: some way to manipulate the recents list to remove entries like an old fashioned first in/ last out stack that you could manipulate using push and pop commands). But there probably is another way to accomplish what I want that has not occurred to me.
macOS 12.6.5 (Monterey), Xcode 14.2, LC 10.0.0, iOS 15.6.1
Targets: Mac, iOS

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9287
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: lock recent

Post by richmond62 » Wed Jul 21, 2021 7:56 am

Aha.

In my Devawriter Pro I have a recent button on pages with non-standard Indian glyphs which takes ypu
back to whichever of the 25 interfaces you were using prior to that one.

I use a strictly rocket-science method: when I leave the card to which I want to return the name of that card is
dumped in a field, so when I hit the RETURN button on the new card all it has to do is to refer to the contents
of that field.

Someone is bound to state that this is "not elegant" or "crude", both of which would be correct: but the thing works.

Code: Select all

on mouseUp
   put "DEVANAGARI" into fld "fRETURNER" of card "SCHARS"
   go to card "SCHARS"
   set the htmlText of fld "fRESULT" of card "SCHARS" to the htmlText of fld "fRESULT" of card "DEVANAGARI"
end mouseUp
returnToSender.jpg

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7215
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: lock recent

Post by jacque » Wed Jul 21, 2021 6:02 pm

Thanks, the explanation helps. There actually are push/pop commands. You could push the home card when leaving it and the back button on the other two cards can pop it. You can also push any number of cards into the push stack and any time you pop, LC goes to the most recent pushed entry which is then removed from the list. If you want to remove the most recent entry from the pushed stack without acting on it, you can pop it into a variable that you don't use.

These commands were made for exactly what you want to do.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

marksmithhfx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 931
Joined: Thu Nov 13, 2008 6:48 am
Location: London, UK

Re: lock recent

Post by marksmithhfx » Thu Jul 22, 2021 6:27 pm

richmond62 wrote:
Wed Jul 21, 2021 7:56 am
I use a strictly rocket-science method: when I leave the card to which I want to return the name of that card is
dumped in a field, so when I hit the RETURN button on the new card all it has to do is to refer to the contents
of that field.
I'm not sure I follow your logic Richmond, but combining what you said with what Jacque said, could you not simply write

Code: Select all

push card
when you are leaving a card you want to return to, and then

Code: Select all

pop card
when you want to return back to that card?

Since you are already maintaining (in essence) a separate stack with the field idea, I think this would work and might be simpler. For me it's a bit more complicated since I don't want to set up a parallel stack to manage my too-ing and fro-ing. I just want to modify the existing "recentCards" stack which apparently is a property of the stack. Since it is a property, a question I have for you and for Jacque is, can't I just edit it?

Also relatedly, I tried using push and pop card and it works as expected, my only concern is that it is (I presume) creating a parallel recentCards queue that has no name. So you can never inspect it. You just have to blindly push and pop things and hope you are doing it correctly. Unless I missed something?

A parallel queue seems like a lot of work just to exclude 4 cards. And if I

Code: Select all

lock recent
in this case I will create all sorts of other problems, because a user might want to go back and forth between the 4 pages in the UG, and if I am not recording which cards they visited (by locking them) then they are going to get a very unexpected tour. No, the best solution I can think of is the ability to push and pop cards on the recent cards list. I'm not sure I understand why LC would avoid allowing that to be done.

Mark
macOS 12.6.5 (Monterey), Xcode 14.2, LC 10.0.0, iOS 15.6.1
Targets: Mac, iOS

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”