Reference

Patterns

The idiomatic D3 / PickBASIC boilerplate you write every day - 9 ready-to-paste snippets, each verified against the reference. Copy one, then tweak the names.

File I/O

Open a file
Attach a file to a variable before reading or writing it.
OPEN "","CUSTOMER" TO CUST.F ELSE
   STOP 201, "CUSTOMER"
END
Uses openstop
Read an item
Load an item into a dynamic array, handling "not on file".
READ REC FROM CUST.F, ID THEN
   NAME = REC<1>
END ELSE
   NAME = ""
END
Uses read
Write or delete an item
Save an updated item, or remove one from the file.
WRITE REC ON CUST.F, ID
DELETE CUST.F, OLD.ID

Locking

Read with a lock, update, release
Update an item safely under concurrency. WRITE (or RELEASE) frees the lock.
READU REC FROM CUST.F, ID LOCKED
   PRINT "Locked by another process"
   STOP
END THEN
   REC<3> = BALANCE
   WRITE REC ON CUST.F, ID    ;* WRITE releases the update lock
END ELSE
   RELEASE CUST.F, ID
END

Select lists

Build a select list and loop
Iterate every item-ID in a file (or an active select list).
SELECT CUST.F
LOOP
WHILE READNEXT ID DO
   READ REC FROM CUST.F, ID THEN
      PRINT ID : " " : REC<1>
   END
REPEAT

Dynamic arrays

Read and replace fields
Pull or set values inside a dynamic array by attribute, value, and subvalue.
NAME = REC<1>          ;* attribute 1
CITY = REC<5,2>        ;* attribute 5, value 2
REC<3> = "ACTIVE"      ;* replace attribute 3
REC = REPLACE(REC, 4, 2, 0, "NEW")
Loop over multivalues
Walk each value in a multivalued attribute.
COUNT = DCOUNT(REC<4>, @VM)
FOR I = 1 TO COUNT
   PRINT REC<4,I>
NEXT I

Dates

Today, format, and parse
Convert Pick internal day numbers to and from readable dates.
TODAY = DATE()
PRINT OCONV(TODAY, "D4/")          ;* 06/05/2026
INTERNAL = ICONV("06/05/2026", "D")

Transactions

Atomic multi-file update
Commit changes to several files as one unit, or roll them all back.
BEGIN WORK
   WRITE ORD  ON ORDERS,   OID
   WRITE LINE ON ORDLINES, LID
COMMIT WORK ELSE
   ROLLBACK WORK
   STOP "Order not saved"
END

Snippets use placeholder names (CUST.F, REC, ID). Swap them for yours. Want a page explained? Paste any of these into the Code Annotator to link every statement and function.