Tagxxx() functions
Posted: Tue Jun 30, 2020 5:21 pm
Hi Robert and Chris,
While trying out some Tagxx() functions i noticed some problems. The sample uses a structural and a non-structual compound index. Each CDX has 3 Tags
-TagCount () does not differentiate whether a CDX is specified or not. The func always returns the number of all available (6) TAGs.
-The Tag() function needs a parameter check since I always have to type e.g. Tag ( , 1) instead of Tag (1)
-My FP-DOS Order() results are different than the X# Order() results. I created a Order_Fix() function that shows the same results as FP-DOS. Maybe someone from the VFP community verifies that ?
the required DBF and CDXs are attached.
regards
Karl-Heinz
While trying out some Tagxx() functions i noticed some problems. The sample uses a structural and a non-structual compound index. Each CDX has 3 Tags
-TagCount () does not differentiate whether a CDX is specified or not. The func always returns the number of all available (6) TAGs.
-The Tag() function needs a parameter check since I always have to type e.g. Tag ( , 1) instead of Tag (1)
-My FP-DOS Order() results are different than the X# Order() results. I created a Order_Fix() function that shows the same results as FP-DOS. Maybe someone from the VFP community verifies that ?
the required DBF and CDXs are attached.
Code: Select all
/*
FP-dialect
xsharp.core
xsharp.rt
xsharp.vfp
*/
FUNCTION Start( ) AS VOID
LOCAL cPath, cDBF, cCDX AS STRING
? RddSetDefault() // "DBFVFP"
?
cPath = "d:test"
cDBF = "small.dbf"
cCDX = "small1x.cdx"
DbUseArea ( TRUE, , cPath + cDBF ) // auto opens small.cdx
DbSetIndex ( cPath + cCDX ) // open small1x.cdx
DbSetOrder ( 5 )
? "Total No. of Tags" , DbOrderInfo(DBOI_ORDERCOUNT ) // 6 ok
?
? "No. of SMALL Tags" , DbOrderInfo(DBOI_ORDERCOUNT , "SMALL" ) , "must show 3" // 6 instead of 3 , VO shows correctly 3
? "TagCount() SMALL" , TagCount ( "SMALL" ) , "must show 3" // 6 instead of 3
?
? "No. of SMALL1X Tags" , DbOrderInfo(DBOI_ORDERCOUNT , "SMALL1X" ) , "must show 3" // 6 instead of 3 , VO shows correctly 3
? "TagCount() SMALL1X" , TagCount ( "SMALL1X" ) , "must show 3" // 6 instead of 3
?
?
FOR VAR i = 1 TO TagCount()
? Cdx (i) , TAG_FIX( i ) , TagNo ( Tag ( , i) ,Cdx(i) )
NEXT
?
// note: above, the active order was set to 5 . That´s "ORDER2" of the small1x.cdx
? "*" , Order("small",1) // ok, "d:testsmall1x.cdx"
? "*" , Order("small" ) // wrong "d:testsmall1x.cdx"
? "*" , Order( 1 ) // wrong "d:testsmall1x.cdx"
? "*" , Order () // wrong "d:testsmall1x.cdx"
?
? "*" , Order_Fix("small",1) // ok, "d:testsmall1x.cdx"
? "*" , Order_Fix("small" ) // ok, "ORDER2"
? "*" , Order_Fix( 1 ) // ok, "ORDER2"
? "*" , Order_Fix () // ok, "ORDER2"
?
DbSetOrder(0)
// ok, shows empty strings only
? "*" , Order("small",1)
? "*" , Order("small" )
? "*" , Order( 1 )
? "*" , Order ()
?
? "*" , Order_Fix("small",1)
? "*" , Order_Fix("small" )
? "*" , Order_Fix( 1 )
? "*" , Order_Fix ()
DbCloseArea()
RETURN
FUNCTION TAG_FIX ( CDXFileName, nTagNumber, uArea ) AS STRING CLIPPER
// a param check is needed, something like ...
IF PCount() = 1
IF IsNumeric ( CDXFileName )
nTagNumber = CdxFileName
CdxFileName = NIL
ENDIF
ENDIF
RETURN Tag ( CDXFileName , nTagNumber , uArea )
FUNCTION Order_Fix ( uArea, nPath) AS STRING
IF PCount() == 0
RETURN DbOrderInfo(DBOI_NAME, , 0) // Tag ( , 0)
ELSEIF PCount() == 1
RETURN (uArea)->DbOrderInfo(DBOI_NAME, , 0) //nTag ( , 0)
ELSEIF PCount() == 2
IF IsNumeric ( nPath )
RETURN (uArea)-> DbOrderInfo(DBOI_BAGNAME)
ENDIF
ENDIF
RETURN ""
Karl-Heinz