FoxPro function list updated

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

mainhatten
Posts: 200
Joined: Wed Oct 09, 2019 6:51 pm

FoxPro function list updated

Post by mainhatten »

FoxProMatt_MattSlay wrote: Remember, in FoxPro, these DBFs do not have to be open first... If there is no Alias already alive with these table names, VFP will do a USE to open the DBFs, and leave them open.
In addition to the description, if DBFs are open, they are still USED AGAIN as to not touch record pointer or fall prey to already set "set filter", "set key" or similar stuff. Work areas opened AGAIN will be closed automatically after SQL.
Clauses Readwrite or NoFilter force creating a new table (which might be RAM based).
Karl-Heinz
Posts: 774
Joined: Wed May 17, 2017 8:50 am
Location: Germany

FoxPro function list updated

Post by Karl-Heinz »

robert wrote:Thomas,
You are right, Roslyn provides that. We also have "X# Sscript" support, but the scripting does not support dialects yet (so it runs in pure X# Core).
I'll discuss with Nikos if we can add dialect support in the scripting engine. When we can then we can certainly support compile() and execscript().
Hi Robert,

I´ve noticed that it´s possible to add to the msi interpreter header files, so the option to select in msi a dialect would be great ! Some of the commands work, but because of the core dialect a command like "USE" fails.

Code: Select all

#R "XSharp.Core"
#R "XSharp.RT"
#R "XSharp.VO"
#include "c:xsharpincludedbcmd.xh"
#include "c:xsharpincludeset.xh"

USING STATIC xSharp.Core.functions
USING STATIC xSharp.RT.functions
USING STATIC xSharp.VO.functions


// ------------------------

SET EXCLUSIVE OFF

LOCAL cDBF AS STRING

cDBF := "D:testxsharp.dbf"

// USE "D:testxsharp.dbf" NEW VIA "DBFCDX" ALIAS  "XSHARP1"

dbUseArea ( .T. , "DBFCDX" , cDBF , "XSHARP1" ) 

dbusearea ( .T. , "DBFCDX" , cDBF , "XSHARP2" )

GO BOTTOM

SKIP -4


? "list content of Field no. 1"
? "---------------------------"
?

do while ! eof()

	? Fieldget ( 1 ) 
		
	SKIP 1 // dbskip (1)

enddo 


SELECT 1
? Alias()  

SELECT 2
? Alias()  


CLOSE DATABASES  // DBCloseAll()

SELECT a
? Alias() 

SELECT b
? Alias()


?
?

// Console.WriteLine ("press any key" ) 
// Console.Read() 

regards
Karl-Heinz
mainhatten
Posts: 200
Joined: Wed Oct 09, 2019 6:51 pm

FoxPro function list updated

Post by mainhatten »

robert wrote:You'll be able to contribute in a few weeks. After finishing the current build I will add function prototypes for all the functions from the list to the source and I will also create a xml file for the documentation of these functions.
I'll write a small tool to extract the documentation from the VFPX help project (will give them credits of course) so we can fill the help fairly quickly.
After that you can start filling in functions, either by copying the implementation from the toolkit or by writing it yourself.

Please give me a few weeks (let's say Jan 1st) to set this up.
Hi Robert,

still waiting - can you give an update ?

regards
Thomas
User avatar
robert
Posts: 4262
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

FoxPro function list updated

Post by robert »

Thomas,

Please have a look at https://github.com/X-Sharp/XSharpPublic ... XSharp.VFP
The file functionsToImplement.txt has a list of the functions that need to be implemented and some instructions on "what to do", also in relation to documenting these functions.
The current "empty" implementations of these functions are in files with the names "todo-A".prg, "todo-B.prg" etc.

After implementing I plan to move the functions to a source file with a meaningful name.

If you want to work on this, you should:
1) clone the repo
2) write the code (please write (unit) test code as well). We will add a VFP unit tests project later this week.
3) send me a pull request or simply zip the code and send it..

What we really like:
- Strongly type the return values of all functions (when multiple return types, type as USUAL)
- Strongly type the parameters when all parameters are mandatory
- For optional parameters add checks and throw an exception for incorrect parameters. You can also call runtime functions such as EnforceNumeric() and EnforceString(). Or you check with IsString(), IsNumeric() etc.
- Make sure you test "edge" cases in the implementation, such as empty strings, negative numbers etc.
- Use as much "standard .Net" code as possible. For example for the Just..() functions I have used the normal methods in the System.IO.Path class to retrieve extensions and filenames. I did not write a "parser" for this. I have also not hard coded the directory separator in "AddBs" (even though the name implies a backslash) because on non windows platforms this might be a forward slash instead of a backslash.

Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
RGreim4XS
Posts: 41
Joined: Sat Feb 08, 2020 7:47 am

FoxPro function list updated

Post by RGreim4XS »

Hello, Im still using vpme for my VFP9 apps. And they use their own classes and tables to live without the DBC features. But without DBC you don’t have long field names and some other features..
BR Rainer
FoxProMatt

FoxPro function list updated

Post by FoxProMatt »

By "vpme", I assume you are referring to "Visual ProMatrix Enterrpise" ??

https://promatrix.com/
And they use their own classes and tables to live without the DBC features. But without DBC you don’t have long field names and some other features..
BR Rainer
So, I'm not sure what point(s) you are trying to say here.
mainhatten
Posts: 200
Joined: Wed Oct 09, 2019 6:51 pm

FoxPro function list updated

Post by mainhatten »

Hi Robert,
(if I sound peeved, irate or belligerent, PLEASE don't take it personal, blame it on lack of sleep, Microsoft and no Axe/Firewood combination around here)

I tried to get a testrun done. XIDE (my usual playpen) did not see new functions, guess they were created after Bandol 2.2, so compile and feed to XIDE.
Downloaded .Zip from Git, unpacked into Directory on D:xSRT
Plan: Edit and compile in VStudio, copy over into Dirs for XIDE, check there

Battle with VStudio (wants new updates, refuses to load, interim XIDE debug not possible anymore...)
results in me giving up, installing VStudio and XIDE again. Debug of previous small tsts possible again.
Trying to load still fails, Project wants NetCore(? not certain anymore...) 4.6, installed 4.6.1
Modifying project leads to further errors compiling, as I cannot find the best place to fix
Delete Git/Project, install new in D;
Trying to load still fails, Project wants NetCore(? not certain anymore...) 4.6, installed 4.6.1
Installing 4.6, Project loads.
Compilation with some small problems (CURRENCY >> USUAL), Some KeyFile not on expected directory position, path D:xSRTRuntimeXSharp.VFPCommon.created, XSharp.snk dropped from D:xSRTCommon
seems to compile, moans about missing dlls in debug, dopped them in various places until no moaning anymore.
Compilation succeeds!
Copying over into
c:Program Files (x86)XSharpAssemblies
c:Program Files (x86)XSharpRedist
switching to XIDE fails to compile
Editing / Adding XSharp.VFP.xml with Just...() resolves compiler error
BUT STILL RUNTIME ERROR EITHER WITH System.String or USUAL as Parameter type.

System.MissingMethodException
Methode nicht gefunden: "XSharp.__Usual XSharp.VFP.Functions.JustDrive(System.String)".

Callstack :
static System.Void console.Exe.Functions.start()() : C:XIDEPrgconsole.prg : 28

Pls tell me the places I goofed off...

Changes to NtoM and MtoN in NumericFunctions.Prg to get it to compile here under VS, included in larger zip.

regards
thomas
XSharp.VFP.zip
(6.29 MiB) Downloaded 27 times
Prg.zip
(8.35 KiB) Downloaded 28 times
User avatar
robert
Posts: 4262
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

FoxPro function list updated

Post by robert »

Thomas,

I am sorry to hear that you are struggling. And I don't take it personally <g>.
Some remarks:
- The currency support is in the 2.3 compiler. You do not have that compiler yet.
- You will therefore not be able to compile XSharp.RT, unless you also build the compiler
- I am not sure why your project wants .Net Core. Non of our runtime components requires .Net core.
- To help with the VFP functions you should normally only need to download the code to the XSharp.VFP component. I am sure that this will not work now (until we have released 2.3) because functions like NToM and MToN require the Currency support in the new compiler.
- The keyfiles are in the right location if you compile with VS. Chris is the only one in our team that works with XIDE. You should ask him what to change to get the XIDE code to run. I can imagine that the Runtime.xiproj file needs to be updated, since I have added some new files since it was last updated in October 2019.
- When you install X# then we install the runtime files in the GAC. When testing you have to make sure that you are testing with the updated runtime and not with the files from the GAC. That's why there is an option to NOT install the runtime in the GAC in the installer.

Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
User avatar
Chris
Posts: 4584
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

FoxPro function list updated

Post by Chris »

Guys,
robert wrote: - The keyfiles are in the right location if you compile with VS. Chris is the only one in our team that works with XIDE. You should ask him what to change to get the XIDE code to run. I can imagine that the Runtime.xiproj file needs to be updated, since I have added some new files since it was last updated in October 2019.
It's updated now!

robert wrote: - When you install X# then we install the runtime files in the GAC. When testing you have to make sure that you are testing with the updated runtime and not with the files from the GAC. That's why there is an option to NOT install the runtime in the GAC in the installer.
Unfortunately for myself that's not an option, because I also need to be looking at many reports that do assume the dlls are in the GAC and it is not convenient adjusting them every single time, so what I am doing is to do my changes in the runtime, close XIDE, update the files in the GAC (just a simple copy & paste), then restart XIDE.

But for you Thomas, what you can do is to remove all X# runtime references from the GAC and replace them with direct references to the "active" dlls that you use/compile, then also delete the X# files from the GAC and then always work with your own set.
Chris Pyrgas

XSharp Development Team test
chris(at)xsharp.eu
mainhatten
Posts: 200
Joined: Wed Oct 09, 2019 6:51 pm

FoxPro function list updated

Post by mainhatten »

robert wrote: What we really like:
- Strongly type the return values of all functions (when multiple return types, type as USUAL)
- Strongly type the parameters when all parameters are mandatory
- For optional parameters add checks and throw an exception for incorrect parameters. You can also call runtime functions such as EnforceNumeric() and EnforceString(). Or you check with IsString(), IsNumeric() etc.
- Make sure you test "edge" cases in the implementation, such as empty strings, negative numbers etc.
- Use as much "standard .Net" code as possible. For example for the Just..() functions I have used the normal methods in the System.IO.Path class to retrieve extensions and filenames. I did not write a "parser" for this. I have also not hard coded the directory separator in "AddBs" (even though the name implies a backslash) because on non windows platforms this might be a forward slash instead of a backslash.
When frustration grew higher, I read some sources...
Substring() in RT.Functions reads like typical xBase code, checking if second and third parameter are filled and so on, whereas in Core function overloading is used. Correct if core style is preferred, as seen also in FileIO ?

Thinking esp. about functions like
GETNEXTMODIFIED(nRecordNumber [, cTableAlias | nWorkArea] [, lNoFire])
GETFLDSTATE(cFieldName | nFieldNumber [, cTableAlias | nWorkArea])

where I could at least type in the overloads, as implementation might be premature at my current level.
Am I correct in guessing that
GETFLDSTATE(nFieldNumber, nWorkArea )
would require least other work, as typically work is done via nWorkare and nFieldNumber, which otherwise has to be searched via FieldPos if given fiekldname ?
Methods to check for existance seen and planned to be used in overloads...

Also, only glanced at in quickreading: is there Support for Python-Slice like Substr in Core when start is negative ?
Not allowed in "pure" vfp, but might be handled/offered via assert or another function name (SliceString?) -
perhaps ask other vfp devs on that.

regards
thomas
Post Reply