ERR.lsp — Dialog Input Validation & Error Display

Module: err.lsp
Version: v3.60
Category: Core Application
Complexity: Low
Size: 1.0 KB (15 lines)

Note

Dual-Purpose Module

Despite its name, err.lsp serves two functions:

  1. Input Validation - Real-time validation of dialog input fields with auto-correction

  2. Error Display - Formatted error message presentation to users

This module is called by dialog validation routines and is NOT the main error handler (that’s a separate error trap system).


Overview

Purpose

The err function validates user input in dialog fields and displays formatted error/validation messages. It automatically corrects dimension values, highlights invalid fields, and presents user-friendly error messages.

Role in CSV 3.60 Architecture

Position in Call Chain:

User enters data in dialog field
  ?
Field validation routine
  ?
(err)  ? THIS MODULE
  ?
Field highlighted (red border)
Value auto-corrected (if applicable)
Error message displayed (if needed)

Used By:

  • rangchck.lsp - Range validation

  • chrchk.lsp - Character validation

  • All *_dlg.lsp files - Dialog input validation


Function Documentation

(err)

Signature:

(defun err ()
  ; Uses global variables: ke, k, v, v2, ks, msg, msg1, msg2
  ; Returns: nil (princ)
)

Purpose: Validates input field, auto-corrects dimensions, highlights errors, and displays messages.

Algorithm:

  1. Field Highlighting:

    • Set field ke to mode 3 (red border/error state)

    • Display corrected value v2 in field

  2. Dimension Auto-Correction:

    • Mix Profile special case: If field starts with “mpm”, multiply by 4

    • Standard case: If secondary field ks exists, multiply by 8

    • Updates secondary dimension field automatically

  3. Error Message Display:

    • If not a secondary field (doesn’t end with “s”):

      • Center the value v in a 42-character width

      • Format message: [[ value ]] centered

      • Display alert with formatted message


Source Code

File Location: src/x86/v3_60/v3.60/err.lsp

Full Source (15 lines):

(defun err  ()
  (mode_tile ke 3)
  (set_tile ke v2)
  (if (= (substr k 1 3) "mpm")
    (set_tile ks (rtos (* 4 (distof (substr v2 1 (1- (strlen v2))))) 5 2))
    (if (and ks (get_tile ks))
      (set_tile ks (rtos (* 8 (distof v2)) 5 2))))
  (if (/= (substr k (strlen k)) "s")
    (progn (set 'fil " ")
           (set 'len (/ (- 42 (strlen v)) 2))
           (while (> len 0) (set 'len (1- len)) (set 'fil (strcat fil " ")))
           (set 'msg (strcat msg "\n\n" fil "[ " v " ]" fil "\n\n" msg1 msg2))
           (alert msg)))
  (princ))

Global Variables Used

Input (Read-Only)

  • k - Current field key/name being validated

  • ke - Error field key (field to highlight)

  • v - Original invalid value entered by user

  • v2 - Corrected value to display

  • ks - Secondary/related field key (for dimension pairs)

  • msg - Primary error message text

  • msg1 - Secondary message line 1

  • msg2 - Secondary message line 2

Modified

  • fil - Temporary: padding/fill string for centering

  • len - Temporary: calculated padding length


Dimension Scaling Rules

Mix Profile (mpm prefix)

Rule: Multiply by 4

Purpose: Likely converts between measurement units or scales

  • Input: 6 ? Output: 24

  • Possibly: inches to quarter-inches?

  • Or: single unit to distributed spacing?

Standard Fields

Rule: Multiply by 8

Purpose: Likely imperial fraction conversion

  • Input: 0.5 ? Output: 4.00

  • Possibly: inches to 1/8” increments?

  • Or: engineering units to fabrication units?



Document Metadata

Status: Comprehensive analysis from source code
Last Updated: 2026-01-20
Analysis Method: Source code review + validation pattern analysis
Completeness: 90% (scaling factor purpose inferred)


End of Document