' Configuration system: parallel arrays for settings (flat 1D)
#COMPILE EXE
#DIM ALL

FUNCTION PBMAIN() AS LONG
    DIM secName(1 TO 5) AS STRING
    DIM secCount(1 TO 5) AS LONG
    DIM entKey(1 TO 50) AS STRING
    DIM entVal(1 TO 50) AS STRING
    LOCAL sc AS LONG
    LOCAL ec AS LONG
    LOCAL i AS LONG
    LOCAL j AS LONG
    LOCAL idx AS LONG
    LOCAL k AS STRING
    LOCAL v AS STRING
    LOCAL sn AS STRING
    PRINT "=== Configuration System ==="
    PRINT
    sc = 1
    secName(sc) = "Display" + SPACE$(9)
    secCount(sc) = 0
    ec = 1
    idx = (sc - 1) * 10 + ec
    entKey(idx) = "theme" + SPACE$(18)
    entVal(idx) = "dark" + SPACE$(36)
    secCount(sc) = ec
    ec = 2
    idx = (sc - 1) * 10 + ec
    entKey(idx) = "font_size" + SPACE$(14)
    entVal(idx) = "12" + SPACE$(38)
    secCount(sc) = ec
    ec = 3
    idx = (sc - 1) * 10 + ec
    entKey(idx) = "fullscreen" + SPACE$(12)
    entVal(idx) = "false" + SPACE$(35)
    secCount(sc) = ec
    sc = 2
    secName(sc) = "Editor" + SPACE$(10)
    ec = 1
    idx = (sc - 1) * 10 + ec
    entKey(idx) = "tab_size" + SPACE$(15)
    entVal(idx) = "4" + SPACE$(39)
    secCount(sc) = ec
    ec = 2
    idx = (sc - 1) * 10 + ec
    entKey(idx) = "word_wrap" + SPACE$(14)
    entVal(idx) = "true" + SPACE$(36)
    secCount(sc) = ec
    ec = 3
    idx = (sc - 1) * 10 + ec
    entKey(idx) = "font" + SPACE$(19)
    entVal(idx) = "Consolas" + SPACE$(32)
    secCount(sc) = ec
    sc = 3
    secName(sc) = "Build" + SPACE$(11)
    ec = 1
    idx = (sc - 1) * 10 + ec
    entKey(idx) = "optimization" + SPACE$(10)
    entVal(idx) = "2" + SPACE$(39)
    secCount(sc) = ec
    ec = 2
    idx = (sc - 1) * 10 + ec
    entKey(idx) = "debug" + SPACE$(18)
    entVal(idx) = "true" + SPACE$(36)
    secCount(sc) = ec
    PRINT "Configuration (" & FORMAT$(sc) & " sections):"
    PRINT "============================================================"
    FOR i = 1 TO sc
        sn = TRIM$(secName(i))
        PRINT "[" & sn & "]"
        FOR j = 1 TO secCount(i)
            idx = (i - 1) * 10 + j
            k = TRIM$(entKey(idx))
            v = TRIM$(entVal(idx))
            PRINT "  " & k & " = " & v
        NEXT j
    NEXT i
    PRINT
    PRINT "Reading values:"
    v = TRIM$(entVal(1))
    PRINT "  Display.theme = " & v
    v = TRIM$(entVal(23))
    PRINT "  Editor.font = " & v
    v = TRIM$(entVal(31))
    PRINT "  Build.optimization = " & v
    PRINT
    PRINT "Config system tests complete."
    FUNCTION = 0
END FUNCTION
