// Advanced INDEX ON test — FOR condition + function expressions FUNCTION Main() LOCAL i, nCount ? "=== Index Advanced Test ===" dbCreate("idxadv", {{"ID","N",6,0},{"FIRST","C",10,0},{"LAST","C",10,0},{"CITY","C",10,0}}) USE "idxadv" FOR i := 1 TO 30 APPEND BLANK FieldPut(1, i) FieldPut(2, {"John","Jane","Bob","Alice","Tom","Mary"}[Int(Mod(i-1,6))+1]) FieldPut(3, {"Kim","Lee","Park","Choi","Yoon"}[Int(Mod(i-1,5))+1]) FieldPut(4, {"Seoul","Tokyo","NYC"}[Int(Mod(i-1,3))+1]) NEXT ? "Records:", RecCount() // 1. INDEX ON with UPPER() ? "" ? "--- 1. INDEX ON UPPER(LAST) ---" INDEX ON UPPER(LAST) TO idxadv_upper GO TOP ? " First:", AllTrim(FieldGet(3)) GO BOTTOM ? " Last:", AllTrim(FieldGet(3)) SEEK "KIM" ? " SEEK KIM: Found=", Found() // 2. INDEX ON with concatenation ? "" ? "--- 2. INDEX ON LAST+FIRST ---" INDEX ON LAST+FIRST TO idxadv_combo GO TOP ? " First:", AllTrim(FieldGet(3)), AllTrim(FieldGet(2)) SEEK "Choi" ? " SEEK Choi: Found=", Found(), "Name:", AllTrim(FieldGet(3)), AllTrim(FieldGet(2)) // 3. INDEX ON with FOR condition ? "" ? "--- 3. INDEX ON LAST FOR CITY = Seoul ---" INDEX ON LAST TO idxadv_seoul FOR CITY = "Seoul" GO TOP nCount := 0 DO WHILE !Eof() nCount++ SKIP ENDDO ? " Records in Seoul index:", nCount, "(expected 10 of 30)" GO TOP ? " First Seoul:", AllTrim(FieldGet(3)), "City:", AllTrim(FieldGet(4)) // 4. INDEX ON UPPER(LAST+FIRST) — nested function + concat ? "" ? "--- 4. INDEX ON UPPER(LAST+FIRST) ---" INDEX ON UPPER(LAST+FIRST) TO idxadv_full GO TOP ? " First:", AllTrim(FieldGet(3)), AllTrim(FieldGet(2)) SEEK "KIMJOHN" ? " SEEK KIMJOHN: Found=", Found() USE ? "" ? "=== Done ===" RETURN NIL