Jump to content

Script to Export Image, then Insert file of that same image


This topic is 4500 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Hi,

I'm creating a IWP database of children's games.The games have worksheets which are displayed as images in a container field. In IWP, these images can't be downloaded to the user unless I Insert the image as a file (not stored a reference) in another field. I've got 1000's of worksheets so is there a script I can make that will essentially;

Export field contents ('IMAGE' field; of Worksheet image.gif, to the temp folder)

Insert file (into 'FILE HOLDER' field;of .gif just exported, don't store as reference)

I have tried for two days to get this working, but I just can't do it.

Or is there another way for the IWP client to download the image apart from what I am trying to do or "right-click, save image as"

Please help. I am tearing my hair out

Thanks so much in advance

Link to comment
Share on other sites

I don't think you need to export the container field, since the image files already exist on your hard drive and Filemaker knows where they live. Try something like:

Show All Records

Go to Record [ First ]

Loop

Set Variable [ $path ; GetValue ( YourTable::IMAGE ; ValueCount ( YourTable::IMAGE ) ) ]

Insert File [ YourTable::FILE HOLDER ; $path ]

Go to Record [ Next ; Exit after last ]

End Loop

Link to comment
Share on other sites

Hi There,

Thanks for the quick reply. I tried the script you suggested, but upon running it, I get the message 'The file ********.gif' cannot be found. I manually found the file and the rest of the script worked fine to insert the file. I have attached a screenshot of the script. I haven't put all the loops in, as some records won't have worksheets. Please let me know where I am going wrong.

Thanks so much,

Have a great day!

post-105445-0-15911600-1322835810_thumb.

Link to comment
Share on other sites

HI,

Yes, trying to solve the issue myslef, I created a new field with the calculation;

GetValue ( Attachment1::Attachment Image ; ValueCount ( Attachment1::Attachment Image ) )

The result was always exactly the same name as the file as the file that I was trying to 'Locate' and then 'Insert'.

Every worksheets name is always the same as the name of the game. I.e. 'Battleships' game has a worksheet named 'battleships.gif', which is the file I want to insert as a file.

The database is set up with a table 'Worksheet images' related to the 'Games' table, by the calculation field 'Game Name & ".gif".

The 'Worksheet Images' table has all its images imported from a folder, which I have not moved or deleted.

Just a note, the attached image I sent you seemed in most aspects identical to the script you suggested for me but except for where exactly to put the getvalue.... part. Did I make a mistake with my script?

Thanks a million in advance.

Link to comment
Share on other sites

I created a new field with the calculation;

GetValue ( Attachment1::Attachment Image ; ValueCount ( Attachment1::Attachment Image ) )

Good - now could you copy the contents of the field and post it here? Make sure you copy the entire contents - there should be 2 or 3 paragraphs there.

Link to comment
Share on other sites

The contents of this calculation field is only the exact name of the gif file. Thus in the game Battleships, the image displayed was gotten from the file 'Battleships.gif' and the entire contents of the new calculation field is only that;

'Battleships.gif'

In other records where I pasted a Bitmap into the container field in the 'Worksheet Images', the contents of our getvalue calculation is simply a question mark (?)

I am a little bit lost

Thanks so much

Link to comment
Share on other sites

It is embedded. It is not a reference.

Furthermore, a lot of the embedded files have been been 'Insert File' by me from various locations.

Isn't the sure way to achieve this to;

1. Export embedded file container contents to temp folder

2. Insert that very file from the temp folder having stored its location

Thanks a bunch!

Link to comment
Share on other sites

Now I'm confused. I took your post to mean that you have referenced many files and now you wish to have them embedded for use with IWP.

If they are already embedded, what is it you're trying to do?

Link to comment
Share on other sites

I have a games database for children. There is a game description and an IMAGE of the worksheet as part of the game description. The database is for IWP use. The client needs to be able to download that worksheet. It can obviously be done with Right-click, save image as. But many teachers are not that computer proficient.

So, as well as the IMAGE of the worksheet, I have another field underneath where I have simply inserted the file (Which shows up as the icon with the filename, not an image) This file too cannot be stored as an image because then it won't be available on IWP. Thus, the users can view an image of the worksheet, and below it simply click the link and download that worksheet.

The images of the worksheets are mostly already in their place, embedded. I don't want to go through 1000's of records, go and find that .gif and then insert file. Export field contents is another option, and then insert that very file.

Or am doing something here that doesn't make sense?

Thanks so much

Link to comment
Share on other sites

Isn't the sure way to achieve this to;

1. Export embedded file container contents to temp folder

2. Insert that very file from the temp folder having stored its location

Yes, that is the way to proceed. However, you must process the inserted images separately from the pasted ones. The inserted ones are easy, because you have the name and the format of the file. For the pasted ones, you should find out the format by attempting to export the contents manually and observing the file extension suggested by Filemaker.

Link to comment
Share on other sites

is that going to make it complicated?

Hopefully not. Try setting the $path variable to =

Get ( TemporaryPath )

&

Case ( YourTable::IMAGE = "?" ; YourTable::Name & ".bmp" ; YourTable::IMAGE )

and then:

Export Field Contents [ YourTable::IMAGE ; $path ]

Insert File [ YourTable::FILE HOLDER ; $path ]

However, I am not sure embedding "1000's of worksheets" inside your file - twice! - is such a good idea. Perhaps you should consider exporting them into a permanent location and referencing them from there.

You might also take a look at SuperContainer:

http://www.360works....supercontainer/

  • Like 1
Link to comment
Share on other sites

Your script Worked! You're a genius!!! Thanks so much.

However, I am not sure embedding "1000's of worksheets" inside your file - twice! - is such a good idea. Perhaps you should consider exporting them into a permanent location and referencing them from there.

As I understand it, a referenced file is not available for download in IWP, so that why I don't have it referenced.

I had a look at the supercontainer. Is it so much more advantageous for IWP?

Thanks so much and have yourself a wonderful weekend.

Link to comment
Share on other sites

This topic is 4500 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.