Add file to Custom Property

Jim Ault jimaultwins at yahoo.com
Sat Mar 13 15:16:14 EST 2010


--First you should do something to allow the user to cancel, such as

      if it is empty then exit to top

-- now
      put it into pathAndFilenameToRead -- not just the file name

--either
      put url ("binary:" & pathAndFilenameToRead) into binFileInVariable
      set the uFileStore of me to binFileInVariable
--or one step and no memory variable is created

--so it becomes 3 lines and user friendly + memory friendly
> on mouseUp

> answer file "Please select a file..."

       if IT is empty then exit to top
      set the uFileStore of me to url ("binary:" & IT)
> end mouseUp


On Mar 13, 2010, at 11:17 AM, Bill Vlahos wrote:

> I want to add a file from disk to a custom property, encrypt it, and  
> save it. Then I want to be able to extract the file from the custom  
> property and open it in the appropriate application.
>
> The first step is to put the file into the custom property but my  
> code below only puts the path to the file.
> on mouseUp
>   answer file "Please select a file..."
>   put it into lFileToRead
>   -- Read the binary contents of a file into a variable
>   open file lFileToRead for binary read
>   read from file lFileToRead until end
>   put base64Encode(lFileToRead) into lBinaryFile -- not sure if this  
> is needed
>   close file lFileToRead
>   set the uFileStore of me to lBinaryFile
> end mouseUp
>
> What am I missing?

Jim Ault
Las Vegas






More information about the use-livecode mailing list