Go to slected card

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller

Post Reply
SEAL29
Posts: 63
Joined: Fri Oct 02, 2020 3:32 pm

Go to slected card

Post by SEAL29 »

How can i solve it with ask dialog to go to selected card?
So ask "Go to card" in dialoge window i type 3476 and when i press OK button go card 3476

Code: Select all

ask "Go to card: "
...
...
Klaus
Posts: 14325
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Go to slected card

Post by Klaus »

Hi SEAL29,

to avoid problems, you need to check if the user entered a NUMBER AND if the number of cards in your stack <= the entered number!
Remeber: If a user does something wrong, it is NEVER his/her fault, but ALWAYS the fault of the developer! :-D

Code: Select all

...
## Note the number of cards of your stack
put the num of cds into tMaxNumber
ask "Go to card:"
put it into tCardNumber

## Check if user clicked CANCEL...
if the result = "cancel" then
  # ... get out of here!
  exit to top
end if

if tCardNumber is a Number AND tCardNumber <= tMaxNumber then
  ## Finally! :-)
  go cd tCArdNumber
end if
...
Best

Klaus
SEAL29
Posts: 63
Joined: Fri Oct 02, 2020 3:32 pm

Re: Go to slected card

Post by SEAL29 »

Thank you, works. :D
dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10509
Joined: Wed May 06, 2009 2:28 pm

Re: Go to slected card

Post by dunbarx »

Seal29.

Do you really have thousands of cards, or was that just an example? LiveCode slows noticeably after a few thousand cards.

If you plan on having significantly more than that, there may be better ways to implement your project.

Craig
SEAL29
Posts: 63
Joined: Fri Oct 02, 2020 3:32 pm

Re: Go to slected card

Post by SEAL29 »

What method did you think of?
FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10105
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Go to slected card

Post by FourthWorld »

How many cards would be a reasonable maximum you would expect to have in this stack?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
SEAL29
Posts: 63
Joined: Fri Oct 02, 2020 3:32 pm

Re: Go to slected card

Post by SEAL29 »

1500-1700 card.
dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10509
Joined: Wed May 06, 2009 2:28 pm

Re: Go to slected card

Post by dunbarx »

If fewer than 2000, you will have no problems. It is only more than several thousand that you might notice a slowdown in navigation.

As for a better way, it depends on what you are doing on each card. For example, with thousands of cards, it sounds like each one is a record of some form of data, duplicated over and over. In that case, you might store all the data in an external file, and load from there to a single card. Your stack would contain only ONE card, and you would populate it from the master file.

So instead of going to a card that had the information for "Uncle Sam", you would read the data for that person from the file, and load it into the appropriate fields or set other properties as needed.

Craig
SEAL29
Posts: 63
Joined: Fri Oct 02, 2020 3:32 pm

Re: Go to slected card

Post by SEAL29 »

Yes this is like database. I wanted to of reading the data from an external location.
FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10105
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Go to slected card

Post by FourthWorld »

What is the average size of each record?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
SEAL29
Posts: 63
Joined: Fri Oct 02, 2020 3:32 pm

Re: Go to slected card

Post by SEAL29 »

Currently the whole document is 45kb as the images contain only the link to them. Now i have 5 card in stack.
dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10509
Joined: Wed May 06, 2009 2:28 pm

Re: Go to slected card

Post by dunbarx »

It would be a good learning experience to practice with an external file, but you will have no issue with the current scope.

@ Richard. I think I have this right, no? The stack, with 1700-odd images, will be a few tens of MB, and that is a non issue?

Craig
FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10105
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Go to slected card

Post by FourthWorld »

dunbarx wrote: Sun Oct 11, 2020 1:56 am @ Richard. I think I have this right, no? The stack, with 1700-odd images, will be a few tens of MB, and that is a non issue?
Can't say. I asked the size of each record, and got a size of a "document", but I don't know if each record is a document or the document is the container of all records.

As for images, he's already handling those with links to them, so displaying them from their disk files would not need to change from how he's doing it now.

That is, if I understand this at all. Not sure that I do.
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: 10509
Joined: Wed May 06, 2009 2:28 pm

Re: Go to slected card

Post by dunbarx »

Currently the whole document is 45kb as the images contain only the link to them. Now i have 5 card in stack.
Can't say. I asked the size of each record, and got a size of a "document", but I don't know if each record is a document or the document is the container of all records.
I noticed that as well. Rereading the above, however, I likely misunderstood, and hastily calculated that there was roughly 9K for the five cards, with each card containing an image. But a typical simple stack is around 45K, so I am sure I am wrong.

As you say, the OP seems already to have moved in a viable direction.

Craig
Post Reply