[VApp] How do I import a picture?

Ruslan Zasukhin sunshine at public.kherson.ua
Thu May 8 11:24:05 CDT 2003


on 5/7/03 10:30 AM, David Hood at david.hood at stonebow.otago.ac.nz wrote:

Hi David,

Funny. I have go to look on VAP download page,
And have found YOUR "Automated trimming of scanned images". :-)

Andy, are you here? Am I right that you was able copy images from FileMaker
to VAPP via AS? IF yes, can you help us with HOW TO ?

David, as I see from your script you have store picture into BLOB field.
Yes this will also works, at least until you do not want to use this
database with e.g. Valentina for REALbasic.

I wonder, can you try simply replace in CREATE TABLE BLOB on Picture.,
And see if this will also works.  NOTE, this will works only if you will
send PICT format picture to Valentina.
If you want send ready existed GIFBL_IDSet, JPGs TIFFs, then for now yes,
use BLOB field..

> For the spurious reason no one else seems to have done it, I decided to
> work out how to import binary information using only applescript. Many
> hours later I present the definitive example script - this creates a
> database called 'imagine' on the desktop, prompts for a binary file
> (i.e. a picture, image or whatever) to store in the database, stores
> the binary data, then draws the file back out of the database and saves
> it to the desktop.
> Known caveats:
> - Since I've used strings for building path info it may do odd things
> on non-latinate path/file information.
> - Don't use a binary file on the desktop, or indeed have any file there
> of the same name as the one you choose (unless you really want the
> example to overwrite it).
> - Because of quirks associated with applescripts I/O I would not depend
> on it using files greater than 20M.
> - I have no idea if this is compatible with other ways of working with
> valentina's blob fields
> - Tested on OS 10.2.5, VAPP 1.9.7b6
> - If run in system 9 you may need to increase the memory of script
> editor depending on the size of the binary.
> - Some of the lines in the script may be word wrapped so that will need
> to be fixed when compiling in script editor
> 
> Regards,
> David Hood
> 
> ------------------------
> set someDatabase to (path to desktop as string) & "Imagine"
> 
> CreateDB(someDatabase)
> set fileNameForNextPart to exampleAddRecord(someDatabase)
> exampleFileExport(fileNameForNextPart, someDatabase)
> ------------------------
> on CreateDB(DBname)
> tell application "Valentina Carbon"
> set theDB to make new database with data file DBname
> 
> tell theDB
> SQL Execute "CREATE TABLE binaryFiles (" & ¬
> "fileName String(30) NOT NULL," & ¬
> "fileType String(4) NOT NULL," & ¬
> "creatorType String(4) NOT NULL," & ¬
> "binaryData BLOB(512) )"
> end tell
> end tell
> close theDB
> end CreateDB
> -----------------------
> on exampleAddRecord(DBname)
> 
> set pathstring to choose file with prompt "Binary file to Input:"
> try
> set inputFile to open for access pathstring
> set fileData to read inputFile as data
> close access inputFile
> on error errMsg number errNum
> try
> close access pathstring
> end try
> error errMsg number errNum
> end try
> 
> tell application "Finder"
> set ctype to creator type of pathstring as string
> set ftype to file type of pathstring as string
> set fname to name of pathstring as string
> end tell
> 
> 
> tell application "Valentina Carbon"
> set DB to open file DBname
> tell DB
> set curs to SQL Select "SELECT * FROM binaryFiles"
> end tell
> make new record with data {fname, ftype, ctype, fileData} at end of
> curs
> close DB
> end tell
> return fname
> end exampleAddRecord
> 
> --------------------
> on exampleFileExport(searchCriteria, DBname)
> tell application "Valentina Carbon"
> set DB to open file DBname
> tell DB
> set theCursor to SQL Select "SELECT * FROM binaryFiles"
> end tell
> 
> set fileN to contents of field "fileName" of record 1 of theCursor
> set fileT to contents of field "fileType" of record 1 of theCursor
> set creatorT to contents of field "creatorType" of record 1 of
> theCursor
> set binaryD to contents of field "binaryData" of record 1 of theCursor
> delete theCursor
> close DB
> end tell
> 
> tell application "Finder"
> set fileOutput to (make new file in desktop with properties
> {name:fileN, creator type:creatorT, file type:fileT}) as string
> end tell
> try
> set binaryOutFile to open for access file fileOutput with write
> permission
> set eof of binaryOutFile to 0
> write binaryD to binaryOutFile
> close access binaryOutFile
> on error errMsg number errNum
> try
> close access file fileOutput
> end try
> error errMsg number errNum
> end try
> 
> end exampleFileExport
> 
> _______________________________________________
> Valentina mailing list
> Valentina at lists.macserve.net
> http://lists.macserve.net/mailman/listinfo/valentina

-- 
Best regards,
Ruslan Zasukhin      [ I feel the need...the need for speed ]
-------------------------------------------------------------
e-mail: ruslan at paradigmasoft.com
web: http://www.paradigmasoft.com

To subscribe to the Valentina mail list go to:
http://lists.macserve.net/mailman/listinfo/valentina
-------------------------------------------------------------



More information about the Valentina mailing list