Gemischtes / mishmash

Deutschsprachiges X#-Forum – German language forum

Moderator: wriedmann

Post Reply
RGreim4XS
Posts: 41
Joined: Sat Feb 08, 2020 7:47 am

Gemischtes / mishmash

Post by RGreim4XS »

Hallo ich mal wieder...
hab viele Jahre AVFPX im Einsatz gehabt. Vorteil Foxpro rein, http raus. Der Teil für Http und Co ist ist in C# geschrieben.

https://github.com/claudefox/ActiveVFP/ ... r/App_Code

Viel gibts ja damit noch ein paar Ideen :
Gruß Rainer
User avatar
robert
Posts: 4260
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

Gemischtes / mishmash

Post by robert »

Horst,
Horst wrote:Hallo
Eine Frage zu PTR.
LOCAL ptrFile AS PTR das führt zu einem Fehler - unsave context nun habe ich es in
LOCAL ptrFile AS INTPTR abgeändert und es kommt kein Fehler
Darf man das ? Kann man dann die FCreate etc Functionen mit gutem Gewissen nutzen ? :-)
PTR is considered "unsafe" because you can use that type to address random locations in memory.

Something like

Code: Select all

 BYTE(ptrFile) := 42,
which writes the number 42 to the memory location pointed to by ptrFile.

The FCreate() and other low level file functions return a PTR in VO but this PTR is not really a memory location but just a unique ID. That is why in X# we have changed these functions to return an IntPtr instead of a PTR.
If you compile with the /unsafe compiler option enabled then you can cast an IntPtr to a PTR and back.

Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
User avatar
Horst
Posts: 327
Joined: Tue Oct 13, 2015 3:27 pm

Gemischtes / mishmash

Post by Horst »

Hallo Robert
So i will use IntPtr ;-)
Question : I tryed to find out how XSharp handles the FOpen Function. The code is open source. so i was looking in GitHub but idont find it there.
Horst
User avatar
robert
Posts: 4260
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

Gemischtes / mishmash

Post by robert »

Horst,
Look in the folder https://github.com/X-Sharp/XSharpPublic ... /Functions for the file File.Prg.
It contains the class XSharp.IO.File. this class implements all that is needed, so opening, reading, writing, closing etc.
The FOpen() function calls FOpen2 which calls Sharp.IO.File.CreateFile(cFileName, oFileMode).
The handles returned are not the real "windows" handles but are random numbers stored in an IntPtr.
We are not using the windows file handles to make sure that our code also works on other platforms.

When running on Windows we use a special filestream object
See https://github.com/X-Sharp/XSharpPublic ... Core/Types, the file Win32FileStream.
This class has a hFile internally which is the real Win32 file handle. But that is not the file handle that is returned by FOpen().

Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
User avatar
Horst
Posts: 327
Joined: Tue Oct 13, 2015 3:27 pm

Gemischtes / mishmash

Post by Horst »

Hallo
Ich habe nun versucht ein C# Webserver Beispiel mit IlSpy in Xsharp code zu übersetzen.
Fehler gibt es bei:
c#:
internal class QuizzServer : HttpServer
{
public QuizzServer(int threadCount) : base(threadCount)
{
}
}
xsharp:
INTERNAL CLASS QuizzServer INHERIT HttpServer
PUBLIC CONSTRUCTOR(threadCount AS LONG );
base(threadCount)
END CLASS
Ich habe keine Ahnung wie ich das übersetzen soll.
Horst
User avatar
wriedmann
Posts: 3655
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

Gemischtes / mishmash

Post by wriedmann »

Hallo Horst,

Code: Select all

INTERNAL CLASS QuizzServer INHERIT HttpServer
PUBLIC CONSTRUCTOR(threadCount AS LONG )
super( threadCount )
END CLASS
Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
User avatar
Horst
Posts: 327
Joined: Tue Oct 13, 2015 3:27 pm

Gemischtes / mishmash

Post by Horst »

Danke Wolfgang
base = super
constructor = init
Muss ich mir in meinen alten Schädel meisseln ;-)
User avatar
wriedmann
Posts: 3655
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

Gemischtes / mishmash

Post by wriedmann »

Hallo Horst,
unter X# ist immer "Constructor()" zu verwenden, nicht "Init()".
"Base" ist nur in C# gültig, in X# ist es wie in VO "super".
Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
User avatar
Horst
Posts: 327
Joined: Tue Oct 13, 2015 3:27 pm

Gemischtes / mishmash

Post by Horst »

c#
HttpListenerContext context = httpListener.GetContext();
messages.Add(context);
Ist context in der Methode definiert, ist das dann in xsharp/vo Local ?
Und messages.add (httpListener.GetContext()) würde doch auch gehen?? Wird in der Methode nur einmal gebraucht.
Gruss Horst
User avatar
wriedmann
Posts: 3655
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

Gemischtes / mishmash

Post by wriedmann »

Hallo Horst,

Code: Select all

HttpListenerContext context = httpListener.GetContext();
messages.Add(context);
ist in X# so zu schreiben:

Code: Select all

local context := httpListener:GetContext() as HttpListenerContext
messages:Add(context)
Wenn die Variable "context" sonst nirgends mehr gebraucht wird, kannst Du das ohne weiteres auch so schreiben:

Code: Select all

messages:Add( httpListener:GetContext())
Achtung auf Doppelpunkt statt Punkt!
Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
Post Reply