Page 1 of 2

Import file

Posted: Sat Dec 29, 2012 11:49 pm
by trailboss
Well, I'm not a beginner but I'm not ashamed to say that this is a beginner question.
I want to view a jpeg file in a Runtime Rev application that I've made. I don't know how to do this simple thing. I try "open file NovJournal.jpg" and nothing happens.

I have a bird database and I'm entering in 37 years of my parents' bird notes from our house in Mexico. The bird entry is easy, but they've written journals out longhand, and I'm tired of entering it all by typing so I thought I'd scan each page and make it available. If I scan a page a day, I'll be done in a few years.

Any ideas on how I might incorporate scanned writing into a database for viewing would be appreciated, but as I said I don't even know how to get the file to open using RunRev.

Thanks
Tom

Re: Import file

Posted: Sun Dec 30, 2012 6:07 pm
by Mark
Hi Tom,

Pictures are displayed in an image object. Your script needs to create one first and then put the picture data into the image control.

Code: Select all

create img "New Image"
put the long id of it into myImageID
set the text of myImageID to url ("C:/path/to/NovJournal.jpg")
Kind regards,

Mark

Re: Import file

Posted: Sun Dec 30, 2012 6:16 pm
by trailboss
Thanks, Mark
I've tried:

on mouseUp
create img "New Image"
put the long id of it into myImageID
set the text of myImageID to url ("computer/macintosh hard drive/users/tomcole/retirement folder/estero morua bird database/December5_1975.jpg")
end mouseUp

Nothing happens, however.

Tom

Re: Import file

Posted: Sun Dec 30, 2012 6:21 pm
by Mark
Hi Tom,

Doesn't LiveCode create an image object?

You can view the correct file path in the message box with the syntax

Code: Select all

answer file ""
put it
Select your file in the file dialog and check the file path in the message box.

Kind regards,

Mark

Re: Import file

Posted: Sun Dec 30, 2012 6:38 pm
by FourthWorld
The "text" property of an object is its contents. In fields it's the textual data displayed, and in images is the imageData.

To assign an image file to an image object use that object's filename property.

Re: Import file

Posted: Sun Dec 30, 2012 6:46 pm
by Mark
Hi,

If you use the filename property of an image object, you're not actually importing that file. OP is asking how to import a file, not how to display a picture on disk. Using the filename property could be an alternative to importing a file, but that solution doesn't answer the OP's question.

If you set the imagedata to the contents of a picture file, you'll get garbage. You have to use the text property, not the imagedata.

Kind regards,

Mark

Re: Import file

Posted: Sun Dec 30, 2012 6:55 pm
by trailboss
I've checked the CARD INSPECTOR and the scripting does create an image but it is kind of invisible. I can select it and that's all. I guess I don't know what I'm doing as usual. I can import my images as controls and put them on pages. And view them that way. Is there an advantage to the way you are suggesting?

Re: Import file

Posted: Sun Dec 30, 2012 6:59 pm
by Mark
Hi,

Whom are you asking?

It seems to me that you wanted to do this by script and that you wanted to actually import the file. The script I posted does this.

Mark

Re: Import file

Posted: Sun Dec 30, 2012 7:07 pm
by trailboss
I was asking Mark. Thanks for your help. I'll keep diddling with this. I can import the files as controls though.
Many thanks,
Tom

Re: Import file

Posted: Sun Dec 30, 2012 7:15 pm
by Mark
Hi Tom,

If it is sufficient for you to import the picture files as control through the File menu, then there is no reason not to use it. I guess that solves it.

Kind regards,

Mark

Re: Import file

Posted: Sun Dec 30, 2012 7:20 pm
by FourthWorld
Mark wrote:If you use the filename property of an image object, you're not actually importing that file. OP is asking how to import a file, not how to display a picture on disk. Using the filename property could be an alternative to importing a file, but that solution doesn't answer the OP's question.
Maybe. The OP wrote:
"I want to view a jpeg file in a Runtime Rev application that I've made."
He also mentioned that he has a good may of these images to view. As journal pages I'd guess they're at least 500x700px, possibly larger if scanned at a good resolution. Importing all them into a stack may be overkill, requiring a lot of memory.

Unless there's some specific reason why it would be essential to import them, I'd just leave them on disk and set the filename of an image object.

Re: Import file

Posted: Sun Dec 30, 2012 7:47 pm
by Mark
Hi,

I think you're repeating yourself.

Mark

Re: Import file

Posted: Sun Dec 30, 2012 11:04 pm
by trailboss
Yes, there are a zillion scanned images or there will be. They're big, so I guess it would be best to just view the image. I put a couple in, and they're so big that it takes a second to go from one card to the next. There's an icon on the tools palette called image area. If I make one of those and stick it on a single card it would be nice to make it display the jpg image. Each image that I will store on my hard drive will have as its name a date. It would be good to enter a date and have the image object display the scanned journal page. I just can't get an image object to display. I guess it must be my path or something. computer/macintosh hard drive/users/tomcole/retirement folder/estero morua bird database/december5_1975.jpg

Re: Import file

Posted: Mon Dec 31, 2012 12:03 am
by Simon
Hi Tom,
There seems to be too much going on here as what you are asking for is too simple.(I think) As I understand it you just want to show an image, maybe be able to change that image to use just a single card.
On a card use the image tool to drag a square into it, in the inspector call it myImage
In a button script put this code;

Code: Select all

on mouseUp
ask file "Please select an image." -- this is just to get you started, select one of your image files
put it into tFilePath
breakpoint -- Take a look at the tFilePath now.  Remove this breakpoint when you are ready
set the filename of img "myImage" to tFilePath
end mouseUp
Will help more once you've seen how this works.

Simon

Re: Import file

Posted: Mon Dec 31, 2012 11:19 am
by Mark
Hi Simon,

I'm pretty sure that you mean "answer file" instead of "ask file" because "ask file" won't let you select a file but rather enter a file name in a particular folder to generate a file path where a new file can be written.

I think your script should be

Code: Select all

on mouseUp
  answer file "Please select an image."
  if it is not empty then
    put it into tFilePath
    put tFilePath // display path in message box
    set the filename of img "myImage" to tFilePath
  end if
end mouseUp
Tom, your file path is indeed wrong, as I already indicated in my previous posts. You must have a look at the file path returned by the answer file command, which I also already demonstrated in an earlier post.

Kind regards,

Mark