how to copy

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
robm80
Posts: 161
Joined: Sat May 03, 2014 7:15 am

how to copy

Post by robm80 » Thu May 08, 2014 12:52 pm

In the messagebox:
put text of field "pagename" of me into tLine
copy tLine to clipboard

answer:Function: missing '('
or
copy char 1 to -1 of field "pagename" of me to clipboard
answer:Function: missing '('
or
copy char 1 to -1 of field "pagename" of me
answer :clipboard: invalid text'

The copy I want is to get the text of field "pagename" in the clipboard to use it elsewhere.

LCNeil
Livecode Staff Member
Livecode Staff Member
Posts: 1223
Joined: Wed Oct 03, 2012 4:07 pm

Re: how to copy

Post by LCNeil » Thu May 08, 2014 1:06 pm

Hi robm80,

You will need to use the clipBoardData property for this-

Code: Select all

   set the clipboardData["text"] to field "pagename"
Kind Regards,


Neil Roger
--
RunRev Support Team ~ http://www.runrev.com
——

robm80
Posts: 161
Joined: Sat May 03, 2014 7:15 am

Re: how to copy

Post by robm80 » Thu May 08, 2014 2:41 pm

Hi Neil,
Many thanks. It works.
How difficult is LiveCode compared with Toolbook!
Rob

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

Re: how to copy

Post by FourthWorld » Thu May 08, 2014 3:46 pm

robm80 wrote:How difficult is LiveCode compared with Toolbook!
It's often simpler, since your earlier example:

Code: Select all

copy char 1 to -1 of field "pagename" of me to clipboard 
...can execute in LC with just:

Code: Select all

copy char 1 to -1 of field "pagename" of me
It's the "to clipboard" part that was throwing it off. A quick visit to the Dictionary entry for the copy command shows no examples that include "to clipboard", which is sensible enough because the clipboard is the default destination for copied text and objects*.

The other syntax using the internal clipboardData array that Neil showed is for more extended functionality, offering a finer level of control than I recall having with Toolbook when I used it back in the day.

For example, the copy command will faithfully copy not only the text but also the style runs, but if you want to refine that to copy only the plain text stripped of all styles then the example provided by Neil will do the trick.

The other nice thing about Neil's array syntax example is that it hints at other array keys, which can be very useful in certain circumstances. Check out the Dictionary entry for clipboardData, and consider for example how you can set the clipboardData["htmlText"] to styled text constructed on the fly in a variable. or set the clipboardData["image"] to a snapshot of an object.

Lots of flexibility in LiveCode, and while my experience with ToolBook was limited to one project for a major retail chain I can remember only a handful of things it offered that I'd like to see added to LiveCode, while many LC things I'd love to see in TB.


* I wrote "default" because another nice extension to LiveCode is the ability to copy object from one container to another without modifying the user's clipboard, by specifying a destination object with "to", e.g.:

Code: Select all

copy group "MyCustomControl" of stack "MyTemplateObjects" to group "DrawingPane" of stack "MyCoolDrawingApp"

PS: I just added a bug report suggesting that your first example, "copy the text of <field specifier>", should also be supported:
http://quality.runrev.com/show_bug.cgi?id=12412
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

atout66
Posts: 266
Joined: Wed Feb 02, 2011 12:31 pm

Re: how to copy

Post by atout66 » Thu May 08, 2014 4:56 pm

robm80 wrote:How difficult is LiveCode compared with Toolbook!
Welcome to the club :wink:

A other post about copying with LC here :http://forums.runrev.com/viewtopic.php?f=7&t=20233

Kind regards, Jean-Paul.
Discovering LiveCode Community 6.5.2.

Post Reply