CreateOrder

This forum is meant for questions and discussions about the X# language and tools
Post Reply
User avatar
Horst
Posts: 337
Joined: Tue Oct 13, 2015 3:27 pm

CreateOrder

Post by Horst »

Hello

I found a different between VO and X#

In VO this makes a index:
odbServer:createorder ( "ArtikelNUNeinp",,"upper (Artikel1)+upper (Artikel2)" ,{||Upper ( _Field->Artikel1)+Upper ( _Field->Artikel2)} , FALSE,FALSE)

Vo is cutting the indexname "ArtikelNUNeinp" to "ArtikelNUN" (10 chars)

In x# not, X# is not making the index.

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

Re: CreateOrder

Post by robert »

Horst,
What did you expect to happen?
What is the name of the DBF file (you're not including a file name, so this becomes a tag in the production index).

Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
Luc
Posts: 28
Joined: Sat Apr 30, 2016 7:31 pm
Location: Belgium

Re: CreateOrder

Post by Luc »

Horst,
It works as in VO, same code:
It depends on what you want to do and the rdd driver you are using, expecting a single bag (ntx, idx) or multi bag index, cdx or adi.

In this sample, the indexname is either the same as the dbfname for multi bags, or a combination of the dbfname and the tagname for a single.
The indexname get's the proper extension.

I also add the path to the indexfile name, (if that would not be part of your dbfname).

Used to index a temporary db table, (code snippet from class tmpServer inherit dbserver)
...
IF SELF:w_sMyDriver = DRIVER_ADSADT
sIndexfile := sDBFName
ELSE
sIndexfile := sDBFName + "_" + AllTrim(ctagName)
ENDIF

sIndexfile := PutExtension(sIndexfile, SELF:_indexExtension() ) // add extension NTX, CDX or ADI
sIndexfile := SELF:w_sPath + sIndexfile

lok := SELF:CreateOrder(ctagName , sIndexfile, cCondition)
...

You need to specify the indexfile name if you don't want to add it to the current production index.
Also, in m.o. you don't need to specify the condition as a string and as a codeblock, the string condition is sufficient.

Luc
User avatar
Horst
Posts: 337
Joined: Tue Oct 13, 2015 3:27 pm

Re: CreateOrder

Post by Horst »

Hello

I see, i forget to say i am using dbfcdx.

And this is my Function to build the Indexs in the last 10 or longer years.

Code: Select all


X#

		IF File (cFileName+".cdx")
			IF FErase (String2Psz (cFilename+".cdx")) = FALSE
				SELF:WriteCgiLog ("CDX von "+cFilename+" konnte nicht gelöscht werden. Abbruch")
			ENDIF
		ENDIF

		IF File (cFileName+".dbf")
			odbTmp 		:= _cryptserver {cFilename,FALSE,FALSE,"DBFCDX"}   // ohne DBF
			DO WHILE AllTrim(odbIndex:FIELDGET(#dbf_name)) == cName
				cCdx_Name	:= AllTrim (odbIndex:FIELDGET(#cdx_name))  
				cCdx_Key	:= AllTrim (odbIndex:FIELDGET(#cdx_key))     
				SELF:WriteCgiLog ("     Name und Schluessel:"+cCdx_Name+"-"+cCdx_Key)
				lOrderOk 	:= odbTmp:createorder (	cCdx_Name,,cCdx_Key)
				IF  ! lOrderOk ; SELF:WriteCgiLog ("ERROR "+cCdx_Name+", "+cCdx_Name+" Index ERROR !") ; ENDIF
				SELF:WriteCgiLog ("      Index gemacht "+cFilename)
				odbIndex:Skip(+1)
			ENDDO
			odbTmp:Close()
		ELSE
			SELF:WriteCgiLog("File nicht gefunden: "+cFileName)
			odbIndex:Skip(+1)
		ENDIF

VO Testcode
FErase (String2Psz ("c:\xide\tmp\artikel.cdx"))
   	oDbServer 	:= _CryptServer { "c:\xide\tmp\artikel.dbf", DBSHARED, IIF (TRUE, DBREADWRITE, DBREADONLY) ,"DBFCDX"}
	? odbServer:FIELDGET (#Artikel1)+" "+NTrim (odbServer:recno)
	odbServer:createorder (	"ArtikelNUNeinp",,"upper (Artikel1)+upper (Artikel2)"	,{||Upper ( _Field->Artikel1)+Upper ( _Field->Artikel2)}	,	FALSE,FALSE)

and i only say there is a different between VO and X# . In VO 'cCdx_Name' can be longer then 10 charaters.

Horst
User avatar
Chris
Posts: 4936
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

Re: CreateOrder

Post by Chris »

Hi Horst,

Indeed, that's an incompatibility to VO, which always ignores the order names longer than 10 characters, both when creating or opening the order. Will log it as a bug, but for now you can just truncate the order names to 10 characters.
Chris Pyrgas

XSharp Development Team
chris(at)xsharp.eu
User avatar
Horst
Posts: 337
Joined: Tue Oct 13, 2015 3:27 pm

Re: CreateOrder

Post by Horst »

Hello Chris

I fixed already my App.
It was more a information to others.
I was running into a problem with the missing indexes. And it was long time hidden because this index was only used in a special moment.

Horst
User avatar
Chris
Posts: 4936
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

Re: CreateOrder

Post by Chris »

Hi Horst,

OK, understood, thanks for reporting it!
Chris Pyrgas

XSharp Development Team
chris(at)xsharp.eu
Post Reply