Add file to Custom Property

Mark Wieder mwieder at ahsoftware.net
Thu Mar 18 17:15:14 EDT 2010


Bill-

Thursday, March 18, 2010, 2:04:21 PM, you wrote:

> So I'm getting close on this. The "Save file" button script seems
> to work fine. The custom property looks to be encrypted.

> Button "Save File"
> on mouseUp
>    answer file "Please select a file..."
>    put it into lFileToRead
>    set the itemDelimiter to "/"
>    answer the last item of lFileToRead
>    -- Read the binary contents of a file into a variable
>    open file lFileToRead for binary read
>    read from file lFileToRead until end
>    close file lFileToRead
>    put it into vFile
>    encrypt it using "blowfish" with "biff" at "128" bit
>    set the uFileStore of me to it
>    set the uFileName of me to the last item of lFileToRead
> end mouseUp

> The following script doesn't actually save the file but I'm not sure why.
> Button "Save and open file"
> on mouseUp
>    ask file "Save file to;" with  the uFileName of button "Save File"
>    put the uFileStore of button "Save File" into vEncryptedFile
>    decrypt vEncryptedFile using "blowfish" with "biff" at "128" bit
>    put vEncryptedFile into URL ("binfile:" & it)
>    set the filetype to ""
>    launch document it
> end mouseUp

I don't trust the "it" variable enough to do what you're trying to do.
The decrypt command is documented as placing the decrypted data into
the it variable, so your file specifier is probably getting destroyed
in the process. I'd do

ask file...
if it is not empty then
  put it into tFilePath
end if

-- and then
put vEncryptedFile into url ("binfile:" & tFilePath)
...
launch document tFilePath

-- 
-Mark Wieder
 mwieder at ahsoftware.net




More information about the use-livecode mailing list