Skip to content

Instantly share code, notes, and snippets.

@edgars
Created July 24, 2025 20:53
Show Gist options
  • Save edgars/799bcb18351124fb1953edc6e8a6e592 to your computer and use it in GitHub Desktop.
Save edgars/799bcb18351124fb1953edc6e8a6e592 to your computer and use it in GitHub Desktop.
mdl_sample.mdl
APPLICATION CustomerRegistrationApp
ENTITY Customer
FIELD CustomerID TYPE NUMERIC(10) KEY
FIELD Name TYPE ALPHANUMERIC(50) REQUIRED
FIELD BirthDate TYPE DATE REQUIRED
FIELD Email TYPE ALPHANUMERIC(100)
FIELD Age TYPE NUMERIC(3)
FIELD Status TYPE ALPHANUMERIC(1) DEFAULT "A"
END_ENTITY
SCREEN CustomerForm
TITLE "Customer Registration"
FIELD CustomerID LABEL "ID" POSITION (1,1) INPUT DISABLED
FIELD Name LABEL "Name" POSITION (2,1) INPUT REQUIRED
FIELD BirthDate LABEL "Date of Birth" POSITION (3,1) INPUT REQUIRED
FIELD Email LABEL "Email" POSITION (4,1) INPUT
FIELD Age LABEL "Age" POSITION (5,1) CALCULATED
FIELD Status LABEL "Status (A/I)" POSITION (6,1) INPUT DEFAULT "A"
BUTTON Save ACTION SaveCustomer
BUTTON Exit ACTION ExitApp
END_SCREEN
RULES
RULE "Calculate Age"
WHEN BirthDate IS NOT NULL
THEN Age = CURRENT_YEAR - YEAR(BirthDate)
RULE "Validate Email"
WHEN Email IS NOT NULL
THEN Email MUST CONTAIN "@"
RULE "Required Name"
WHEN Name IS NULL
THEN RAISE ERROR "Name is required"
RULE "Status Must Be A or I"
WHEN Status NOT IN ["A", "I"]
THEN RAISE ERROR "Status must be A or I"
END_RULES
ACTION SaveCustomer
IF ERRORS_EXIST
SHOW_MESSAGE "Please correct the errors"
ELSE
SAVE RECORD Customer
SHOW_MESSAGE "Customer saved successfully"
END_ACTION
ACTION ExitApp
EXIT
END_ACTION
END_APPLICATION
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment