OK you've finally got me, X# is very cool!

Public support forum for peer to peer support with related to the Visual Objects and Vulcan.NET products
Juraj
Posts: 161
Joined: Mon Jan 09, 2017 7:00 am

OK you've finally got me, X# is very cool!

Post by Juraj »

Hi All

in a visit to chris's post I wrote a similar application for comparison, without using VO, It's written in a core dialect. I replaced DBserver
with OleDB.

Juraj
Attachments

[The extension viaef has been deactivated and can no longer be displayed.]

User avatar
wriedmann
Posts: 3755
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

OK you've finally got me, X# is very cool!

Post by wriedmann »

Hi Chris,
just to be clear for anybody else reading this thread, this is only ONE of the ways of how things work in X#.
thank you for your clarification! Sometimes, if you are asking 5 programmers for the solution of a problem, you will get at least 20 different solutions <g>.
I would like to include also this in the XIDE samples if you do not mind.
Of course you can do this! I'll send you an extended version of it later today.

Wolfgang

P.S. sometimes it would be very helpful to create a VS project or solution from an XIDE application, so even VS users could use it
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
User avatar
Chris
Posts: 4906
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

OK you've finally got me, X# is very cool!

Post by Chris »

OK, thanks!

About creating a VS solution, well the reason why I used my own format, was because I couldn't stand the VS project system, so I am really not looking forward to understand it and write code to utilize it/save in this format. But of course you are very welcome to write a plugin that does that if you like :)
Chris Pyrgas

XSharp Development Team
chris(at)xsharp.eu
User avatar
wriedmann
Posts: 3755
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

OK you've finally got me, X# is very cool!

Post by wriedmann »

Hi Chris,

the XPorter/VO creates a VS solution already, so you have the code.... I would have to reverse engineer the needed files.
If you can give me the code how you create a VS project, I will build the plugin <g>

Wolfgang

P.S. I remembered I had the source to the Xporter somewhere, and in fact, I have an old version of it, so I could take this as sample, if you agree
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
User avatar
Chris
Posts: 4906
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

OK you've finally got me, X# is very cool!

Post by Chris »

Hi Wolfgang,

Please have a look at your XSharpVOXPorterTemplates folder, and open the file template_VS.xsproj. As you will see, this is an already existing VS project file (I just created a new test project in VS and copied the project file), it just has a few wholes for inserting the files and references created by VOXPorter, which uses this file as a template.

So, no, I do not have code for creating a VS project file, only some very simple one to insert files and references. And even for that, I have simply hard coded inside the VOXporter the text that VS expects, just copied it again from an existing project file :)

You can find the complete VOXporter code here: https://github.com/X-Sharp/XSharpPublic ... /VOXporter
Chris Pyrgas

XSharp Development Team
chris(at)xsharp.eu
User avatar
wriedmann
Posts: 3755
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

OK you've finally got me, X# is very cool!

Post by wriedmann »

Hi Chris,

thank you very much! I will do that.

I have only too limited time to dedicate it to reverse engineering of the VS project files.

Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
FoxProMatt

OK you've finally got me, X# is very cool!

Post by FoxProMatt »

Wolfgang -

Thanks for the sample app and data. I was able to get the app running from XIDE and the DBFs.
2019-03-22 18_38_42-Window.png
2019-03-22 18_38_42-Window.png (99.17 KiB) Viewed 609 times
FoxProMatt

OK you've finally got me, X# is very cool!

Post by FoxProMatt »

Wolfgang -

I have studied this code, and while I can say as a VFP and C# coder, new to X#, it is indeed easy to follow what the code is doing, *however*, that sure is a LOT of code to get data from a DBF. You went to a DataTable, which I think is a .Net thing, right? In VFP we just say:

Code: Select all

USE SomeTable.DBF Alias MyData
Grid.Recordsource = "MyData"
This code sample iterates over every column in the table and every row in the table to build a DataTable, which is probably disconnected from the original DBF where the data came from.

So what paradigm am I missing, where I desire to bind a UI grid directly to a live DBF, or a cursor from a SQL Query?

Code: Select all

Static Method GetCustomerTable() As DataTable
	Local oCustomer		As DataTable
	Local oServer		As DBServer
	Local nField		As Int
	Local nFCount		As Int
	Local aFields		As Array
	Local cFieldName	As String
	Local oRow			As DataRow

	oCustomer			:= DataTable{ "Customer" }
	oServer				:= DBServer{ System.IO.Path.Combine( ProgSettings.DataPath, "Customer.dbf" ), True, True, ProgSettings.DefaultRDD }
	oServer:SetOrder( "Cust1.ntx" )
	oServer:GoTop()
	nFCount				:= oServer:FCount
	aFields				:= ArrayNew( nFCount )
	For nField := 1 UpTo nFCount
		cFieldName			:= Proper( oServer:FieldName( nField ) )
		aFields[nField]		:= cFieldName
		oCustomer:Columns:Add( cFieldName, System.Type.GetType( "System.String" ) )
	Next

	While ! oServer:EOF
		oRow				:= oCustomer:NewRow()
		For nField := 1 UpTo nFCount
			cFieldName			:= aFields[nField]
			If IsString( oServer:FieldGet( nField ) )
				oRow[cFieldName]	:= AllTrim( oServer:FieldGet( nField ) )
			Else
				oRow[cFieldName]	:= AsString( oServer:FieldGet( nField ) )
			EndIf
		Next
		oCustomer:Rows:Add( oRow )
		oServer:Skip()
	End
	oServer:Close()

	Return oCustomer
User avatar
lumberjack
Posts: 727
Joined: Fri Sep 25, 2015 3:11 pm
Location: South Africa

OK you've finally got me, X# is very cool!

Post by lumberjack »

Matt,
Yes that is a "hardcoded" approach for a specific customer table.
However, here is the beauty of X#. XSharpPublic contain the runtime source code. I will push a function DbDataTable soon and also have this feature in the OOP implementation DbServer.

Code will change to:

Code: Select all

USE SomeTable.DBF ALIAS Alias
oGrid:DataSource := DbDataTable()
Or:

Code: Select all

oCust :=  DbServer{<pars>, "SomeTable.DBF", <pars,...>, "Alias"}
oGrid:DataSource := oCust:DataTable()
Just remember there are very few people coming from VO that use the COMMAND/Functional DBF approach these days, most are using the OOP implementation.

Hope this satisfy your concern,
______________________
Johan Nel
Boshof, South Africa
User avatar
wriedmann
Posts: 3755
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

OK you've finally got me, X# is very cool!

Post by wriedmann »

Hi Matt,
that sure is a LOT of code to get data from a DBF.
yes, you are right about this.
But my code (one static function) is a connection between two worlds: the DBServer as VO data object to the .NET datatable.
Therefore it needs some connection code.
And if you look at my code, you see that there is no assumption of a data structure, and there could be one static function that takes a filename and returns a datatable - in fact my code is written so it is generalized.
If the DBServer would be understand SQL statements as the relative object in VFP does, it could be written in a select statement.
Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
Post Reply