AW: Self-repairing install solution

Tiemo Hollmann TB toolbook at kestner.de
Fri Jan 11 05:01:31 EST 2008


Nice piece Josh, thanks for sharing!
Tiemo

> -----Ursprüngliche Nachricht-----
> Von: use-revolution-bounces at lists.runrev.com [mailto:use-revolution-
> bounces at lists.runrev.com] Im Auftrag von Josh Mellicker
> Gesendet: Freitag, 11. Januar 2008 01:13
> An: how to use Revolution
> Betreff: Self-repairing install solution
> 
> 
> For anyone who might need this in the future and hasn't written it,
> hopefully I can save you some time!
> 
> PROBLEM: What if your application depends on a bunch of auxilary
> files scattered around the user's hard drive- maybe these are
> pictures, movies, text files, settings, spreadsheets, who knows? You
> know you can make an installer that initially, will put all these
> files in all the right places. But what if the user accidentally
> deletes or moves some of them?
> 
> 
> Instead of an installer, here is a function you can run when starting
> up that will install these files initially, then replace any missing
> asset files, "repairing" an installation if necessary on each launch.
> 
> ------------------------------------------------------------------------
> ------------------------------------------------------------------------
> STEP ONE:
> 
> Use this function (during development) to find all the important
> files and import them into custom properties:
> 
> ON importAssetsIntoCustomProps
>      set the custompropertyset of me to "myAssetFiles"
>      REPEAT
>          answer file "choose file to import (cancel when done)"
>          IF it is empty THEN exit to top
>          set the myAssetFiles[it] of me to URL ("binfile:" & it)
>      END repeat
> END importAssetsIntoCustomProps
> 
> (You can do this repeatedly, as much as you want, it will update the
> binary data if you import the same filename that has been updated)
> ------------------------------------------------------------------------
> ------------------------------------------------------------------------
> STEP TWO:
> 
> To call the function, use something like:
> 
> on openStack
>      jjEnsureAssets
> end openStack
> 
> ------------------------------------------------------------------------
> ------------------------------------------------------------------------
> -- include these handlers:
> 
> ON jjEnsureAssets
>      set the custompropertyset of me to "myAssetFiles"
>      put the customproperties of me into tAssets
>      REPEAT FOR each line pFile in the keys of tAssets
>          IF there is no file pFile THEN
>              makeFoldersIfNecessary pathFromPathAndFile(pFile)
>              put the myAssetFiles[pFile] of me into URL ("binfile:" &
> pFile)
>          END IF
>      END repeat
> END jjEnsureAssets
> 
> ON makeFoldersIfNecessary pLocalFilePath
>      set the itemdel to "/"
>      put "/" into tPath
>      REPEAT WITH x = 2 to the number of items of pLocalFilePath --
> ("2" because "/" will surely exist! :-)
>          put item x of pLocalFilePath & "/" after tPath
>          IF there is not a folder tPath THEN
>              create folder tPath
>          END IF
>      END REPEAT
> END makeFoldersIfNecessary
> 
> FUNCTION pathFromPathAndFile tPathAndFile
>      set the itemdel to "/"
>      delete the last item of tPathAndFile
>      return tPathAndFile
> END pathFromPathAndFile
> 
> ------------------------------------------------------------------------
> ------------------------------------------------------------------------
> 
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution




More information about the use-livecode mailing list