Enable people to run your programs without installing anything

Sometimes friends or relatives might hear that you’re an expert with using computers, and might ask you to help them solve a problem.

Indeed, when I moved from Boston to Hawaii to be with my family in 1984, people heard that I was a graduate of MIT and thus must be an expert with computers, and therefore I should be able to do their accounting system or office automation for them. Not the easiest task in the world with MS-DOS, 286’s, < 1 M RAM, 20 Meg hard disks, 6 Mhz processors.

Wouldn’t it be great if I could send a text file to them that was the program? They can modify or run it at their leisure.

For example, maybe your friend asks you to help do a mailmerge of their Excel address book to mailing labels. (see Sending Christmas cards: Creating mailng labels automatically)

With the inclusion of the VFP compiler in the runtime (since what version? I forget: anybody know?) this is pretty easy to do.

All the client has to do is unzip 4 files into a folder, put the text file in the same folder and then they can run it.

For example, the audience of my blog may not have Foxpro installed, but you can easily run code samples with a few minor modifications of the sample code.

· If there is a Form, then you need to make it Top Level (ShowWindow=2) or make _screen.Visible=.t.

· When the program finishes, it needs to either Quit or Clear the event loop (CLEAR EVENTS)

                   PROCEDURE Destroy

                   IF _vfp.StartMode>0

                   QUIT && or CLEAR EVENTS

                   ENDIF

In order to make some prior samples work, just modify the code in these links as described:

What is taking up the space on your hard disk? TreeMap it! 

Turtle Graphics Logo Program   (be careful: this sample already sets ShowWindow to 0, so make _screen.Visible=1 to see it

Create your own typing tutor!

Create a zip file with 4 files:

This zip contains only 4 files: (3.3 megs zipped)

            VFP9R.DLL Foxpro runtime c:\Program Files\Common Files\Microsoft Shared\VFP\

            VFP9RENU.DLL Foxpro runtime English localized resources (strings/dialogs) c:\Program Files\Common Files\Microsoft Shared\VFP\

            MSVCR71.DLL The Visual C Runtime c:\Windows\system32

            EXEC.EXE The Exec program created below

Here’s a skeleton program that can be run by this method. It shows a form with a button:

CLEAR ALL

*_screen.Visible=1

ox=CREATEOBJECT("Myform")

ox.visible=1

DEFINE CLASS MyForm as Form

          ShowWindow=2 && Top level form

          ADD OBJECT cmdQuit as commandbutton WITH ;

                   Cancel=.t.,;

                   Caption="\<Quit"

          PROCEDURE cmdQuit.click

                   thisform.Release

          PROCEDURE Destroy

                   IF _vfp.StartMode>0

                   QUIT && or CLEAR EVENTS

                   ENDIF

ENDDEFINE

Below is the code that creates the EXEC.EXE file: save the text below as EXEC.PRG and run it. If there is only one PRG file in the folder, it will run it. You can pass the name of the PRG to execute as a command line parameter. You can

PARAMETERS cFileToExec as String

          IF VARTYPE(cFileToExec)!= 'C' && if user didn't pass in command line arg

                   n=ADIR(aa,"*.prg") && see if there is exactly 1 PRG in the cur dir

                   IF n=1

                             cFileToExec =aa[1,1] && if so, use it

                   ELSE

                             cFileToExec =GETFILE("prg","File to Execute?")

                   ENDIF

          ENDIF

          IF _vfp.StartMode=0

                   && Design time

                   CLEAR

                   TEXT TO cStr

                             screen=off && hide VFP runtime screen by default

                             resource=off && turn off foxuser resource file

                   ENDTEXT

                   STRTOFILE(cStr,"config.fpw") && Create a config file

                   BUILD PROJECT Exec FROM Exec, config.fpw && project contains 2 files: "exec.prg" and "config.fpw"

                   BUILD EXE Exec FROM Exec

                   cCmd="exec "+cFileToExec

                   !/n &cCmd

                   RETURN

          ENDIF

          && Run & Design time

          COMPILE (cFileToExec )

          DO (cFileToExec )

          READ EVENTS && cFileToExec should do a Quit or CLEAR EVENTS to end the event loop

 

End of program