Page 1 of 1
[SOLVED]Previous card?
Posted: Thu Jun 04, 2020 12:34 am
by anmldr
What determines which card is the "previous card" in script? Is it the order of creation of cards that determines the sequence?
I assumed that if I have a button on a card (this card is called "theFirstCard") and it's code is:
There is a button on "theSecondCard" named "Back". It's script is:
But, in creating this stack, what if I created the cards in this order:
theFirstCard
theFourthCard
theThirdCard
theSecondCard
My "Back" button on "theSecondCard" is going to "theThirdCard" and not "theFirstCard". So, is it the order of creation (and so the Card ID number) that determines which is the previous and next cards followed in the code?
I was assuming that the previous card was the one that was in the history of the previous card seen by the user and so "previous" changes if two or more cards have buttons that direct it to a given card. Meaning, if I go to "theSecondCard" from "theFirstCard", the "previous" card would be "theFirstCard". And, if I was on "theThirdCard" later in using the app, and a button sends the user to "theSecondCard", then in this instance, the "Back" button on "theSecondCard" would use the app's history and that it would go to the "previous" card that was "theThirdCard".
If it is the order of creation of cards that determines the sequence, then I will need to keep track of the history myself, correct?
Linda
Re: Previous card?
Posted: Thu Jun 04, 2020 7:57 am
by SparkOut
In the Property Inspector you will see various "identification references" for all objects.
Every object has an ID which is unique in the stack.
There is also a name, which you can set to anything, as you already know.
You may notice altId which is an alternate Id number that is not very much used, I believe it is something to help with legacy and metacard compatibility and avoid colliding IDs. (Not sure, it's not really relevant here anyway.)
Each object also has a number. This goes up increasing as you create new objects of that type. It has a correlation with "layer" in that respect, so the order that you create objects will set the default number and layer. The lowest layered it of that type will have the lowest number. So on a card, you place a field, which will be in layer 1 and field number 1 (id say 1010). Then you place a button which will be in layer two, and become button number 1 (id 1011). Then you place another field, which is layer 3 (above the button) and field number 2 (id 1012).
The layer is a setable property (and correspondingly, the number) so you can set the layer of field id 1012 to bottom. This means it is now the lowest layered field in layer 1, so it is field number 1. Field id 1010 has now become field 2, in layer 2 because the other field has been shoved in underneath into layer one and pushed it up to layer 2. If you then set the layer of button id 1010 to top, then it is now in layer 3, but is still field number 2, because it is the field second closest to the bottom layer.
You may have guessed that although a card does not have a "layer" in terms of rendering the objects, each card has a number order within the stack. You can change the order by setting the property or you should be able to drag the cards about within the project browser.
Re: Previous card?
Posted: Thu Jun 04, 2020 8:31 am
by anmldr
Thank you. I will then always be specific about the card name rather than using Previous, Next, etc. That way, I will be less apt to make mistakes in "directing" what is happening.
Linda
Re: Previous card?
Posted: Thu Jun 04, 2020 5:50 pm
by SparkOut
If you set the order of the cards and don't change them, there's no reason to avoid using next and previous. Especially as the actual cards are often a bit less volatile than other objects on the cards. It is a question of style and technique and sometimes it suits some people and their application to have a lot of dynamically generated objects and cards. Other times the application structure suits a more static style.
So, while this is to agree that giving an explicit object reference is a "good thing" you need not be afraid of the "simple" references where appropriate. Your application's cards won't jump about by themselves - only if you create on the fly or have a particular user interface that allows it. So use whatever you are comfortable with.
Re: Previous card?
Posted: Thu Jun 04, 2020 6:53 pm
by anmldr
I guess time and practice will allow me to better choose my preferences then.
Thanks,
Linda
Re: Previous card?
Posted: Thu Jun 04, 2020 8:36 pm
by raugert
Iām not absolutely sure but I believe you can just re-order the cards in the Project Manager and they will follow suit.
Re: Previous card?
Posted: Thu Jun 04, 2020 8:46 pm
by dunbarx
I believe you can just re-order the cards in the Project Manager and they will follow suit.
Yep, just drag from one position in the list and drop at another.
Craig
Re: Previous card?
Posted: Thu Jun 04, 2020 9:00 pm
by Klaus
anmldr wrote: āThu Jun 04, 2020 12:34 am
What determines which card is the "previous card" in script? Is it the order of creation of cards that determines the sequence?
No, as you already experienced. You can really take "previous card" literally, since it means the card
that you have been on previously before you came to the current (this) card.

Re: Previous card?
Posted: Sat Jun 06, 2020 6:00 pm
by SparkOut
There's a difference between "go back" and "go previous card"
"Go back" will take you to the card that you were last on before the one you are currently viewing (and back from there will be the one you were on before that, and so on).
"Go previous card" will go back through the cards in "layer" order (as created, or moved in the hierarchy through Project Browser or script)
Re: Previous card?
Posted: Sat Jun 06, 2020 6:10 pm
by Klaus
You are definitively right!
Sorry, I must have mixed this.

Re: Previous card?
Posted: Sun Jun 07, 2020 10:28 am
by mrcoollion
SparkOut wrote: āSat Jun 06, 2020 6:00 pm
There's a difference between "go back" and "go previous card"
"Go back" will take you to the card that you were last on before the one you are currently viewing (and back from there will be the one you were on before that, and so on).
"Go previous card" will go back through the cards in "layer" order (as created, or moved in the hierarchy through Project Browser or script)
I learned something here. Thanks SparkOut

Re: Previous card?[SOLVED]
Posted: Sun Jun 07, 2020 5:02 pm
by anmldr
SparkOut wrote: āSat Jun 06, 2020 6:00 pm
There's a difference between "go back" and "go previous card"
"Go back" will take you to the card that you were last on before the one you are currently viewing (and back from there will be the one you were on before that, and so on).
"Go previous card" will go back through the cards in "layer" order (as created, or moved in the hierarchy through Project Browser or script)
Now THAT is a great tip. Thank you.
Linda
Re: Previous card?
Posted: Sat Jun 20, 2020 4:11 am
by anmldr
For reference, see related:
recent
recentCards
push
pop
go back
Linda