Pasting Data from Runtime Revolution to a Document

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller, robinmiller

Post Reply
trailboss
Posts: 112
Joined: Sat Dec 13, 2008 4:55 pm

Pasting Data from Runtime Revolution to a Document

Post by trailboss » Wed Mar 13, 2013 7:16 pm

I want to make an application that takes data from a runrev field and pastes it into a document like word, or powerpoint, etc.

I've tried lots of the scripting I've found and it doesn't work for me.

Here's my try now. It opens the file, but doesn't paste. I need to do this another way. Many thanks! TOM IN ARIZONA

on mouseUp
put cd fld sortfield into x
set the clipboardData ["text"] to x
put "/users/tomcole/test.rtf" into tfilepath
launch document tfilepath
get the clipboardData
write the clipboardData to file tfilepath
end mouseup

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am
Location: Palo Alto

Re: Pasting Data from Runtime Revolution to a Document

Post by Simon » Wed Mar 13, 2013 11:30 pm

Hi Tom,
You have a couple of odd things in your script I don't understand, but try this:

Code: Select all

on mouseUp
   set the defaultFolder to specialFolderPath("desktop")
   put fld "sortfield" into url "file:test.rtf"
   launch document "test.rtf"
end mouseUp
I'm not sure if that is what you wanted, if not just say.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

trailboss
Posts: 112
Joined: Sat Dec 13, 2008 4:55 pm

Re: Pasting Data from Runtime Revolution to a Document

Post by trailboss » Thu Mar 14, 2013 12:20 am

Well, it opened the file once I think when I put it on the desktop as I guess the script says, but nothing was pasted into the file.

Also, I couldn't ever get it to launch the document again. It just says "the document 'test.rft' could not be opened." It has been corrupted somehow. Now I can't open it at all.

I keep making a new file with the same name, and it immediately becomes unusable when I click the button.

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3422
Joined: Sun Jan 07, 2007 9:12 pm
Location: Bochum, Germany

Re: Pasting Data from Runtime Revolution to a Document

Post by bn » Thu Mar 14, 2013 12:33 am

Hi Tom,

well your file ending signifies RTF (rich text format) but you put plain text into the document.

I tried the following code on a Mac and it works:

Code: Select all

on mouseUp
   set the defaultFolder to specialFolderPath("desktop")
   put the rtfText of fld "sortfield" into url "file:test.rtf"
   launch document "test.rtf"
end mouseUp
it opens the document in TextEdit as RTF

Kind regards
Bernd

trailboss
Posts: 112
Joined: Sat Dec 13, 2008 4:55 pm

Re: Pasting Data from Runtime Revolution to a Document

Post by trailboss » Thu Mar 14, 2013 1:15 am

Wow. That sure works. Thanks all around. I'm thinking of ways to input data into powerpoint and other kinds of documents and this gets me started.

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3422
Joined: Sun Jan 07, 2007 9:12 pm
Location: Bochum, Germany

Re: Pasting Data from Runtime Revolution to a Document

Post by bn » Thu Mar 14, 2013 10:17 am

Hi Tom,
I'm thinking of ways to input data into powerpoint and other kinds of documents and this gets me started.
mind you Powerpoint and many other programs have their unique file/data structure. It will probably not be possible to generate documents in above way for them.

You would have to explain more in detail what you are trying to achieve. Using the clipboard might be possible depending on object type.

Kind regards
Bernd

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2530
Joined: Sat Dec 22, 2007 5:35 pm
Location: Genève
Contact:

Re: Pasting Data from Runtime Revolution to a Document

Post by jmburnod » Thu Mar 14, 2013 11:32 am

Hi,
I never used "send to program" and nobody, even Bernd and his angels staff speaks about it. :shock:
I thought that was a way to send a message like "paste text"

Kind regards
Jean-Marc

trailboss
Posts: 112
Joined: Sat Dec 13, 2008 4:55 pm

Re: Pasting Data from Runtime Revolution to a Document

Post by trailboss » Fri Mar 15, 2013 4:13 pm

Well, I have another question.

Here's how I have learned to create a powerpoint document and "paste" data into it. The field MyData has five lines of text. When this script is run, it creates a PPT document with five "slides." There's a "slide" for each line. Each line of text is the TITLE of the slide. Good so far, but how can I also "paste" data into the TEXT area below the PP slide title? Can I create perhaps some two-tiered hierarchy within Runtime Rev and then create a PP doc with slides containing BOTH a title AND the text below it -- or even add a graphic?

Thanks in advance for your help

on mouseUp
open file specialFolderPath("desktop") & "/Data in a PowerPoint Document.ppt" for write
put cd fld "MyData" into localvariable
put localvariable into myText
write myText to file specialFolderPath("desktop") & "/Data in a PowerPoint Document.ppt"
close file specialFolderPath("desktop") & "/Data in a PowerPoint Document.ppt"
launch document specialFolderPath("desktop") & "/Data in a PowerPoint Document.ppt"
end mouseUp

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am
Location: Palo Alto

Re: Pasting Data from Runtime Revolution to a Document

Post by Simon » Fri Mar 15, 2013 11:00 pm

I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

trailboss
Posts: 112
Joined: Sat Dec 13, 2008 4:55 pm

Re: Pasting Data from Runtime Revolution to a Document

Post by trailboss » Fri Mar 15, 2013 11:15 pm

Nice! It does just what I wanted it to do.

Just tabs for the hierarchy. What could be simpler? I should have thought I would have hit upon that myself!
Thanks very much indeed.

Any ideas on writing something in the file that will put a graphic on the slide? Or should I make a new Topic for that?

Tom in Arizona

Post Reply

Return to “Talking LiveCode”