Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Active Scripting

Aug
1,929
71
The only thing that I do not like about Visual FoxPro for Windows is the inability to work at the console, the way I could with Clipper 5.01 and dBASE IV 2.0 for DOS. By console, I mean TCC/CMD console, not the Visual FoxPro Command Window.

Since it is inevitable that the Windows 7 64-bit OS will one day be forced upon me, putting an end to my good ole' 16-bit applications, I have decided to take advantage of the features of VBScript and TCC to extract data from my .DBF files.

I have been using DOSBox, but it lacks the OS features available in TCC.

So, below is a Visual Basic script that extracts data from a .DBF file, sending the results to TCC. Note that Microsoft Visual FoxPro is required for this script, and that you would have to make modifications for your .DBF location and structure.

Code:
rem ******************************************************************
rem * This script is called from TCC as follows;                     *
rem * script bmo.vbs %+ echo %jlc Records                            *
rem ******************************************************************
rem
rem ******************************************************************
rem * Create and return a reference to the                           *
rem *   Visual FoxPro Automation Object                              *
rem ******************************************************************
rem
set vfp = CreateObject("visualfoxpro.application")
rem
rem ******************************************************************
rem * Enter commands,                                                *
rem *   just as you would from the FoxPro Command Window             *
rem ******************************************************************
rem
vfp.DoCmd("use C:\jlc\Data\vfp\jlcbank\register.dbf shared")
vfp.DoCmd("set fields to acct_numb, trans_date, payee, amount")
vfp.DoCmd("set filter to left(acct_numb,4) = '5191'")
vfp.DoCmd("go top")
vfp.DoCmd("count all for left(acct_numb,4) ='5191' to m->bmo")
rem
rem ******************************************************************
rem * Create a script-level variable                                 *
rem *                                                                *
rem * Note that VBScript only supports the Variant data type.        *
rem * When I assign an integer number to the variable,               *
rem *   it becomes an integer variable.                              *
rem ******************************************************************
rem
intBMO = vfp.Eval("m->bmo")
vfp.DoCmd("go top")
rem
rem ******************************************************************
rem * Display the selected records to stdout,                        *
rem *   via the TCC COM interface                                    *
rem ******************************************************************
rem
for counter = 1 to intBMO
  vfp.DoCmd("store acct_numb + payee + DTOS(trans_date) + str(amount,9,2) to m->jlc")
  shell.writeln(vfp.Eval("m->jlc"))
  vfp.DoCmd("skip")
next
rem
rem ******************************************************************
rem * Create an environment variable in TCC                          *
rem *                                                                *
rem * Note that I have to convert the VBScript integer variable      *
rem *  to a string                                                   *
rem ******************************************************************
rem
str2TCC = "set jlc=" + CStr(intBMO)
rem
rem ******************************************************************
rem * Using the TCC COM interface,                                   *
rem *   create an environment variable in TCC                        *
rem ******************************************************************
rem
shell.exec(str2TCC)
rem
rem ******************************************************************
rem * Destroy reference to the Visual FoxPro Automation Object       *
rem ******************************************************************
rem
set vfp=Nothing
The script is run from TCC as follows;

Code:
script bmo.vbs %+ echo %jlc Records
It should not be too difficult to modify this script to work with other Automation Objects, such as Microsoft Excel, or Microsoft Access, providing you with a method to work with the desired data in TCC.

Joe
 
Back
Top