Link to cloned card

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

Post Reply
dalkin
Posts: 183
Joined: Wed Jul 04, 2007 2:32 am
Contact:

Link to cloned card

Post by dalkin » Tue Oct 01, 2019 7:07 am

SCREEN.jpg
Steps:

From this 'master' card, I have a button 'Clone' with

on mouseUp pButtonNumber
clone card id "1094"
end mouseUp

on the cloned card, the user gives the card a name, 'Project Title' . On returnInField, the name is sent to a scrolling list field on a separate navigation card.

Code attached to the "Project Title" field:

on returnInField
set the textStyle of field "Title" to link
put return before line 1 of field "Index" of card id 1130 //card 1130 contains the scrolling list
put field "Title" before field "Index" of card id 1130
end returnInField

The scrolling list field populates with the various "Project Title" fields just fine but none of them link back to the card with its unique title.

How do I code a URL to return to the card with its unique Project Title?
The underlying purpose of Al is to allow wealth to access skill
while removing from the skilled the ability to access wealth.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10097
Joined: Fri Feb 19, 2010 10:17 am

Re: Link to cloned card

Post by richmond62 » Tue Oct 01, 2019 10:01 am

How do I code a URL to return to the card with its unique Project Title?
I don't know why you want a URL . . . is this stack going to turn the cloned card into a web page?

Possibly what you want is a button on the front card of the stack
that will send you to the cloned "card with its unique Project Title".

I'm just running round the corner to the vet's as our cat needs her annual immunisation injection.

Then I'll have a 'bash' at that idea. 8)
on the cloned card, the user gives the card a name, 'Project Title'
How?

dalkin
Posts: 183
Joined: Wed Jul 04, 2007 2:32 am
Contact:

Re: Link to cloned card

Post by dalkin » Tue Oct 01, 2019 10:31 am

Cats $$$$$ been there, done that.

By URL I simply meant a link to the card .. the Project Title is simply a text field where the use gives the card a unique identifier for reference in eg. navigation .. let's suppose the title is "My Poem", or "The Owl and the Pussycat". It's my intention that each card is a self-contained workspace for manipulating text and importing a sound file of eg. the completed work. The primary objective is to provide text tools for playing with the text in various ways. In the Screenshot, I achieve that by using 'selectedText of Me'.
The underlying purpose of Al is to allow wealth to access skill
while removing from the skilled the ability to access wealth.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10097
Joined: Fri Feb 19, 2010 10:17 am

Re: Link to cloned card

Post by richmond62 » Tue Oct 01, 2019 1:42 pm

So what you are looking for is something like this:

A button containing this:

Code: Select all

on MouseUp
go to card "LatestThing"
end mouseUp
Here's something to play with:

Code: Select all

on mouseUp
   ask "What should your card be called?"
   put it into IMENA
   if IMENA is not empty then
      clone btn "Cheese"
      set the name of it to IMENA
      put the script of btn "Cheese" into SKRIPT
      replace "Cheese" with IMENA in SKRIPT
      set the script of btn IMENA to SKRIPT
      clone card id 1004
      set the name of it to IMENA
   end if
end mouseUp
This clones a card, clones a button on the frontmost card,
names the new card, names the new button the same thing as the new card,
and generally does what you are looking for.

Download the stack: tear it to pieces, and have some fun. 8)
Attachments
Clone Wars.livecode.zip
Here's the stack.
(7.66 KiB) Downloaded 265 times

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7390
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Link to cloned card

Post by jacque » Tue Oct 01, 2019 5:49 pm

I think the OP is looking for a list field that links to a card of the same name as the clicktext. No buttons involved. I'm not at my computer but the idea is this:

Set the style of the index field to list using its property inspector. In the index field put a mouseUp handler that gets the clicktext. Assuming that's the name of a card, you can then go there.

When a field is set up as a list field, the clicktext will retrieve the entire line which makes text retrieval easier for this sort of thing. Maybe someone else can provide a more detailed handler than I can manage typing on my phone.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10097
Joined: Fri Feb 19, 2010 10:17 am

Re: Link to cloned card

Post by richmond62 » Tue Oct 01, 2019 5:53 pm

I think the OP is looking for a list field
Indeed: but I'm not going to do all the heavy lifting. :D

Klaus
Posts: 14192
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Link to cloned card

Post by Klaus » Tue Oct 01, 2019 6:43 pm

Hi dalkin,

is that what Jaques wrote what you are after? OK, then do this:
1. To understand LC better you should go to the -> LC Preferences -> General
and check -> Property labels are: Name of Livecode property
The inspector will now show the NAME of the LC property and not the description of that property.
This way you can see what you can use in your scripts!

2. Get used to also NAME all of your cards! You will admit that:
card "index"
is a BIT better to memorize than:
card ID 4711 :-)

3. You can "concatenate" strings (text) and then use it "en bloc" like this:

Code: Select all

on returnInField
  ## Once you have set this property for the field in the inspector, 
  ## there is no need to do this every time you access the field!
  ## set the textStyle of field "Title" to link
  ## put return before line 1 of field "Index" of card id 1130 //card 1130 contains the scrolling list

  ## This does what you want:
  put field "Title" & CR before field "Index" of card id 1130
end returnInField
4. Now add this "mouseup" handler to your LIST field -> index

Code: Select all

on mouseup

  ## put the complete selected line into a variable
  put the selectedtext of me into tCard

  ## ALWAYS do checks like this, you are now the programmer and repsonsible for EVERYTHING
  ## Especially if the USER fucks up, it is all YOUR fault! :-D
  if there is a card tCard then
  
    ## There is a card with that name, so we simply go to that card.
    go cd tCard
  end if
end mouseup
Best

Klaus

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

Re: Link to cloned card

Post by FourthWorld » Tue Oct 01, 2019 10:33 pm

The current card is always addressable as "this card", and only one card can be viewed at a a time.

Given that, a set of scripts at the stack level should operations on anything within a given card without variance, no matter which card is being shown at a time.

If you need to access things from other cards while on a given card, the best way to do that will depend on what is being done. But there, as with most objects, giving cards meaningful names that uniquely identify them will make such things simple.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

dalkin
Posts: 183
Joined: Wed Jul 04, 2007 2:32 am
Contact:

Re: Link to cloned card

Post by dalkin » Wed Oct 02, 2019 10:47 am

Thank you to everyone who contributed to this reply. Much appreciated. In the end, I adapted the workflow described by Klaus (renaming the cards as advised), with the simple addition as follows:

on returnInField
set the name of this card to field "Title" \\ else the call to tCard from the scrolling list field has nothing to work with :D
put the name of this card into tCard
put return before line 1 of field "Index" of card "Navigation"
put field "Title" before field "Index" of card "Navigation"
end returnInField

I can only think that this will be incredibly useful in many situations to many developers. It's so simple but it's terrific functionality.
The underlying purpose of Al is to allow wealth to access skill
while removing from the skilled the ability to access wealth.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10097
Joined: Fri Feb 19, 2010 10:17 am

Re: Link to cloned card

Post by richmond62 » Wed Oct 02, 2019 11:01 am

It's so simple but it's terrific functionality.
That should be written in great, big letters on the front page of LiveCode's website. :D

Post Reply