Creating a Patch Upgrade

Ken Ray kray at sonsothunder.com
Fri Feb 4 00:50:01 EST 2005


On 2/2/05 11:25 PM, "Paul Salyers" <ps1 at softseven.org> wrote:

> Is making a patch for a program easy or hard to change minor things on a
> program that has already been compiled into an exe?

As Derek mentioned, if your users have only downloaded an exe and you want
to patch it, you'd have to use a patching program.

However, lot can be done if the architecture of the executable is thought
about ahead of time. For example, instead of a single exe, you could deliver
an exe and a stack file. The stack file would contain the actual "guts" of
the program, while the exe was only a "stub" that would immediately open the
stack file when it was launched. So instead of:

  MyApp.exe

You have:

  MyApp.exe
  MyApp.dat  -- or whatever you want to call it

And the preopenstack handler of the MyApp.exe is simply:

  open stack "MyApp.dat"

Now suppose the primary stack (MyApp.dat) had the internal name of "MyApp".
Then add the simple ability to look for a patch (if there ever is one) and
execute it after the primary stack opens. I like to connect to an
alternative stack like this by using "start using" to make the stack's
functions and handlers accessible, and the "stop using" it when I'm done:

on preOpenStack
  open stack "MyApp.dat"
  if there is a file "MyAppPatch.dat" then
    start using stack "MyAppPatch.dat"
    RunPatch  -- executes the "RunPatch" handler in MyAppPatch.dat
    stop using stack "MyAppPatch.dat"
    delete file "MyAppPatch.dat"  -- remove it so it doesn't run next time
  end if
end preOpenStack

Then, in the "patch" stack's stack script, there would be a handler called
"RunPatch" that would make modifications to MyApp and save it. For example,
suppose you needed to change a custom property of the MyApp stack. It could
be something like:

on RunPatch
  set the uCustomProp of stack "MyApp" to "100"
  save stack "MyApp"
end RunPatch

Or, if you wanted to change the location of a field on the third card of the
MyApp stack, you could do something like:

on RunPatch
  set the loc of field "MyField" of card 3 of stack "MyApp" to 10,20,100,200
  save stack "MyApp"
end RunPatch 

Anyway, you get the idea. With a good architecture up front, you can allow
users to download a simple stack, place it in the same directory as the
executable and know that your app will be patched the next time it is run.

HTH,


Ken Ray
Sons of Thunder Software
Web site: http://www.sonsothunder.com/
Email: kray at sonsothunder.com




More information about the use-livecode mailing list