HOWTO: Pass Data Between Different Versions of FoxPro

ID: Q192957


The information in this article applies to:


SUMMARY

With the rapid pace of advancements in software development tools, developers are increasingly confronted with issues related to legacy applications and exchanging data between applications. This article illustrates how to pass data between applications created with different versions of FoxPro.


MORE INFORMATION

At run-time, applications exist as separate and distinct processes executing within their own memory space. Because these are separate processes, attempts to pass variables directly between applications created with different versions of FoxPro are likely to fail. Using shared tables is generally the simplest and most efficient way to share data between two processes.

Before running this code, use the SET DEFAULT TO command to ensure that both versions of FoxPro point to the same folder.

  1. Using FoxPro 2.6, create a program file called TEST1.PRG, using the following code:
    
          PARAMETER lcharvalue
          IF PARAMETERS()>0
             ? "The String Passed was "+ALLTRIM(lcharvalue)
          ENDIF 


  2. Create a new project called TEST, add TEST1.PRG, and then create an executable file.


  3. Using FoxPro 2.6, type the following command at the command prompt, "DO TEST WITH 'Hello World'" and note that "The String Passed was Hello World" prints to the screen.


  4. Using Visual FoxPro, type the following command at the command prompt, "DO TEST WITH 'Hello World'" and note that the following error message appears:
    "Object file test1.exe was compiled in a previous version of FoxPro"


  5. Using FoxPro 2.6, create a program file named "TEST.PRG", using the following code:
    
          *:* Begin Code
          SET EXCLUSIVE OFF
          IF !FILE('TESTTHIS.DBF')
             IF ATC("Visual", VERSION())=0
                CREATE TABLE testthis (datainfo C(20))
             ELSE
                CREATE CURSOR temp (datainfo C(20))
                COPY TO testthis.DBF TYPE FOX2X
             ENDIF
          CLOSE ALL
          ENDIF
          IF !USED('TESTTHIS')
             USE testthis
          ELSE
             SELECT testthis
          ENDIF
          fileval=RECCOUNT()
          DO WHILE .T.
          IF RECCOUNT('TESTTHIS')<>fileval ;
             OR LASTKEY()=27
             EXIT
          ENDIF
          ENDDO
          IF RECCOUNT('TESTTHIS')<>fileval
             GO BOTTOM
             =TEST1(datainfo)
          ENDIF
          *:* ENDCODE Code 


  6. From the command prompt in FoxPro 2.6, type "DO TEST."


  7. Using Visual FoxPro, type the following commands at the command prompt:
    
          SET EXCLUSIVE OFF
          "INSERT INTO TESTTHIS (datainfo) VALUES ('Hello World')" 


  8. Press the ALT-TAB keys to navigate to the session of FoxPro 2.6 and observe that "The String Passed was Hello World" appears on the screen.

    NOTE: If you modify a table created in FoxPro 2.x with Visual FoxPro, FoxPro 2.x can no longer open the table. Therefore, when making changes to any table to be used between versions, use FoxPro 2.x to make the changes or copy the table back to FoxPro 2.x form by using the Visual FoxPro COPY TO <filename> TYPE FOX2X command.


Additional query words: kbDSupport kbDSE kbXBase kbVFp600 kbVFp500a kbVFp500 kbVFp300b kbVFp300


Keywords          : 
Version           : MS-DOS:2.6a; WINDOWS:2.6a,3.0,3.0b,5.0,5.0a,6.0
Platform          : MS-DOS WINDOWS 
Issue type        : kbhowto 

Last Reviewed: August 9, 1999