**------------------------------------------------- Create Cursor test(CodeTest char(5), Num I NULL) Index On (CodeTest + BinToC(Num)) tag Num Insert into test(CodeTest, Num) values ('Code1', 1) Insert into test(CodeTest, Num) values ('Code1', 0) cSeekExpr = CodeTest + BinToC(Num) && I want found this record, i retrive the index key! Insert into test(CodeTest, Num) values ('Code2', 0) && Removing this line the problem doesn't exists REINDEX *Index On (CodeTest + BinToC(Num)) tag Num && Moving this line after Create cursor the problem doesn't exists ** The actual Tag is "Num" ** So i expect that following sequence for the first 2 records ** Codetest Num ** ------------------ ** Code1 0 ** Code1 1 ** ** But the order is ** Codetest Num ** ------------------ ** Code1 1 ** Code1 0 ** The index was not created properly!! GO TOP ACTIVATE SCREEN clear ? 'Actual Key: ' + KEY() ? 'Codetest Num' ** cSeekExpr is the key retrvieved from second record inserted ? ? 'Searching for: "Code1" + BINTOC(0)' ? 'Found() = ', KEYMATCH(cSeekExpr),SEEK(cSeekExpr) USE in testThe problem is not related to the BINTOC() function or nullable field,
**------------------------------------------------- *the bug is present h = 3 && for any n 1..238 n = 128 && for any n 0..255 x = 255 && for any x 1..255 a1 = CHR(0) && for any a1 string a2 = CHR(1) && for any a2>a1 Create Cursor test(F1 C(MAX(LEN(a1),LEN(a2))), F2 C(m.h+1)) Index On F1 + F2 tag Num Insert into test(F1,F2) values (m.a1, REPLICATE(CHR(m.n),m.h)+CHR(m.x)) Insert into test(F1,F2) values (m.a1, REPLICATE(CHR(m.n),m.h)+CHR(0)) cSeekExpr = F1 + F2 Insert into test(F1,F2) values (m.a2, REPLICATE(CHR(m.n),m.h)+CHR(0)) && Removing this line the problem doesn't exists REINDEX ** cSeekExpr is the key retrvieved from second record inserted ? ? 'Searching for: "Code1" + BINTOC(0)',cSeekExpr ? 'Found() = ', KEYMATCH(cSeekExpr),SEEK(cSeekExpr) LOCATE FOR F1+F2==cSeekExpr ? FOUND() SELECT * from ALIAS() WHERE F1+F2==cSeekExpr USE in testBUT THIS OCCUR ONLY FOR CONCAT STRINGS ?
**------------------------------------------------- *the bug is present h = 3 && for any n 1..238 n = 128 && for any n 0..255 x = 255 && for any x 1..255 a1 = CHR(0) && for any a1 string a2 = CHR(1) && for any a2>a1 Create Cursor test(F1 C(MAX(LEN(a1),LEN(a2))+m.h+1)) Index On F1 tag Num Insert into test(F1) values (m.a1+REPLICATE(CHR(m.n),m.h)+CHR(m.x)) Insert into test(F1) values (m.a1+REPLICATE(CHR(m.n),m.h)+CHR(0)) cSeekExpr = F1 Insert into test(F1) values (m.a2+REPLICATE(CHR(m.n),m.h)+CHR(0)) && Removing this line the problem doesn't exists REINDEX ** cSeekExpr is the key retrvieved from second record inserted ? ? 'Searching for: "Code1" + BINTOC(0)',cSeekExpr ? 'Found() = ', KEYMATCH(cSeekExpr),SEEK(cSeekExpr) LOCATE FOR F1==cSeekExpr ? FOUND() SELECT * from ALIAS() WHERE F1==cSeekExpr USE in testI have found a workaround, but before post it i test it.