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: FourthWorld, heatherlaine, Klaus, kevinmiller

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

Go to slected card

Post by SEAL29 » Fri Oct 09, 2020 7:43 pm

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: 14194
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Go to slected card

Post by Klaus » Fri Oct 09, 2020 7:59 pm

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 » Fri Oct 09, 2020 9:28 pm

Thank you, works. :D

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10319
Joined: Wed May 06, 2009 2:28 pm

Re: Go to slected card

Post by dunbarx » Fri Oct 09, 2020 11:35 pm

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 » Sat Oct 10, 2020 5:57 am

What method did you think of?

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

Re: Go to slected card

Post by FourthWorld » Sat Oct 10, 2020 6:15 am

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 » Sat Oct 10, 2020 6:49 am

1500-1700 card.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10319
Joined: Wed May 06, 2009 2:28 pm

Re: Go to slected card

Post by dunbarx » Sat Oct 10, 2020 2:03 pm

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 » Sat Oct 10, 2020 3:15 pm

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: 10048
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Go to slected card

Post by FourthWorld » Sat Oct 10, 2020 5:32 pm

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 » Sat Oct 10, 2020 6:46 pm

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: 10319
Joined: Wed May 06, 2009 2:28 pm

Re: Go to slected card

Post by dunbarx » Sun Oct 11, 2020 1:56 am

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: 10048
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Go to slected card

Post by FourthWorld » Sun Oct 11, 2020 4:32 am

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: 10319
Joined: Wed May 06, 2009 2:28 pm

Re: Go to slected card

Post by dunbarx » Sun Oct 11, 2020 2:38 pm

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