A simple program - many errors!

We encourage new members to introduce themselves here. Get to know one another and share your interests.
dexter
Posts: 11
Joined: Tue Dec 01, 2020 10:14 am

A simple program - many errors!

Post by dexter »

Hey guys,

Before I submit the very simple code that throws exceptions almost everywhere (very discouraging) I would like to ask if you have online/offline documentation of the implemented commands? Lack of documentation + lack of proper intellisense (+ no access to definitions) causes lots of pain and sadness

So, here is the code. I put comments where it run ok and where it throws an exception.

Code: Select all

***********************************
FUNCTION Start() AS VOID STRICT
***********************************
? "Hello World! Today is ",Today()

use c:work_temp && --> exception, can't recognize a field (Field 'DAYSCMPL' is not valid)

use C:meter in 0 && OK
use C:compinfo in 0  && OK

select compinfo.compid, compinfo.comp_desc from compinfo join meter on compinfo.compid = meter.compid into cursor cm && --> exception, doesn't recognize this select as valid command
select cm
scan
	? transform(compid) && --> exception, transform should have second param(why?)
endscan 


WAIT
RETURN	
ENDFUNC 
Any help is highly appreciated.
Dimitar
User avatar
Chris
Posts: 4986
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

A simple program - many errors!

Post by Chris »

Hi Dimitar,

Please go to the folder <Program files>XShapInclude. You can find all the commands that are currently implemented in the files dbcmd.xh and FoxProCmd.xh.

Embedded SQL is indeed not supported yet.

About Transform(), we were simply not aware that FoxPro allows it to be called with only one parameter, but now that we know this, we will add support for it. For now, for your tests, you can use AsString() instead of Transform(), in order to convert any data type to string.
Chris Pyrgas

XSharp Development Team
chris(at)xsharp.eu
User avatar
kevclark64
Posts: 127
Joined: Thu Aug 15, 2019 7:30 pm
Location: USA

A simple program - many errors!

Post by kevclark64 »

Dimitar, I wouldn't be discouraged about the current state of X# in regard to Foxpro compatibility. I've been following X# for about the last 18 months and I've been pretty shocked at the incredible progress they've made. X# is already mostly compatible with Foxpro and simple Foxpro programs can be converted over to X# fairly easily. I'd say the main outstanding issues currently are conversion of forms and reports and also supporting inline SQL (which you saw does not currently work). These are definitely major items, but I expect them to be resolved at some point. There is also the fact that if you want to move ahead with a modern update to Foxpro that is highly compatible with existing code then X# is really your only option. I believe the project is very much worth supporting.
dexter
Posts: 11
Joined: Tue Dec 01, 2020 10:14 am

A simple program - many errors!

Post by dexter »

I'm kinda confused about the priorities - if Forms/Report are more important than dealing with DBFs and inline sql ...hmm

I suspect the most legacy code comes from desktop apps which drives the development efforts for X#. But I really hoped dealing natively with DBFs is what would make X# to shine in .NET world.

I'm keen to try and convert a service we have to X#.Net but having no ability to work with cursors is a huge stopper.

Dexter
User avatar
robert
Posts: 4567
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

A simple program - many errors!

Post by robert »

Dexter,

I am not sure where you base your opinion about our priorities on?
FoxPro DBF support, including DBC etc is one of the most important features. It is also useful for other "dialects", that helps too. We will add most DDL commands in one of the next builds. So you can expect CREATE TABLE CREATE CURSOR etc.
Embedded SQL SELECT statements is a bit more complicated. This requires a full blown SQL Parser, analyzer etc.
Rushmore is also on our todo list bbut this also requires a relatively complicated engine that analyzes conditions (filter, for condition for indexes, scan conditions etc) and translates these to query plan based on the available index. Much of what is needed for SQL access to DBF files is also needed for Rushmore.

If you really need embedded SQL and Rushmore we can probably deliver that on top of the Advantage support for VFP tables fairly quickly.

We are working very hard on the Forms, Menus etc, so they can be read from a VFP Project and brought into a VS solution.
Reporting will follow after that.

Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
FoxProMatt

A simple program - many errors!

Post by FoxProMatt »

If you really need embedded SQL and Rushmore we can probably deliver that on top of the Advantage support for VFP tables fairly quickly.
Robert - could you elaborate a little on what this would look like in a PRG, and what assets would we need in our project/code base that we don't currently in a basic VFP/DBF app?
User avatar
robert
Posts: 4567
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

A simple program - many errors!

Post by robert »

Karl,

Advantage supports file /record based access and sql based access to DBF data
it also supports Query Optimization (rushmore)
I am not sure if Advantage supports DBC databases. I'll have to check that.

We can probably map embedded SQL statements into a function that executes an advantage query and returns it as an X# cursor. We already have a AxSqlRDD for this.

You can use Advantage in Client-Server mode as well as with a Local Server . The (free) local server works in File-Sharing mode like FoxPro. The only problem that I am aware with the local server is that it does not work in a Terminal Server client session (officially).

Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
FoxProMatt

A simple program - many errors!

Post by FoxProMatt »

Robert - So with Advantage, does it allow SQL commands sent to *local cursors*, which did not originate from opening a DBF table.

Imagine this (very common) scenario in real VFP apps:

Code: Select all

SqlExec() against Sql Server table A to create local Cursor1
next,

Code: Select all

SqlExec() against Sql Server table B to create local Cursor2
next,
Local SQL command against Cursor1 and Cursor2:

Code: Select all

Select A.Field1, B.Field2 
 From Cursor1
   Join Cursor2 on Cursor1.FieldBlah = Cursor2.FieldBlah
 Where Cursor1.FieldX = "ABC123"

You see?? No DBF's at all, but we still need to execute SQL commands against local Cursors, no matter where they came from. Heck, Maybe Cursor1 is from Sql Sever and Cursor2 is from a DBF, but we still need local SQL commands to work against these local cursors.
User avatar
robert
Posts: 4567
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

A simple program - many errors!

Post by robert »

Matt,
What FoxPro calls a local cursor is what other databases call a temporary table.
Of course Advantage also supports temporary tables.
This is an example from the Advantage documentation:

Code: Select all


// This example creates two temporary tables for intermediate results

// Step 1. Create a temporary table named DeptCount and at the same time
// populate it with summary data from an existing table in the
// database
 

SELECT deptnum, count(*) as NumEmployees
INTO #DeptCount
FROM employees
GROUP BY deptnum

// Step 2. Create another temporary table named LocCount which list the
// number of employees in each location for each department.

SELECT deptnum, location, count(*) as cnt
INTO #LocCount
FROM employees
GROUP BY deptnum, location

// Finally using the 2 temporary tables to list the percent of employee
// on each location for each department

SELECT a.deptnum, a.location, ( a.cnt * 100 ) / b.NumEmployees As PercentAtLocation
FROM #LocCount a, #DeptCount b
WHERE a.deptnum = b.deptnum
I'll investigate a bit more but I think mapping FoxPro SQL statements to Advantage is not too complicated.

Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
mainhatten
Posts: 200
Joined: Wed Oct 09, 2019 6:51 pm

A simple program - many errors!

Post by mainhatten »

robert wrote: I am not sure if Advantage supports DBC databases. I'll have to check that.
AFAIR they have an analogue table to which a DBC can be "upsized" near automatically. So a bit more work on table structue modification, not everything doable in vfp available in the Advantage DataDict..
We can probably map embedded SQL statements into a function that executes an advantage query and returns it as an X# cursor. We already have a AxSqlRDD for this.
It should also be easy to hook any resulting ADO.Net datareader and pipe the resultset not into a .Datatable, but into a new .dbf temp table on disk - missing then is "only" the logic of tableupdate already existing in Ado.Net very similar to vfp logic.
You can use Advantage in Client-Server mode as well as with a Local Server . The (free) local server works in File-Sharing mode like FoxPro. The only problem that I am aware with the local server is that it does not work in a Terminal Server client session (officially).
I think even local server (while simple ISAM) does not allow vfp-similar access in vfp but needs to be accessed via ODBC/OLEDB and then via Cursoradapter, View or SQL_Exec to a vfp-based cursor - but with >2GB added to base table if wanted. If xSharp allows such direct access, it just shows the potential of RDD concept.

regards
thomas
Post Reply