Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Invoking dBase IV using different dBase databases ... 1

Status
Not open for further replies.

lasitter

MIS
Jun 16, 2004
6
US
I'm trying to set a file association in windows such that when I double-click on a dbase file, dbase is started by windows and automatically uses that file.

I have no problem creating the association, but dBase thinks anything passed to it "%1" is a program, and chokes when attempting to compile a database.

So what I need to know is how to have dBase invoke a startup program which then understands that "%1" is the file it's supposed to open.

So: \dbase\dbase startup.prg %1

What would the contents of startup.prg look like? I'm not getting something right about using the PROCEDURE or PARAMETER commands, most likely.

Thanks.
 
The request to open a specific table (.dbf) should come from within startup.prg

You can either hatd-code the name of the table into startup.prg or if you want to be able to select a table when startup.prg runs, the USE ? syntax should be used, but again from within startup.prg


 
So what I want to do is pass startup.prg a parameter from the DOS command line such that it fills in the value for:

USE ?

Or whatever the syntax needs to be, thereby automatically starting dBase and using the file.

What does the DOS command line look like (an example), and what's the syntax of the "USE" statement inside the STARTUP.PRG file.

I plan to take this information and put it into a .PIF file so I can double click on a .DBF file and open it.

OK?
 
You can't pass a parameter to startup.prg - you'll have to either hard code the actual DBF name (use mytable.dbf) or hard code a method to see all DBF files in the directory - use ?. Both of these must be hard coded IN startup.prg

There's always a better way. The fun is trying to find it!
 
Acutally, tviman, you can send a parameter to dBase. Using lasitter's example, it should look like this:

\dbase\dbase startup.prg [%1]
 
Oh, yes, I should have mentioned it works with DOS version 5.0, so I'm not sure about the others before or later.

What I use it for is to run an application from a DOS batch file. The incoming parameter is then placed into the keyboard which then acts just like it was me typing at the keyboards. It even exits on it's own.

A sample BOS batch command line:

\dbase\dbase startup.prg [{F8}{13}%1{13}]{27}{27}]

F8 is a predefined: ON KEY LABEL F8 DO keyF8 WITH xTxt
13 is the Enter key
27 is the Escape key

PARAMETER in_keybd
IF TYPE("in_keybd")="C" && from outside DOS batch file
cp_keybd=LTRIM(RTRIM(in_keybd))
* make sure typeahead is large enough
SET TYPEAHEAD TO MIN(24,LEN(cp_keybd)+12)
KEYBOARD cp_keybd
ENDIF

Of course, you don't have to do all that complicated stuff. Adjust as needed.

Does this help? Down with carpal tunnel and tendonitis! Up with speed and accuracy!

dbMark
 
I must confess to still being a bit lost here ...

-------------

> \dbase\dbase startup.prg [{F8}{13}%1{13}]{27}{27}]

Are the square brackets actually typed in or no?

> F8 is a predefined: ON KEY LABEL F8 DO keyF8 WITH xTxt

Is "keyF8" a procedure with "xTxt" as a parameter?

Is it located in startup.prg?

And is this next section also in startup.prg?

Thanks.

PARAMETER in_keybd
IF TYPE("in_keybd")="C" && from outside DOS batch file
cp_keybd=LTRIM(RTRIM(in_keybd))
* make sure typeahead is large enough
SET TYPEAHEAD TO MIN(24,LEN(cp_keybd)+12)
KEYBOARD cp_keybd
ENDIF
?¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦
 
dBase (and FoxPro too) have 3 delimiters that can be used for typing text strings, all are generally equivalent:
"text" - double quotes
'text' - single quotes
[text] - square brackets

With these three you can enclose strings within strings:

cString = "DO xProgram WITH [ABC]"
&cString

The same string can be written as:

cString = [DO xProgram WITH "ABC"]
&cString

As for your question of what the sample code I gave meant, yes "keyF8" would be a procedure with "xTxt" as a parameter.

Finally, the lines of code using in_keybd and cp_keybd are quite similar to a routine I use for a DOS batch file to tell the dBase program what to do, even one compiled as an EXE. Play with it and adjust it for your needs. When I first designed it, my first attempts failed. It would not work if I enclosed my parameter with double quotes in the DOS batch file, but after much experimentation I found that both single quotes and square brackets works fine.

Hmmm, maybe this should be made into a FAQ...

dbMark
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top