The Database Managers, Inc.

Contact The Database Managers, Inc.

Use an RSS enabled news reader to read these articles.Use an RSS enabled news reader to read these articles.

Page 2

Compiling DataFlex Programs

by Curtis Krauskopf

User-Specified Parameters

A better way to do this, though, is to have one batch file that is flexible enough to handle an arbitrary set of files using wildcard characters.

The way to do that on MS-Dos and Windows is to use the %1 parameter in the batch file. The batch file now changes to:

for %%s in (%1) do dfcomp %%s

If I accidentally run the batch file without specifying any parameters, like this:


nothing bad happens (fortunately) but I don't even get a meaningful error message. This is what the screen displays when dfc is run without any parameters:

for %s in ((null)) do dfcomp %s

It would be nice if the batch file could detect when I ran it without parameters. That can be done with the following batch file trick:

if x%1==x goto instructions

When the first parameter on the batch file does not exist, this command expands to

if x==x goto instructions

which is always true. But if a parameter was specified, such as ap*.src, then that expression would expand to:

if xap*.src==x goto instructions

@echo off

The @echo off command immediately disables the displaying of batch file commands. Most advanced batch files have this as one of the first few lines.

which is always false. Because of this, there's a limitation with the batch file in that filenames with embedded equal signs can't be handled properly when they are on the command line. This really isn't a problem, though, because I've never seen a programmer put an equal sign in the middle of a filename.

So we can handle wildcard compilations by using the FOR command, and the batch file is even smart enough to detect when it was executed without any parameters by using the IF command.

Go Back to Page: 1
Copyright 2003-2010 The Database Managers, Inc.


DataFlex Decompiler
DataFlex: Tips | Freeware | WebApp Server | Books | Links
Services | Programming | Contact Us | Recent Updates

Send feedback to: