HOW TO WRITE 12D MACROS — COMPANION FILES
==========================================

These are the example and configuration files from the book, supplied as
known-good references. The book teaches you to type them yourself; these
copies are for comparison when something on your machine misbehaves, and
as ready-made starting points for your own tools.

CONTENTS
  ch02_setup\   The complete first_macro project from Chapter 2:
                workspace file, .vscode\tasks.json build task, and
                first_macro.4dm.
  ch03_first_program\
                The site_note project from Chapter 3: the complete
                first macro with its documentation header.
  templates\    skeleton.4dm -- the book's standard starting file;
                12d-macros.code-snippets -- the book's snippet
                library, grown chapter by chapter. To use it: run
                Snippets: Configure User Snippets in VS Code, create
                a new global snippets file, and paste this file's
                contents in. Snippets for panel widgets arrive with
                Part VI.
                for every new macro: documentation header over an
                empty main. Copy it, rename it, fill in the header.
  ch04_error_lab\
                The Chapter 4 fault lab: a clean base program plus
                eight fault_*.4dm files, each seeded with exactly one
                mistake, and ANSWERS.txt. Diagnose from the compiler
                message before opening the answers.
  ch05_program_anatomy\
                The version_note project from Chapter 5: a two-file
                macro proving #include and #define, with the version
                travelling from version.h into the output.
  ch06_variables\
                The peg_summary project from Chapter 6 (variables,
                initialisation, assignment, labelled report) plus
                probes.4dm - two checkpoint experiments whose output
                feeds back into the book.
  ch07_operators\
                arithmetic_table from Chapter 7: every operator and
                promotion claim printed as evidence, including two
                marked experiments. Predict each row before reading.
                arithmetic_table_capture.4dm writes the same table
                to c:\12d\macros\arithmetic_table_output.txt for
                saving or sending (uses Chapter 23 file machinery
                early, purely as a capture tool).
  ch08_flow\
                chainage_checker from Chapter 8: stepping, an if
                ladder, a switch crew rotation, tolerance matching,
                and the book's first production zero-divide guard.
  ch09_functions\
                function_kit from Chapter 9 (prototypes, reference
                out-parameters, table-of-contents layout) plus
                helpers.h - the founding of your shared library:
                real_equal and round_to, ready to promote to
                C:\12d\macros\include.
  ch10_text\
                string_lab from Chapter 10 (building, formatting,
                dissecting, parsing) plus helpers.h v1.1, which
                adds pad_left and pad_right - copy it over your
                shared library copy.
  ch11_collections\
                misclose_stats from Chapter 11: a Dynamic_Real
                walked one-based, a fixed crew tally, and three
                probe blocks (verdict codes, arrays by reference,
                and the commented-out edges probe - read its
                caution before uncommenting).
  ch12_geometry\
                radiation_check from Chapter 12: join and polar on
                hand-checkable numbers, three angle languages,
                chainage/offset vs a baseline, and two probes.
                Ships helpers.h v1.2 (adds bearing_join and
                polar_point) - copy over your shared library copy.
  ch13_elements\
                model_census from Chapter 13 - the first live read
                of a 12d project. EDIT THE MODEL_NAME DEFINE to a
                model in your own project, run inside 12d, and the
                census prints a row per element plus the probe
                block the book's record needs.
  ch14_project\
                project_atlas from Chapter 14: project header,
                whole-project model census, Find_models pattern
                search, the book's first database write (create-
                or-reuse "macro atlas"), and the model placed on
                a view. Edit the VIEW_NAME define if your view is
                not "1".
  ch15_properties\
                string_xray from Chapter 15 - the book's first
                interactive macro. Pick a string in 12d: identity,
                vertex table, traverse listing (bearings/dists/
                grades via the shared library), and the first
                visible write (recolour). Probe block measures the
                Select_string verdict both ways.
  ch16_creation\
                setout_maker from Chapter 16 - the first macro that
                puts new survey data into a project: four computed
                pegs and a path string, created by the verified
                five-move pipeline. Ships superdims.h (dimension
                constants under the manual's own names) - promote
                it beside helpers.h in your shared include.
  ch17_strings\
                conformance_check from Chapter 17 - the daily tool:
                pick a design string, then pick check points one
                by one (Esc ends); each is dropped onto the design
                and reported as chainage / offset / level diff.
                Probe rows measure dir's language, the offset sign,
                and the string's chainage datum.
  ch18_strings2\
                string_workshop from Chapter 18 - the first
                geometry-changing tool, and Prompt's debut. Pick a
                string, choose by number: lift / regrade / arc
                (length audited against trigonometry) / densify
                (rebuilt into "macro dense", original untouched).
                SCRATCH DATA ONLY. The lift's Calc_extent is
                marked for the reshape-extent experiment.
  ch19_attributes\
                conformance_stamp from Chapter 19 - the checker
                grown into a record-writer: each checked point is
                stamped with CONF_CH / CONF_OFF / CONF_DZ /
                CONF_DATE attributes, verified by re-read and the
                wardrobe listing, with a probe block measuring
                exists-polarity, type codes, wrong-type reads and
                missing-name reads. Stamps are visible in the
                element's properties in 12d.
  ch20_tins\
                tin_check from Chapter 20 - conformance against a
                SURFACE. TIN name via Prompt (Text overload), the
                sanity line (points/triangles), the pick loop with
                the doubly-guarded Tin_height, and probes: exists
                polarity, outside-boundary face, the diagonal
                reveal at the square's centre, Tin_slope raw.
                Prerequisite: a TIN triangulated from macro setout
                (suggested name "PEGS TIN").
  ch21_alignments\
                align_lab from Chapter 21 - reads an alignment's
                hip/vip intent tables, then creates MACRO ALIGN
                (L design, R100, hand length 957.080, 1% grade)
                with self-auditing prints. Probes: vip reader
                verdicts, insert-position semantics.
  ch22_files\
                setout_report from Chapter 22 - the first
                deliverable: SETOUT_REPORT.txt written into the
                project folder (header/table/footer), re-read and
                echoed (the audit pair for files). Probes: open
                verdicts, missing-file open, File_exists polarity,
                EOF verdict.
  ch23_files_in\
                csv_loader from Chapter 23 - data from outside.
                Self-provisions PEGS_IN.csv (one broken row by
                design), imports it via next_field (helpers v1.3)
                with verdict-guarded conversion, names and skips
                bad lines, stands points up in "macro import".
                Probes: Get_subtext indexing, Parse refusal.
                helpers.h v1.3 adds next_field - promote it over
                your shared copy.
  ch24_report\
                conf_report from Chapter 24 - the arc complete:
                harvests the CONF_* stamps from macro setout,
                judges against the TOLERANCE define, and writes
                CONF_REPORT.txt (criterion in header, verdict
                table, unchecked listed, four-population summary,
                provenance block), echoed from disk.
  ch25_levelbook\
                level_book from Chapter 25 - design against ground
                at interval. Interval via Prompt, design by pick,
                surface by name; LEVEL_BOOK.txt with sign
                convention, stations, answered/unanswered count,
                provenance; echoed from disk. Known-by-construction
                audit: shared edges must difference to zero.
  ch26_panels\
                panel_census from Chapter 26 - the census given a
                face: model box, Census/Finish buttons, message
                line, the wait loop with Get_id if-chain, Validate
                verdict printed raw. The template every Part VI
                panel tool grows from.
  ch27_undo\
                peg_placer from Chapter 27 - the panel that writes:
                E/N/H boxes, Place judging all values before the
                six-move pipeline into "macro placed", Add_undo_add
                per peg, Add_undo_list bundling the run on Finish.
                Checkpoint: 12d's own Undo measures the bundle.
  ch28_production\
                centroid_panel from Chapter 28 - the production
                architecture re-derived standalone: source box,
                create-mode model box, clean tick, housekeeping
                filter, targeted errors, highlight log lines,
                bulk Set_model, one undo registration, full
                release discipline. Measured constants raw
                (MODEL_EXISTS = 10; TRUE dialect = 1).
  ch29_widgets\
                widget_lab from Chapter 29 - the widget catalogue
                probe: two tabs (screen text, integer box, text
                edit box / choice box, tick box), every widget
                read back with raw verdicts.
  usermenu.4d   the book's toolbox as a categorised 12d user
                menu (see Chapters 2 and 30). Install into your
                12d user directory; entries come alive as their
                chapters compile the tools.
  ch31_capstone\
                (folder also ships dimension_styles.xml - one
                merge-ready style, DIM 250 OUT DIR: copy into the
                project folder, or merge its block into your
                office file)
                conf_capstone from Chapter 31 - the capstone suite:
                design/as-built pairs stationed at interval, 3D tie
                lines, ID + movement labels ("DIM <mm> <side> <brg>",
                bearing = direction of movement design-to-as-built),
                tolerance judged, twin position/level reports, one
                undo bundle.
  (Folders for later chapters are added as the book progresses.)

BEFORE YOU USE THE CHAPTER 2 FILES
  The build task in .vscode\tasks.json contains the path to the 12dPL
  compiler, cc4d.exe, for a standard 12d Model 15 installation:

      C:\Program Files\12d\12dmodel\15.00\nt.x64\cc4d.exe

  If your 12d Model is installed elsewhere or is a different version,
  edit that line to match your machine. Section 2.3 of the book shows
  how to find your compiler. Remember that every backslash in the JSON
  file is written doubled.

WHAT IS DELIBERATELY NOT HERE
  Nothing belonging to 12d Solutions or to any training provider is
  included: no compiler, no 12d header files, no third-party setup
  files. Everything those supply, you already have through your own
  12d Model installation.

TERMS
  Copyright (c) 2026 Asher Rohi Publishing. You may use, adapt, and
  build on these files freely in your own work and your organisation's
  projects. They are supplied as-is, without warranty of any kind;
  test everything against your own data before relying on it.

  This companion accompanies the book "How to Write 12d Macros",
  published by Asher Rohi Publishing — asherrohipublishing.com
