Getting Started with X# -- Converting a VFP Application or DLL

This forum is meant for questions about the Visual FoxPro Language support in X#.

Jeff Stone
Posts: 34
Joined: Fri Jun 07, 2019 4:16 pm

Getting Started with X# -- Converting a VFP Application or DLL

Post by Jeff Stone »

Hi Everyone,

I've been away from X# for quite awhile due to a change in my job responsibilities. We have a VFP .DLL that contains basic VFP table and database functions to allow some C programs and Excel programs to read and write to/from DBF and .DBC files. A standard security upgrade on our network blocked access to the VFP .DLL for a couple days before we were able to figure out the security upgrade was the issue and rolled it back. This event highlighted the need for us to build an alternative .DLL to offer the same functionality. I believe X# should be able to do the job.

To get someone else up-to-speed more quickly on X#, is there a write-up anywhere which identifies all of the compiler switch settings that are needed to have X# operating in the most VFP compatible way? For example, reading through the VFP forum, I've learned that the -vo12 switch should be used for integer division operations. Given the switch is described as "Enables Clipper compatible integer divisions", a new X# user would not readily know that they should use this switch. All comments and suggestions are welcome.

TIA,

Jeff
User avatar
Chris
Posts: 4584
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

Re: Getting Started with X# -- Converting a VFP Application or DLL

Post by Chris »

Hi Jeff,

It all depends on what you are doing in the code, but I would say the most common options to be enabled for VFP are
-lb (late bound calls)
-memvar and -undeclared (support for undeclared vars, PUBLICs, PRIVATEs etc)
-fox1 and /fox2
-vo2 -vo3 -vo7 -vo9 -vo12 -vo14

the most important of course is to use the VFP dialect in the project settings, this alone makes the compiler as VFP syntax compatible as possible.
Chris Pyrgas

XSharp Development Team test
chris(at)xsharp.eu
Jeff Stone
Posts: 34
Joined: Fri Jun 07, 2019 4:16 pm

Re: Getting Started with X# -- Converting a VFP Application or DLL

Post by Jeff Stone »

Thanks, Chris. This is very helpful. For persons reading this post at a later date, I have pasted links to descriptions of Chris's recommended switches below:

-lb (late bound calls)
https://www.xsharp.eu/help/opt-lb.html

-memvar and -undeclared (support for undeclared vars, PUBLICs, PRIVATEs etc)
https://www.xsharp.eu/help/opt-memvar.html The -memvar option tells the compiler to enable the support for 'memory variables'. This option is also needed in the FoxPro dialect if you want to make local variables visible to the macro compiler with the -fox2 compilation option.
https://www.xsharp.eu/help/opt-undeclared.html The -undeclared option tells the compiler to enable the support for 'undeclared variables'

-fox1 and /fox2
https://www.xsharp.eu/help/opt-fox1.html -fox1 Classes are assumed to inherit from the Custom class
https://www.xsharp.eu/help/opt-fox2.html The -fox2 compiler option is enabled for foxpro compatible array support.


-vo2 -vo3 -vo7 -vo9 -vo12 -vo14
https://www.xsharp.eu/help/opt-vo2.html -vo2 Initialize strings
https://www.xsharp.eu/help/opt-vo3.html -vo3 All instance methods virtual
https://www.xsharp.eu/help/opt-vo7.html -vo7 Implicit casts and conversions
https://www.xsharp.eu/help/opt-vo9.html -vo9 Handle problems with incorrect or missing return statements
https://www.xsharp.eu/help/opt-vo12.html -vo12 Clipper Compatible integer divisions
https://www.xsharp.eu/help/opt-vo14.html -vo14: Use Float Literals
Jeff Stone
Posts: 34
Joined: Fri Jun 07, 2019 4:16 pm

Re: Getting Started with X# -- Converting a VFP Application or DLL

Post by Jeff Stone »

Hi,

Stupid follow on question. How do I set the VFP dialect in XIDE? I don't see any dialect options under Project/Properties or Application/Properties.

TIA,

Jeff
FFF
Posts: 1532
Joined: Fri Sep 25, 2015 4:52 pm
Location: Germany

Re: Getting Started with X# -- Converting a VFP Application or DLL

Post by FFF »

Jeff,
you have to have set compiler language to X#, then in the dialect list there's Foxpro, too.
Properties.PNG
Regards
Karl
(on Win8.1/64, Xide32 2.19, X#2.19.0.2.)
Jeff Stone
Posts: 34
Joined: Fri Jun 07, 2019 4:16 pm

Re: Getting Started with X# -- Converting a VFP Application or DLL

Post by Jeff Stone »

Thanks, Karl.

Seeing the "Application Name" label on your screen shot was the clue that I needed. My problem was due to my coming at X#/XIDE from a VFP standpoint. In VFP, you create a project and then just start adding code (.prg files), forms, data, etc to the project. In XIDE, after you create a new project, you have to then select Project/Create New/Application. After creating a new application, I can then right click on it in the Project layout tab on the right side of XIDE to see the screen that you displayed.

I'm too new to X# to be helpful yet, but I think if a few short 5 minute videos are created (definitely not more than 10 minutes) such as "VFP User Introduction to Getting Started with XIDE for X#"** would generate more converts to X#. If people get too frustrated just trying to create the basic "Hello World" program, they lose interest. The videos do need to be dialect specific so that the transition to X# seems as simple as possible.

Regards,

Jeff

**To add more detail here...
For the VFP Intro Video, it would be really helpful to just see someone:
  • Create a Project
    Create The Application
    Set the Dialect as FoxPro
    Set all of the related compiler switches that Chris listed below
    Create a 5 line .prg with variables being assigned values and then displaying them
Jeff Stone
Posts: 34
Joined: Fri Jun 07, 2019 4:16 pm

Re: Getting Started with X# -- Converting a VFP Application or DLL

Post by Jeff Stone »

For newbies, based on the below posts, I was still doing something incorrectly. After setting the Dialect to FoxPro and setting all of the compiler switches that Chris listed,I got the following error messages:

error XS9014: The dialect 'FoxPro' requires a reference to the runtime DLLs XSharp.Core.DLL and XSharp.RT.DLL.
error XS9019: Compiler option 'vo7' (Implicit casts and Conversions) is not supported for dialect FoxPro
error XS9019: Compiler option 'vo12' (Clipper Integer divisions) is not supported for dialect FoxPro
error XS9019: Compiler option 'vo14' (Float literal Values) is not supported for dialect FoxPro
error XS9019: Compiler option 'memvars' (PRIVATE and or PUBLIC variables) is not supported for dialect FoxPro
error XS9006: Illegal combination of commandline options: /undeclared must be combined /memvars.

The first error message was the key to resolving all of them. Under the Application Properties, I needed to go to the References tab and then select the XSharp.Core and XSharp.RT entries under the GAC tab and click on the Add button. After that all errors were resolved and I successfully compiled and ran my test prg.
Attachments
Capture.PNG
Last edited by Jeff Stone on Wed Dec 20, 2023 3:30 pm, edited 1 time in total.
User avatar
wriedmann
Posts: 3655
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

Re: Getting Started with X# -- Converting a VFP Application or DLL

Post by wriedmann »

Hi Jeff,
There is a sample application for VFP in the XIDE gallery:
20-12-2023_16-12-49.png
This sample uses the correct references
20-12-2023_16-14-03.png
20-12-2023_16-14-03.png (6.47 KiB) Viewed 607 times
and compiler options
20-12-2023_16-15-02.png
I suspect the FoxPro dialect sets some /vo options in a different manner internally in the compiler, so the these are not to be used.
I would also think that you could need a reference to XSharp.data.

Regarding the videos: do you had a look in the Youtube X# Academy?
https://www.youtube.com/channel/UCFqLBM ... 4xRxFGLiVA

Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
Jeff Stone
Posts: 34
Joined: Fri Jun 07, 2019 4:16 pm

Re: Getting Started with X# -- Converting a VFP Application or DLL

Post by Jeff Stone »

Thanks Wolfgang. My old eyes didn't see the Foxpro Dialect Application option, so I mistakenly started with a Basic X# Application. Now the real testing will start as I try to convert a somewhat simple VFP DLL that our C programs call to access DBF data. If/when I successfully complete this conversion, it will be interesting to see if we can actually drop the DLL and, instead, merge the X# code with our C code in Visual Studios.
User avatar
wriedmann
Posts: 3655
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

Re: Getting Started with X# -- Converting a VFP Application or DLL

Post by wriedmann »

Hi Jeff,
you should give a look to the videos in the Academy as they should explain more how to work and what classes are here to support your migration.
And Robert or Fabrice should be able to help you - unfortunately I have no experience with VFP, but know that it is somewhat different from what I'm used (VO a class based compiler system as X# is, and VFP is mainly a command based interpreter, and that makes it very hard to the devteam to make compile VFP code).
Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
Post Reply