Welcome to Foxite.COM Community Weblog Sign in | Join | Help

Command-line VFP

It's surprisingly easy to create a command-line interface to your application: example usages could be application updates, maintenance routines, anything that doesn't require a user interface.

As an example create a file called vfp.cmd somewhere in the default path (e.g. the system32 directory for local admins or at install) and add the following:
@cscript //nologo "%~dpn0.vbs" %*
This executes a script which is on the same drive, the same path, has the same name as the cmd file, has the extension vbs, and passes all the command line arguments to the script host.

Then create a file in the same directory as the .cmd file called vfp.vbs with these contents:
dim i, oVFP
i = 0

wscript.echo "Arguments:"

do while i < wscript.arguments.count
wscript.echo wscript.arguments(i) & "(" & i & ")"
i = i + 1
loop

set oVFP = createobject("VisualFoxpro.Application")
wscript.echo "VFP File path:"
wscript.echo oVFP.DefaultFilePath
Once this has been done, open a command prompt and type
vfp foo bar 
to see the results. Your script could process the arguments itself, or it could pass them to your application or COM server depending on the requirements.
Published Thursday, April 27, 2006 11:57 AM by stuartd

Comments

Anonymous comments are disabled