Hi all,
X# newbie here.
I’d like to migrate a very large Harbour application (which had a prior life in Clipper) to XSharp for a client who has been using it for 25+ years. It’s pretty much still standard Clipper code.
I’ve just started to experiment with X#; It appears that most folks are migrating from either VO or VFP though so I’m not finding much help on the subject. In order to make this feasible for my client, I need to minimize code re-write other than the presentation layer. Most of the business logic is in a number of function libraries, the system was written quite modular for its time.
One of my first tests involves a simple call to a function with a return value:
bValue := AnyFunc()
return
function AnyFunc()
return(.t.)
This works in Harbour.
However, in XSharp, I get error “XS1031 Type expected” unless I code the function as
function AnyFunc() as boolean
Do I have to re-write hundreds of functions or is there a setting in ‘Language’ or ‘Dialect’ I should be setting.
Thanks.
Harbour -> XSharp migration: function calls/returns
Harbour -> XSharp migration: function calls/returns
Hi Roland,
you may need more options, but to compile code with undefined variables you need at least the dialect Harbour and the options /lb (allow late bound calls), /memvar (support memvar, public, private) and /undeclared (support undeclared variables).
Then this code compiles:
Wolfgang
you may need more options, but to compile code with undefined variables you need at least the dialect Harbour and the options /lb (allow late bound calls), /memvar (support memvar, public, private) and /undeclared (support undeclared variables).
Then this code compiles:
Code: Select all
function Start( ) as void
System.Console.WriteLine("Hello x#!")
bValue := AnyFunc()
return
function AnyFunc()
return(.t.)
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
Harbour -> XSharp migration: function calls/returns
Hi Roland,
after moving your code you should think about strong typing your variables and functions to have better and much, much faster code.
Check out this code:
You may be surprized..... but the most important thing is the much better control at compile time.
Wolfgang
after moving your code you should think about strong typing your variables and functions to have better and much, much faster code.
Check out this code:
Code: Select all
function Start( ) as void
local nWeak
local nStrong as int
local dStart as DateTime
System.Console.WriteLine("start, not typed")
dStart := DateTime.Now
for nWeak := 1 to 10000000
nop
next
System.Console.WriteLine("ended, not typed, duration " + ( DateTime.Now - dStart ):ToString() )
System.Console.WriteLine("start, typed")
dStart := DateTime.Now
for nStrong := 1 to 10000000
nop
next
System.Console.WriteLine("ended, typed, duration " + ( DateTime.Now - dStart ):ToString() )
return
Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
Harbour -> XSharp migration: function calls/returns
Hi Roland,
As Wolfgang said, you need to set the Dialect to Harbour, and this will also require you to add references to the libraries XSharp.Core and XSHarp.RT. If you do not know how to do this, please just ask.
About /undeclared and /memvar, you need to set those options if needed, but if the vars you use are always defined with LOCAL statements, then this will not be needed. Most likely you will also need to enable /vo7 too pass parameters by reference, but that depends on the code.
Btw, is the app using @SAY GET commands for the presentation? If yes, we may have a solution so that you can keep also that code (almost) unchanged, but show the command line windows as regular windows using WinForms.
As Wolfgang said, you need to set the Dialect to Harbour, and this will also require you to add references to the libraries XSharp.Core and XSHarp.RT. If you do not know how to do this, please just ask.
About /undeclared and /memvar, you need to set those options if needed, but if the vars you use are always defined with LOCAL statements, then this will not be needed. Most likely you will also need to enable /vo7 too pass parameters by reference, but that depends on the code.
Btw, is the app using @SAY GET commands for the presentation? If yes, we may have a solution so that you can keep also that code (almost) unchanged, but show the command line windows as regular windows using WinForms.
Chris Pyrgas
XSharp Development Team
chris(at)xsharp.eu
XSharp Development Team
chris(at)xsharp.eu
Harbour -> XSharp migration: function calls/returns
Thanks for all your kind and speedy responses; great group!
I had missed your suggested 'Implicit Casts' and 'Late Binding' settings. I now included them and still get that 'Type Expected' error. I've included screen grabs of my updated settings.
I agree that I should cast all variables but the time do to so and subsequent testing would likely make the task impossible, it's roughly 32,000 lines of code.
Chris, I'm curious about your suggestion re @ SAY/GET.
Again, thanks so much for your help.
Roland
I had missed your suggested 'Implicit Casts' and 'Late Binding' settings. I now included them and still get that 'Type Expected' error. I've included screen grabs of my updated settings.
I agree that I should cast all variables but the time do to so and subsequent testing would likely make the task impossible, it's roughly 32,000 lines of code.
Chris, I'm curious about your suggestion re @ SAY/GET.
Again, thanks so much for your help.
Roland
- Attachments
-
- Language Settings.png (86.06 KiB) Viewed 886 times
-
- Dialect Settings and Run result.png (135.52 KiB) Viewed 886 times
-
- Application Dialect Setting.png (71.44 KiB) Viewed 886 times
Harbour -> XSharp migration: function calls/returns
Hi Roland,
unfortunately I don't use Visual Studio, but Chris's excellent XIDE, so I don't know what is missing in your configuration to compile without errors. The settings your screenshots show are correct, but I suspect there is something that they don't get applied.
Maybe they are different between the application and the project setting?
Regarding typing: of course it is not possibile to change them all, but touching the most time critic code could help.
After all, 32.000 lines of code is not that much - I have applications with more than 500.000 lines, and I know there are some (VO) applications ported to X# with more than a million of lines.
Wolfgang
unfortunately I don't use Visual Studio, but Chris's excellent XIDE, so I don't know what is missing in your configuration to compile without errors. The settings your screenshots show are correct, but I suspect there is something that they don't get applied.
Maybe they are different between the application and the project setting?
Regarding typing: of course it is not possibile to change them all, but touching the most time critic code could help.
After all, 32.000 lines of code is not that much - I have applications with more than 500.000 lines, and I know there are some (VO) applications ported to X# with more than a million of lines.
Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
Harbour -> XSharp migration: function calls/returns
Roland
Please enable the option “treat missing types as usual”
Robert
Please enable the option “treat missing types as usual”
Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
The Netherlands
robert@xsharp.eu
Harbour -> XSharp migration: function calls/returns
Rolland,
Regarding @SAY...GET commands, some time ago we had built a system that uses the already existing code unchanged and maps the commands to real controls (edit boxes, combo boxes etc) in real windows, so no code rewrite was necessary, only some window design in the (visual) window editor, to put the controls in nice places, group them in group controls etc. It was created to the specific needs and app (also written in Harbour) code of another customer, but I suspect that with some changes it can be adjusted to work with any codebase.
I'd say let's have a look first on the business code side of things, to see how easy it is to reuse it in X# (but keep in mind, that even if something does not work, we can most probably improve it quickly), and if you're satisfied with that part, then we can look into the visual side of things as well.
.
Regarding @SAY...GET commands, some time ago we had built a system that uses the already existing code unchanged and maps the commands to real controls (edit boxes, combo boxes etc) in real windows, so no code rewrite was necessary, only some window design in the (visual) window editor, to put the controls in nice places, group them in group controls etc. It was created to the specific needs and app (also written in Harbour) code of another customer, but I suspect that with some changes it can be adjusted to work with any codebase.
I'd say let's have a look first on the business code side of things, to see how easy it is to reuse it in X# (but keep in mind, that even if something does not work, we can most probably improve it quickly), and if you're satisfied with that part, then we can look into the visual side of things as well.
.
Chris Pyrgas
XSharp Development Team
chris(at)xsharp.eu
XSharp Development Team
chris(at)xsharp.eu
Harbour -> XSharp migration: function calls/returns
Thank you Robert, earlier on, I did a 'quick reply' to your message, but I can't see it. Gremlins. Your tip did the trick! Thanks!
Harbour -> XSharp migration: function calls/returns
Thanks Chris, I'll keep that in mind. Ideally, I'll re-write the presentation layer and hook it into the existing 'back-end'. This legacy system is very heavy on calculations and database activity, less so on visuals.