Inserting graphic into a field

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
edgore
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 197
Joined: Wed Jun 14, 2006 8:40 pm

Inserting graphic into a field

Post by edgore » Thu Jul 30, 2009 5:00 pm

Is there any way to insert a graphic into a field? I thought I remembered there being some way to do something like "set the image of char 1 of field myField to image "blah"" or something like that that, but after searching through the docs I cannot seem to find any reference to that functionality any more. I am currently using 3.0.

Here is what I am actually trying to accomplish...

I have an application that pulls a random sample from a larger population - you tell it what your total population, click a button, and then it applies a bunch of rules based the total size of your population, a minimum allowable sample size, a maximum required sample size, and (currently) spits out a text files that contains a list of the items thatyou should include in your sample. Currently the applciaiton saves this as a text file. However, this year they want the output to be something less editable. I can easily modify the application to spit out a image file instead of a text file, which would work, except that later Iwant to be able to reload the orginal sample and potentially pull an expanded sample from the same population that. To to this I need to be able to load the original sample, and generate a new set of unique samples in addition to the original items. In order to do that, I need to have the items included in the original sample available inthe saved file in some format that I can read back in and process - obviously an image file is not going to work for that.

Also, the client wants the output from this application to be openable in "some commonly available application, like Word", so using a rev stack as my data file is out.

I was hoping that I could create an off-screen field that contains an image of the list of samples, along with a text list of the original samples, then I could save out the RTF text of that field to a file, which would be openable in word, while at the same time my app could load the RTF file and parse out the text list of existing samples in order to exclude these from the resample. Unfortunately, I can't figure out how to put animageinto a field to allow me to do this.

I could build the RTF file myself, but I was hoping I could avoid figuring out the RTF format on my own and just let Rev handle that on it's own.

If anyone would like to see the existing application, which just outputs text files I have uploaded a copy to my website at http://www.edgore.com/Sampler_2.02.rev and I will keep it up there for a while (at least until I figure out what I need to do to make this work)

edgore
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 197
Joined: Wed Jun 14, 2006 8:40 pm

Post by edgore » Thu Jul 30, 2009 5:28 pm

Found it! It's the imagesource property. Now to experiment and see if the RTF export icludes the image data.

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9842
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Post by FourthWorld » Thu Jul 30, 2009 6:14 pm

RTF files usually embed images; not sure if they support linked images, but perhaps worth a try.

This may also be useful:
http://curryk.com/wordlib.html
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Thu Jul 30, 2009 7:48 pm

Hi Edgore,

You could write a script that exports the HTML text to a file and the pictures to a folder next to that file. That would allow the client to open it in an internet browser, which I would call a "commonly available application".

Best,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

edgore
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 197
Joined: Wed Jun 14, 2006 8:40 pm

Post by edgore » Thu Jul 30, 2009 8:14 pm

Unfortunately, for the client I am working with multiple files and having to keep stuff together would only confuse them - I've gotta figure out a single file solution (or convince them that having the output be "uneditable" is stupid, which it is...)

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Thu Jul 30, 2009 9:16 pm

Hi Edgore,

Then you might want to figure out how NeoOffice/OpenOffice creates HTML documents. It should be possible to put everything into one file. It is more complicated, but still doable.

Is there any reason why you wouldn't simply create a "stack player" for them, which they can use to view all the data in stacks?

Best,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

edgore
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 197
Joined: Wed Jun 14, 2006 8:40 pm

Post by edgore » Thu Jul 30, 2009 9:22 pm

I have thought about looking at something like the mht format (which is an all-in-one-file html file format like what you mention), but have not started to go down that track yet, since I *should* be able to figure out rtf.

The client doesn't want to have to distribute a reader, which is why I am trying to figure out another way to do this.

It looks like the rtftext of a field is really, just like it says, only the text. I am hoping that I can figure out the encoding used by rtf to insert an image. according to microsoft the control word (the rtf equivalent of markup) for inserting an image is \bin, but I still need to figure out the correct encoding. I assumed it would be base64, but that assumption appears to be wrong.

keyless
Posts: 211
Joined: Wed Dec 12, 2007 11:21 pm

Post by keyless » Thu Jul 30, 2009 9:29 pm

What your describing seems best done with PDF. Quantum Reports or some sort of html to PDF, or maybe PDF printer driver methods.

word, RTF are very editable compared to PDF which can even be locked from edit.

now getting data from PDF might be tricky, but I once worked for a company that used ghost script to parse data from PDF, and there are pdf2txt and other convertersaround too I think.

edgore
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 197
Joined: Wed Jun 14, 2006 8:40 pm

Post by edgore » Thu Jul 30, 2009 9:51 pm

the "uneditable" part would be provided by the image file in the RTF, which would be relatively uneditable, since it would be encoded.

Actually, after thinking about Mark's suggestion I am goingto go with using mht for thefile format, which is basically a mime-encoded html file that includes the picture data base64 encoded.

This will let me create an image in RunRev, encode it in RunRev, encode it in RenRev, then put together a textfile with my data, the encoded image, and all the markup needed to display the thing in Explorer (which in the client's environment is the standard browser).

This should do it.

Thanks to all.

Curry
Posts: 111
Joined: Mon Oct 15, 2007 11:34 pm
Location: USA
Contact:

Re: Inserting graphic into a field

Post by Curry » Sat Apr 24, 2010 6:27 am

WordLib allows import Word and OpenOffice documents (including graphics with .docx or .odt) and it is available now. WordOut allows exporting to those document formats, and it's coming soon, currently in beta.
Best wishes,

Curry Kenworthy

LiveCode Development, Training & Consulting
http://livecodeconsulting.com/

WordLib: Conquer MS Word & OpenOffice
SpreadLib: "Excel-lent" spreadsheet import/export
http://livecodeaddons.com/

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”