fbpx

Descend() in index expressions, using Vulcan runtime

  • Wolfgang Riedmann
  • Wolfgang Riedmann's Avatar Topic Author
  • Offline
More
3 months 3 weeks ago #1 by Wolfgang Riedmann
Descend() in index expressions, using Vulcan runtime was created by Wolfgang Riedmann
Hello,

I have now tried to move a VO application I'm working on to X#, using the Vulcan runtime.

But my application fails to deal with index expressions that contain the Descend() function, like these:
upper(artnr)+str(descend(datum),10)
upper(kdnr+artnr)+str(descend(datum),10)
upper(kname+artnr)+str(descend(datum),10)

and several more of them.

Is there anything I can do other than wait for the X# runtime and RDDs?

TIA

Wolfgang

Please Log in or Create an account to join the conversation.

More
3 months 3 weeks ago #2 by Karl Faller
I seem to remember a lengthy thread in the newsgroup, many moons ago, with the result that descend is broken....?

Please Log in or Create an account to join the conversation.

  • Wolfgang Riedmann
  • Wolfgang Riedmann's Avatar Topic Author
  • Offline
More
3 months 3 weeks ago #3 by Wolfgang Riedmann
Replied by Wolfgang Riedmann on topic Descend() in index expressions, using Vulcan runtime
Hi Karl,
Thank you very much. This means I have to wait until the X# runtime and RDDs are ready.
Wolfgang

Please Log in or Create an account to join the conversation.

More
3 months 3 weeks ago #4 by Chris Pyrgas
Replied by Chris Pyrgas on topic Descend() in index expressions, using Vulcan runtime
Karl, you could very well be right of course, but personally I don't remember this discussion about Descend() being broken. At least there was no open bug report logged about this in when I was a member of the team in the vulcan days, I would had known otherwise.

Wolfgang, can you please give more information? What do you mean it fails, do you get runtime errors, or the sorting is not done correctly? Can you please give us a full repro sample?

TIA
Chris

XSharp Development Team
chris(at)xsharp.eu

Please Log in or Create an account to join the conversation.

More
3 months 3 weeks ago - 3 months 3 weeks ago #5 by Karl Faller
Chris,
that's why is said "seem to remember" ;)- if right, it was way before VN appeared. I think Steph(?) and Geoff were involved. As i hadn't use for it, i never bothered to check for relevance.

Karl
Last edit: 3 months 3 weeks ago by Karl Faller. Reason: typo

Please Log in or Create an account to join the conversation.

  • Wolfgang Riedmann
  • Wolfgang Riedmann's Avatar Topic Author
  • Offline
More
3 months 3 weeks ago #6 by Wolfgang Riedmann
Replied by Wolfgang Riedmann on topic Descend() in index expressions, using Vulcan runtime
Hi Chris,
I have to isolate the code as it is deep in my class library, and only orders that contain descend() are atfected, and all of them.
The same code works in VO for at least 10 years now, but since that is an application I'm currently working on I have tried to move it to X#.
Wolfgang

Please Log in or Create an account to join the conversation.

More
3 months 3 weeks ago #7 by Guy DEPREZ
Wolfgang,
Did you try descend(dtos(datum))? datum is first converted to string and then descend is called.
Guy

Please Log in or Create an account to join the conversation.

  • Wolfgang Riedmann
  • Wolfgang Riedmann's Avatar Topic Author
  • Offline
More
3 months 3 weeks ago #8 by Wolfgang Riedmann
Replied by Wolfgang Riedmann on topic Descend() in index expressions, using Vulcan runtime
Hi Guy,

I cannot change that as this is part of a more than 10 year old VO application, and if I change the index expressions, I will have to change also the application itself.

Wolfgang

Please Log in or Create an account to join the conversation.

  • Wolfgang Riedmann
  • Wolfgang Riedmann's Avatar Topic Author
  • Offline
More
3 months 3 weeks ago #9 by Wolfgang Riedmann
Replied by Wolfgang Riedmann on topic Descend() in index expressions, using Vulcan runtime
Hi Chris,

I was now able to reproduce the issue in a small sample:
The following index expression works:
DbCreateOrder( "DATEFIELD", cCdxName, "Descend( DateField )" )
and the following fails with a runtime error:
DbCreateOrder( "SDATEFIELD", cCdxName, "Str( Descend( DateField ), 10 )" )

The runtime error says:
Vulcan.NET Runtime Error

Error Code: 34 [Data width error]
Error Subcode: 1121 [Data width error]
Subsystem:
Funktion: ORDCREATE

Please find attaches a small console application (as XIDE export file) that creates a small DBF in your c:\temppath and then creates the order.

File Attachment:

File Name: DescendTester.zip
File Size:1 KB

Wolfgang

P.S. for them that are not using XIDE, this is the full sample code:
function Start( ) as void                     
	local cAlias			as string
	local cDbfName			as string
	local cCdxName			as string
	local aStruct			as array
	local nArea				as dword
	
	try

	cAlias				:= "DbfTest"	
	cDBFName			:= String.Format( "c:\temp\{0}.dbf", cAlias )
	cCdxName			:= String.Format( "c:\temp\{0}.cdx", cAlias )

	System.Console.WriteLine( "Creating table " + cDbfName + "..." )
	aStruct				:= ArrayNew( 3 )
	aStruct[1]			:= { "CHARFIELD", "C", 10, 0 }
	aStruct[2]			:= { "NUMFIELD", "N", 10, 0 }
	aStruct[3]			:= { "DATEFIELD", "D", 10, 0 }
	DBCreate( cDbfName, aStruct, "DBFCDX", true, cAlias,, false )
	if ( nArea := Select( cAlias ) ) > 0
		( nArea )->( DBCloseArea() )
	endif
	if DBUseArea( true, "DBFCDX", cDbfName, cAlias, false, false ) 
		nArea				:= Select( cAlias )
		( nArea )->( DBAppend() )
		( nArea )->Charfield	:= "Hi X#"
		( nArea )->NumField		:= 2018
		( nArea )->DateField	:= Today()
		( nArea )->( Dbcommit() )
		if ( nArea )->( DbCreateOrder( "CHARFIELD", cCdxName, "Descend( CharField )" ) ) == false
			System.Console.WriteLine( "Error creating order!" )
		endif
		if ( nArea )->( DbCreateOrder( "NUMFIELD", cCdxName, "Descend( NumField )" ) ) == false
			System.Console.WriteLine( "Error creating order!" )
		endif
		if ( nArea )->( DbCreateOrder( "DATEFIELD", cCdxName, "Descend( DateField )" ) ) == false
			System.Console.WriteLine( "Error creating order!" )
		endif  
		if ( nArea )->( DbCreateOrder( "SDATEFIELD", cCdxName, "Str( Descend( DateField ), 10 )" ) ) == false
			System.Console.WriteLine( "Error creating order!" )
		endif  
	else
		System.Console.WriteLine( "Error opening table" )
	endif
	
	catch oEx as Exception
		
	System.Console.WriteLine( oEx:Message )
	System.Console.WriteLine( oEx:StackTrace )
	
	end try	
	
return
Attachments:

Please Log in or Create an account to join the conversation.

  • Wolfgang Riedmann
  • Wolfgang Riedmann's Avatar Topic Author
  • Offline
More
3 months 3 weeks ago #10 by Wolfgang Riedmann
Replied by Wolfgang Riedmann on topic Descend() in index expressions, using Vulcan runtime
Hello,

an addition: in VO this code works. And the VO help says about Descend():

This example uses Str() instead of DToS() since Descend() of a date returns a numeric value


Wolfgang

Please Log in or Create an account to join the conversation.

  • Wolfgang Riedmann
  • Wolfgang Riedmann's Avatar Topic Author
  • Offline
More
3 months 3 weeks ago #11 by Wolfgang Riedmann
Replied by Wolfgang Riedmann on topic Descend() in index expressions, using Vulcan runtime
Hi Chris,

problem isolated.
In VO, Descend( Today() ) returns 2773423, ValType N
In X# with the Vulcan runtime, it returns 10.04.5982, ValType D

Unfortunately, the X# runtime behaves as the Vulcan runtime, even when using the VO dialect, as it returns a date value, and the same value as the Vulcan runtime.

This may be a problem when migrating Vulcan applications, but as far as I have understand the thread in 2013 about Descend() problems, no one is using the Descend() function in Vulcan.

Wolfgang

Please Log in or Create an account to join the conversation.

More
3 months 3 weeks ago - 3 months 3 weeks ago #12 by Robert van der Hulst
Replied by Robert van der Hulst on topic Descend() in index expressions, using Vulcan runtime
Wolfgang,

You are right. We currently emulate the Vulcan behavior and not the VO behavior. I will change that for the next build. VO returns 5231808 - the LONG(_CAST) of the date for Descend.
And that number 5231808 is the difference between 31-12-2999 and 01-01-1900 in case you were wondering (Harbour and clipper use the same calculation).

Robert

XSharp Development Team
The Netherlands
This email address is being protected from spambots. You need JavaScript enabled to view it.
Last edit: 3 months 3 weeks ago by Robert van der Hulst.

Please Log in or Create an account to join the conversation.

More
3 months 3 weeks ago #13 by Chris Pyrgas
Replied by Chris Pyrgas on topic Descend() in index expressions, using Vulcan runtime
Hi Wolfgang,

Thanks, yes you are right, it is a bug. I think it's possible to create a workaround though, let me give it a try and will get back to you.

@Karl, ah sorry, didn't realize you were talking about the VO implementation itself!

Chris

XSharp Development Team
chris(at)xsharp.eu

Please Log in or Create an account to join the conversation.

  • Wolfgang Riedmann
  • Wolfgang Riedmann's Avatar Topic Author
  • Offline
More
3 months 3 weeks ago #14 by Wolfgang Riedmann
Replied by Wolfgang Riedmann on topic Descend() in index expressions, using Vulcan runtime
Hi Robert,

thank you very much!

Wolfgang

Please Log in or Create an account to join the conversation.

More
3 months 3 weeks ago #15 by Chris Pyrgas
Replied by Chris Pyrgas on topic Descend() in index expressions, using Vulcan runtime
Hi Wolfgang,

Here's a quick fix, for now that you use the vulcan runtime. Just put this anywhere in your libraries or main exe and the macro compiler should pick this implementation at runtime:
FUNCTION Descend(val)
	IF IsDate(val)
		RETURN 5231808 - (DWORD)(DATE)val
	END IF
RETURN VulcanRTFuncs.Functions.Descend(val)

Chris

XSharp Development Team
chris(at)xsharp.eu

Please Log in or Create an account to join the conversation.

  • Wolfgang Riedmann
  • Wolfgang Riedmann's Avatar Topic Author
  • Offline
More
3 months 3 weeks ago #16 by Wolfgang Riedmann
Replied by Wolfgang Riedmann on topic Descend() in index expressions, using Vulcan runtime
Hi Chris,

this is again to demonstrate you were right when you wrote I should try to migrate my VO applications whenever possible.

Wolfgang

Please Log in or Create an account to join the conversation.

  • Wolfgang Riedmann
  • Wolfgang Riedmann's Avatar Topic Author
  • Offline
More
3 months 3 weeks ago #17 by Wolfgang Riedmann
Replied by Wolfgang Riedmann on topic Descend() in index expressions, using Vulcan runtime
Hi Chris,

I have tried it, it does not fails anymore.

But somewhere later during the reindexing process my application crashes with a System.Reflection.TargetInvocationException error - I have to check it further.

But there seems to be some incompatibility between VO and Vulcan/X#, because I check if the index expression from the dictionary and the one from the index are the same - and I start reindexing only when they are not the same.
With the X# version the reindexing starts even when I have already built the indexes with the VO version.
I have to check also this one.

But in the meantime I have to continue the development of the other ported application (that uses only part of the database of a VO application, but stores the main data on a remote SQL server).

Wolfgang

Please Log in or Create an account to join the conversation.

More
3 months 3 weeks ago #18 by Chris Pyrgas
Replied by Chris Pyrgas on topic Descend() in index expressions, using Vulcan runtime
Hi Wolfgang,

Yeah, maybe somewhere there's a difference between VO/Vulcan/X#. When you locate which index is not the same as is supposed to be, please let us know, usually it's easy to fix such issues.

Chris

XSharp Development Team
chris(at)xsharp.eu

Please Log in or Create an account to join the conversation.

  • Wolfgang Riedmann
  • Wolfgang Riedmann's Avatar Topic Author
  • Offline
More
3 months 3 weeks ago #19 by Wolfgang Riedmann
Replied by Wolfgang Riedmann on topic Descend() in index expressions, using Vulcan runtime
Hi Chris,

this may be important when the X# RDDs are ready and in use, but I have my doubts you can do anything in the Vulcan RDDs.
The strange thing is that one order failed this check:
if ( cAlias )->( DBOrderInfo( DBOI_NUMBER, cIndexFile, self:TagName ) ) == 0
The orders name is "LFNR", and the order expression is "upper(lfnr,10)", with a ordercondition of !(Inaktiv)

There are many other orders with similar name and similar expressions, and they work.

This is very strange, as this code is more than 20 years old, and has worked from VO 1.0 on....

I will check that further, but it could take a few days as I have other projects to move forward.

Wolfgang

Please Log in or Create an account to join the conversation.

More
3 months 3 weeks ago #20 by Chris Pyrgas
Replied by Chris Pyrgas on topic Descend() in index expressions, using Vulcan runtime
Hi Wolfgang,

It depends on where the problem is, because as you saw with the Decend() function it was easy to provide a quick workaround. No rush at all, when you get the time to look into it again and andnarrow it down a bit, please let us know so we can have a look.

Chris

XSharp Development Team
chris(at)xsharp.eu

Please Log in or Create an account to join the conversation.