Files
five/examples/test_index_adv.prg
Charles KWON OhJun 59568f3301 Five v0.9 — Harbour + Go fusion language
- Compiler: PP → Lexer → Parser → Analyzer → Gengo pipeline
- Parser: 232/236 (98%) Harbour compatibility, registry-based dispatch
- RTL: 351 Harbour-compatible functions
- RDD: DBF/NTX/CDX engines with Rushmore bitmap optimization
- Go Interop: IMPORT + pkg.Func() + obj:Method() with FastPath (15M calls/sec)
- HB_FUNC API: Full Harbour C API compatible Go bridge
- Concurrency: SPAWN/LAUNCH/GOROUTINE, <-, WATCH, PARALLEL FOR, ASYNC/AWAIT
- Extensions: Multi-return, DEFER, Slice, f-string, Nil-safe ?:, CONST
- Macro Compiler: Runtime AST parsing and evaluation
- Debugger: TUI debugger with source display, breakpoints, stepping
- FRB: Native + Pcode dual mode runtime binary
- Tests: 13 packages ALL PASS

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-31 09:41:50 +09:00

65 lines
1.8 KiB
Plaintext

// 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