Page 1 of 1

Go to slected card

Posted: Fri Oct 09, 2020 7:43 pm
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: "
...
...

Re: Go to slected card

Posted: Fri Oct 09, 2020 7:59 pm
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

Re: Go to slected card

Posted: Fri Oct 09, 2020 9:28 pm
by SEAL29
Thank you, works. :D

Re: Go to slected card

Posted: Fri Oct 09, 2020 11:35 pm
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

Re: Go to slected card

Posted: Sat Oct 10, 2020 5:57 am
by SEAL29
What method did you think of?

Re: Go to slected card

Posted: Sat Oct 10, 2020 6:15 am
by FourthWorld
How many cards would be a reasonable maximum you would expect to have in this stack?

Re: Go to slected card

Posted: Sat Oct 10, 2020 6:49 am
by SEAL29
1500-1700 card.

Re: Go to slected card

Posted: Sat Oct 10, 2020 2:03 pm
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

Re: Go to slected card

Posted: Sat Oct 10, 2020 3:15 pm
by SEAL29
Yes this is like database. I wanted to of reading the data from an external location.

Re: Go to slected card

Posted: Sat Oct 10, 2020 5:32 pm
by FourthWorld
What is the average size of each record?

Re: Go to slected card

Posted: Sat Oct 10, 2020 6:46 pm
by SEAL29
Currently the whole document is 45kb as the images contain only the link to them. Now i have 5 card in stack.

Re: Go to slected card

Posted: Sun Oct 11, 2020 1:56 am
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

Re: Go to slected card

Posted: Sun Oct 11, 2020 4:32 am
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.

Re: Go to slected card

Posted: Sun Oct 11, 2020 2:38 pm
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