Xbase++ forum

This forum is meant for questions about the XBase++ Language support in X#.

Anonymous

Xbase++ forum

Post by Anonymous »

Xbase++ support is in development by the X# Team. If you have a strong interest in joining the early development stage, please join the FOX program to gain access to the Private discussion forum.
User avatar
DenGhostYY
Posts: 15
Joined: Fri Sep 16, 2022 8:23 am

Some questions about migrating from Xbase++

Post by DenGhostYY »

Hello. Please answer my questions.[*]
[*]What function do you plan to implement? What Xbase++ documentation do you rely on? We need to know about this in order to migrate from Xbase++ to X#.
[*]Why did you deprecate functions Error(), Inkey()? What functions then to use instead of them?
[*]There is function Int() in Xbase++. I found a X# function Integer(), read the tip, however questions remain. What happens if the number is greater than the short?
What is the best way to get around this error?
It seems to me that just entering such the UDC is wrong.

Code: Select all

#xtranslate int(<x>) => integer(<x>)
X# Compiler version 2.16.0.5 (public)
-dialect:xBase++ -xpp1 -lb -memvar -vo1 -vo3 -vo5 -vo10 -vo15 -vo16

Code: Select all

procedure Main()
    ? int(12.4) // error XS0103: The name 'int' does not exist in the current context
    return
User avatar
wriedmann
Posts: 3784
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

Some questions about migrating from Xbase++

Post by wriedmann »

Hello,
PMFJI, but even if I'm not from the development team: you are waiting for an answer. A part from the fact that is weekend now: I can give you some sort of answer I could immagine one of the team members could give.
First the easy one: Inkey() and the other functions make only sense in a character mode application, and X# does not supports them. If you are using things like Inkey() in a console/command line application: the .NET Framework offers a System.Console class with static methods like ReadLine() and ReadKey():
https://learn.microsoft.com/en-us/dotne ... le.readkey
https://learn.microsoft.com/en-us/dotne ... e.readline
You can build your own function library to implement that function. The same could be made for the Int() function. And you are asking what is occurring when a value is too large for a function? Try it out, IMHO that is the most simple and fast thing (at least I would do that).

Regarding the functions to implement: the X# project is request driven. If you need a function that is not in the library, request it, or better, show code to implement it.
In your situation, if you have a large Xbase++ application to migrate, contact Robert and hire him for a day or more to look at your code, and then he can help you.
Or you can even pay him and his team for creating what you need. After all, it is an open source project and the development team needs to eat and to pay their bills.
Currently the projects has some larger sponsors and many small ones (the FoX members, including myself).

Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
User avatar
robert
Posts: 4572
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

Xbase++ forum

Post by robert »

Hi,

1) So far we have implemented the functions that our customers needed and asked for. If you are missing functions, please let us know. We will try to implement them then. Of course, you can also implement missing functions yourself and share them with us.

2) The Error() function in Xbase++ is the class function of the Error class. In .Net there normally is no "Class Function". This is something from Xbase++ (and Classs(y) in Clipper). The Inkey() function is used in Terminal based applications. X# is normally used to write either console apps, or Windows apps. In these contexts, Inkey() does not make sense. We do not plan to support writing terminal applications. The only exception is the ? (Qout) and ?? (QQout) that write to the console. SET CONSOLE and SET ALTERNATE are supported for this.

3) The function Int() was dropped in Visual Objects, because there is also a type with the name Int() and the expression Int(<something>) meant either cast a value to Int or dereference a pointer to an integer.
We an add that function in the Xbase++ runtime library if you depend on it.
Integer() should return the same results.
I am not sure why you are referring to Short in your question. If the value you send in to the function is between Int32.MinValue and Int32.MaxValue then the function returns an Int32 value. Otherwise it returns a float without fraction. That is why the return type of Integer() is not Int32 (or Int64) but USUAL.

Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
User avatar
DenGhostYY
Posts: 15
Joined: Fri Sep 16, 2022 8:23 am

Re: Xbase++ forum

Post by DenGhostYY »

Hello. Please tell me how to write a library of functions compatible with X# in C# using dependencies XSharp.RT and XSharp.XPP (dialect XBase++)
I tried to write

XbTools.cs

Code: Select all

using XSharp.RT;
using XSharp.XPP;

namespace XbTools
{
    public static class XbTools
    {
        public static XSharp.__Usual CharRem(XSharp.__Usual cDeleteChars, XSharp.__Usual cString)
        {
            return new XSharp.__Usual("result");
        }
    }
}
Program.prg
Doesn't compile without the XbTools.XbTools

Code: Select all

procedure Main()
    local s := XbTools.XbTools.CharRem("", "")
    ? s
    wait
return
User avatar
DenGhostYY
Posts: 15
Joined: Fri Sep 16, 2022 8:23 am

Re: Xbase++ forum

Post by DenGhostYY »

What language is better to write such functions in terms of performance?
User avatar
wriedmann
Posts: 3784
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

Re: Xbase++ forum

Post by wriedmann »

Hello,
C# does not knows anything about the xBase types.
You have to use only base .NET types, no usuals, arrays, dates or similar things.
And to use your class without a namespace you can simply add a
using XbTools;
in your .cs file.
Mixing C# and X# definitively works, I have done that several times. The only thing you have to be aware is that C# does not knows the special xBase datatypes.
Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
User avatar
wriedmann
Posts: 3784
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

Re: Xbase++ forum

Post by wriedmann »

Hello,
if you can use X# Core dialect, it should behave like C#.
Or you can also use the X# runtime, strong typing all variables.
Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
User avatar
robert
Posts: 4572
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

Re: Xbase++ forum

Post by robert »

Den,
DenGhostYY wrote: Tue Dec 19, 2023 9:08 am Hello. Please tell me how to write a library of functions compatible with X# in C# using dependencies XSharp.RT and XSharp.XPP (dialect XBase++)
I tried to write

XbTools.cs

Code: Select all

using XSharp.RT;
using XSharp.XPP;

namespace XbTools
{
    public static class XbTools
    {
        public static XSharp.__Usual CharRem(XSharp.__Usual cDeleteChars, XSharp.__Usual cString)
        {
            return new XSharp.__Usual("result");
        }
    }
}
Program.prg
Doesn't compile without the XbTools.XbTools

Code: Select all

procedure Main()
    local s := XbTools.XbTools.CharRem("", "")
    ? s
    wait
return
Our compiler adds a special attribute to assemblies that indicates which class contains static methods that should be treated as functions.
You can find the attribute here:
https://www.xsharp.eu/runtimehelp/html/ ... ribute.htm
You can also add a namespace with this attribute that should be automatically added as "using" at the start of your app.

If you write the code as a function in X# then this is done automatically by the compiler.

Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
User avatar
robert
Posts: 4572
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

Re: Xbase++ forum

Post by robert »

DenGhostYY wrote: Tue Dec 19, 2023 9:25 am What language is better to write such functions in terms of performance?
There should be no difference in runtime performance when written in C# or X#. The performance is not determined by the compiler but by the algoritm used.
Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
Post Reply