đź’»

Introduction to Basic Coding Concepts

Apr 29, 2025

Part Four: Learning How to Code

Adding a Button

  • Navigate to the standard palette.
  • Add a TButton component.
  • Change name:
    • Default: Button1
    • New: btnChangeHair
  • Modify the caption:
    • Display: Change Hair

Methods and Events

  • Focus: Button actions.
  • Access events via the object inspector.
    • Example: OnClick event.
  • Double-click to access code area.

Writing Code for Events

  • Code executes between begin and end keywords.
  • Event-driven programming:
    • Events: Trigger code execution.
    • Order of clicking affects execution sequence.

Coding Syntax

  • Structure of statements:
    • Syntax: [object].[property] := [new_value];
    • Example:
      • shpTongue.Visible := False;
      • shpHair.Brush.Color := clWhite;
  • Importance of matching types (e.g., True/False for Visible).

Example: Positioning and Movement

  • Properties: Top and Left.
    • move right to get the “left” property to be bigger and then move right to get the “left” property smaller
    • move down to get the “top“ property bigger than move up to get the” top” property smaller
  • Button example:
    • Button name: btnMoveLeftEye
    • Code: Move shapes by changing Left property.

Design vs. Runtime

  • Design Time:

    • Is when you change properties in the object inspector
  • Runtime:

    Is When you change properties using code