Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

Perl as a test tool for Foxpro apps?

by talwyn (Monk)
on Aug 17, 2005 at 04:07 UTC ( #484305=perlquestion: print w/replies, xml ) Need Help??
talwyn has asked for the wisdom of the Perl Monks concerning the following question:

Hi all,

I have used perl and the Test modules along with Win32::Gui and win32::guitest to automate testing of windows applications in the past. Sendkeys, windows manipulation, selection and mouse clicks, etc.

Now I would like to do the same for some foxpro applications. However, Foxpro makes extensive use of windowless controls that do not have standard windows handle attached to the widgets.

So... Anyone know how to do this? Anyone know how to use the FoxPro API? The MSDN wasn't very forthcoming with examples... it seems like this would be the solution that I need to wrap into a perl module.... but I can't seem to find any working code or configuration for vc++ .Net so I can get started.

Any pointers to relevant docs would be helpful. Any pointers to good example code would be much appreciated.

Note this is not about database operations... this is about Foxpro GUI manipulation.


Code snippet follows:

#include<stdio.h> #include"c:\program files\Microsoft Visual Foxpro 8\Samples\api\pro_ex +t.h" int main() { WHANDLE wh; TEXT * title; title = "Form1"; wh = _WFindTitle(title); printf( "Found with fox handle '%d'",(int) wh); return 0; }

When compiled this generates the following errors:

  • foxpro_auto error LNK2019: unresolved external symbol @__WFindTitle@8 referenced in function _main
  • foxpro_auto fatal error LNK1120: 1 unresolved externals

Replies are listed 'Best First'.
Re: Perl as a test tool for Foxpro apps?
by planetscape (Chancellor) on Aug 17, 2005 at 15:39 UTC

    What version of FoxPro are you trying to automate?

    The MSDN document you probably want to start with is "Accessing the Visual FoxPro API": VFP 7.0, VFP 8.0, VFP 9.0.

    Look in the Samples/API directory under your FoxPro installation for the "pro_ext.h" file, which contains information about all the data structures and API calls you are likely to need. VFP 7.0's looks like this:


      hi planetscape.

      I read that document and attempted to use the api for VFP8, it would not ,however, compile; it was complaining about unresolved symbols in the linker.

      It was suggested that this was because of definitions and that I needed windef.h... which i tried but it (windef.h) is full of syntax errors (Is this header not maintained anymore?

      Do you have any experience setting up the compiler/linker to use the api? The examples in the sample directory are for use by foxpro apps to call external services... not *quite* what I wanted.


        Alas, I have automated Word, Acess, Excel (and probably a few others), but never VFP. I have been doing a little digging and find very little information on automating VFP; there's tons of stuff if you go the other direction and use VFP to automate something else.

        That doesn't do you any good, however.

        I've debugged a few header files; where I start is Google Groups with a copy of the error message(s) in hand.

        Hentzenwerke is probably the leading authority on things FoxPro. Many of their books are available in electronic editions available for immediate download. Even though it's a version "behind", you might find Hacker's Guide to Visual FoxPro 7.0 useful; it appears to have several pages at least on using VFP as an automation server. (My hardcopy is for VFP 6.0 and maybe worthless for your purposes, but let me know if you want me to look at something for you.)

        If I find anything else, I'll be sure to let you know. If you like, you could always /msg me your e-mail address, and we could, for example, compare header files or whatnot without sucking on the Monastery's bandwidth.


Re: Perl as a test tool for Foxpro apps?
by planetscape (Chancellor) on Aug 18, 2005 at 01:38 UTC

    Hopefully this will be enough now to get you started:

    Control of Visual FoxPro 8.0 from Other Applications

    I've cobbled together a short example of how to get the proper object reference and do one simple method, because I am really not an expert in automating via Perl:

    #!/usr/bin/perl use strict; use warnings; use Win32::OLE; use Data::Dumper; my $objVFP = Win32::OLE->new('VisualFoxPro.Application') or die "oops\ +n"; $objVFP->DoCmd('USE "C:\Program Files\Microsoft Visual FoxPro 7\Sample +s\Tastrade\Data\customer"'); my @arr = $objVFP->RequestData('Customer',5); print Dumper(\@arr);

    The output from this snippet follows:

    $VAR1 = [ [ [ 'ALFKI ', 'Alfreds Futterkiste ', 'Maria Anders ', 'Sales Representative ', 'Obere Str. 57 + ', 'Berlin ', ' ', '12209 ', 'Germany ', '030-0074321 ', '030-0076545 ', '6300', '2600', '2', ' ' ], [ 'ANATR ', 'Ana Trujillo Emparedados y helados ', 'Ana Trujillo ', 'Owner ', 'Avda. de la Constituci&#8804;n 2222 + ', 'M&#920;xico D.F. ', ' ', '05021 ', 'Mexico ', '(5) 555-4729 ', '(5) 555-3745 ', '3500', '1900', '5', ' ' ], [ 'ANTON ', 'Antonio Moreno Taquer&#966;a ', 'Antonio Moreno ', 'Owner ', 'Mataderos 2312 + ', 'M&#920;xico D.F. ', ' ', '05023 ', 'Mexico ', '(5) 555-3932 ', ' ', '8500', '1700', '6', ' ' ], [ 'AROUT ', 'Around the Horn ', 'Thomas Hardy ', 'Sales Representative ', '120 Hanover Sq. + ', 'London ', ' ', 'WA1 1DP ', 'UK ', '(71) 555-7788 ', '(71) 555-6750 ', '17100', '0', '1', ' ' ], [ 'BERGS ', 'Berglunds snabbk÷p ', 'Christina Berglund ', 'Order Administrator ', 'Berguvsv&#931;gen 8 + ', 'Lule&#963; ', ' ', 'S-958 22 ', 'Sweden ', '0921-12 34 65 ', '0921-12 34 67 ', '28600', '4900', '0', ' ' ] ] ];


      Thanks for the pointer! On the face of it this looks like it may be a viable approach! I'll keep ya posted. Thanks.


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://484305]
Approved by Tanktalus
Front-paged by planetscape
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (4)
As of 2017-06-26 07:48 GMT
Find Nodes?
    Voting Booth?
    How many monitors do you use while coding?

    Results (573 votes). Check out past polls.