DBFLibDBF and FPT files for Ring

Getting started

Install the package and create, fill and read the first table.

Install#

Install the package with RingPM, the Ring package manager, in one step:

Shell
ringpm install dbflib from ringpackages

No external dependencies are required.

Quick start#

Ring
load "dbflib.ring"

# --- Create a new table ---
oDbf = new DBFFile

aFields = [
    ["ID",      "N",  6, 0],
    ["NAME",    "C", 40, 0],
    ["SALARY",  "N", 12, 2],
    ["ACTIVE",  "L",  1, 0],
    ["NOTES",   "M", 10, 0]   # memo field — used just like any other
]

oDbf.create("employees.dbf", aFields)

# --- Append a record — memo field uses replace() like everything else ---
oDbf.append()
oDbf.replace("ID",     1)
oDbf.replace("NAME",   "Ahmed Al-Rashid")
oDbf.replace("SALARY", 85000.50)
oDbf.replace("ACTIVE", true)
oDbf.replace("NOTES",  "Senior developer, joined 2023.")

# --- Close and reopen ---
oDbf.close()

oDbf = new DBFFile
oDbf.open("employees.dbf")

# --- Read all records — fieldGet() works on memo fields too ---
oDbf.goTop()
while ! oDbf.isEof()
    ? trim(oDbf.fieldGet("NAME")) + " — " + oDbf.fieldGet("SALARY")
    ? oDbf.fieldGet("NOTES")
    oDbf.skip(1)
end

oDbf.close()
DBFLib - DBF and FPT files for Ring, made with ringdoc.