xsharp.eu • Descend() in index expressions, using Vulcan runtime
Page 1 of 3

Descend() in index expressions, using Vulcan runtime

Posted: Sat Sep 22, 2018 5:35 pm
by wriedmann
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

Descend() in index expressions, using Vulcan runtime

Posted: Sat Sep 22, 2018 6:18 pm
by FFF
I seem to remember a lengthy thread in the newsgroup, many moons ago, with the result that descend is broken....?

Descend() in index expressions, using Vulcan runtime

Posted: Sat Sep 22, 2018 6:48 pm
by wriedmann
Hi Karl,
Thank you very much. This means I have to wait until the X# runtime and RDDs are ready.
Wolfgang

Descend() in index expressions, using Vulcan runtime

Posted: Sun Sep 23, 2018 6:53 am
by Chris
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

Descend() in index expressions, using Vulcan runtime

Posted: Sun Sep 23, 2018 10:32 am
by FFF
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

Descend() in index expressions, using Vulcan runtime

Posted: Sun Sep 23, 2018 11:02 am
by wriedmann
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

Descend() in index expressions, using Vulcan runtime

Posted: Sun Sep 23, 2018 11:08 am
by Guy Deprez
Wolfgang,
Did you try descend(dtos(datum))? datum is first converted to string and then descend is called.
Guy

Descend() in index expressions, using Vulcan runtime

Posted: Sun Sep 23, 2018 1:27 pm
by wriedmann
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

Descend() in index expressions, using Vulcan runtime

Posted: Sun Sep 23, 2018 2:06 pm
by wriedmann
Hi Chris,

I was now able to reproduce the issue in a small sample:
The following index expression works:

Code: Select all

DbCreateOrder( "DATEFIELD", cCdxName, "Descend( DateField )" )
and the following fails with a runtime error:

Code: Select all

DbCreateOrder( "SDATEFIELD", cCdxName, "Str( Descend( DateField ), 10 )" )
The runtime error says:

Code: Select all

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.
DescendTester.zip
(1.49 KiB) Downloaded 73 times
Wolfgang

P.S. for them that are not using XIDE, this is the full sample code:

Code: Select all

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

Descend() in index expressions, using Vulcan runtime

Posted: Sun Sep 23, 2018 2:09 pm
by wriedmann
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