Fpole.dll Examples

The following examples demonstrate using functions in Fpole.dll from Visual FoxPro, a Help file, and Word Basic.

Visual FoxPro Example

MYDLL = "C:\Program Files\Microsoft Visual FoxPro 7.0\Fpole.dll

DECLARE integer SetOleObject in (MYDLL) string 
DECLARE integer FOXDOCMD in (MYDLL) string,string 
DECLARE integer FOXEVAL in (MYDLL) ;
   string, string @,integer 

=SetOleObject("visualfoxpro.application") 
?FOXDOCMD("wait wind 'test' timeout 2","") 
?FOXDOCMD("modi proj xx2 nowait ","") 
?FOXDOCMD("close all","") 

CLEAR DLLS 

Help File Example

  1. In the [CONFIG] section of a help project, register the DLL:

    RegisterRoutine("fpole.dll","FOXDOCMD","SS")
    
  2. In your .RTF file, call the function the same way you would call a native Help macro:

    HotSpotText!FOXDOCMD("DO (HOME() + 'myprg')","at")
    
  3. Compile and run the help file.

Simple Word Basic Example

Declare Sub FOXDOCMD Lib "C:\Program Files\Microsoft Visual FoxPro 7.0\Fpole.dll" (cCommand As String, cOptions As String) 

Sub MAIN 
FOXDOCMD "USE (HOME(2) + 'Data\Customer')", "i" 
FOXDOCMD "_CLIPTEXT = customer.company", "i" 
EditPaste 
End Sub 

Another Word Basic Example

This example presents a dialog box so that a user can choose a customer ID from a list. The associated company name and contact are then inserted into the Word document.

'Declare the Fpole.dll functions.
'--------------------------------
Declare Sub SetOleObject Lib "C:\Program Files\Microsoft Visual FoxPro 7.0\Fpole.dll(cApp As String)

Declare Sub FOXDOCMD Lib "C:\Program Files\Microsoft Visual FoxPro 7.0\Fpole.dll(cCommand As String, BringToFront As String)

Declare Sub FOXEVAL Lib "C:\Program Files\Microsoft Visual FoxPro 7.0\Fpole.dll(cExpression As String, cBuff As String, nLen As Integer)

Declare Sub CLOSEIT Lib "C:\Program Files\Microsoft Visual FoxPro 7.0\Fpole.dll

Sub MAIN

Dim cBuffer$
cBuffer$ = String$(50, " ")
Dim aCustID$(5)
aCustID$(0) = "BLONP"
aCustID$(1) = "CHOPS"
aCustID$(2) = "ISLAT"
aCustID$(3) = "LETSS"
aCustID$(4) = "SEVES"
cboCustID = 0'1st element in the array

Begin Dialog UserDialog 404, 150, "Calling Visual FoxPro with Fpole.dll"
   DropListBox 44, 33, 160, 108, aCustID$(), .cboCustID
   Text 15, 14, 268, 13, "Choose a Customer ID from the list.", .Text2
   Text 15, 61, 231, 13, "Then Choose OK to insert the ", .Text4
   Text 15, 78, 215, 13, "Company Name and Contact", .Text5
   Text 15, 95, 141, 13, "into your document.", .Text6
   OKButton 298, 76, 88, 21
   CancelButton 299, 111, 88, 21
End Dialog

Dim dlg As UserDialog
nButtonChoice = Dialog(dlg)

' If the user presses "Cancel"...
'--------------------------------
If nButtonChoice = 0 Then
   Goto EndOfSub
End If

' Automate Visual FoxPro
'-----------------------
Print "Opening Visual FoxPro"
SetOleObject "visualfoxpro.application"
FOXDOCMD "USE (HOME(2) + 'Data\Customer')", "i"
FOXDOCMD "LOCATE FOR cust_id = " + Chr$(39) + aCustID$(dlg.cboCustID) + Chr$(39), "i"

Insert "Customer ID" + Chr$(9)
FOXEVAL "cust_id", cBuffer$, 50
Insert RTrim$(cBuffer$)
InsertPara

Insert "Company:" + Chr$(9)
FOXEVAL "company", cBuffer$, 50
Insert RTrim$(cBuffer$)
InsertPara

FOXEVAL "contact", cBuffer$, 50
Insert "Contact: " + Chr$(9) + RTrim$(cBuffer$)
InsertPara

Print "Closing Visual FoxPro"
CLOSEIT
Print " "

EndOfSub:
End Sub

See Also

Fpole.dll | FOXDOCMD( ) | FOXEVAL( ) | SETERRMODE( ) | SETOLEOBJECT( ) | CLOSEIT( ) | GETLASTERR( )