Experimenting with Smart Console Applications

Introduction

You can add an image to the console if you add W3Graphics to the uses clause and add the required image to Resources as follows.

  1. Right click on the Resources folder in the tree view of the project at the top left of the Smart IDE.
  2. Click on Add Resource File(s).
  3. Browse to find your file (e.g. banner.png) and open it.

We added the "CodeShow" banner.png and also customised the console and the header. The code follows a screenshot of the program in action.

Entered Data

Entered Data

unit uConsolePlay;

interface

uses
  // W3System, W3Scroll, W3Console, W3Components, W3Application, W3ConsoleApp, W3Lists,  W3Graphics;
  System.Types, System.Lists, SmartCL.System, SmartCL.Scroll, SmartCL.Console,
  SmartCL.Components, SmartCL.Application, SmartCL.ConsoleApp, SmartCL.Graphics,
  System.Colors;
type
  TApplication = class(TW3CustomConsoleApplication)
  protected
    procedure ApplicationStarting; override;
    procedure PopulateConsole; override;
    procedure ProcessCommand(aCommand: string); override;
  end;

implementation

procedure TApplication.ApplicationStarting;
begin
  inherited;
end;

procedure TApplication.PopulateConsole;
begin
  Header.Width := 200;
  Header.Title.Caption := 'Play';
  Header.NextButton.Caption := 'Press';
  Console.InnerHTML:='<img src="res/banner.png"><font color="green"><h1>Hi</h1></font>';
  Console.SetSize(200, 100);
  Console.Color := clYellow;
end;

procedure TApplication.ProcessCommand(aCommand: string);
begin
  Console.InnerHTML:='<img src="res/banner.png"><font color="green"><h1>' +
                      aCommand +  '</h1></font>';
  inherited ProcessCommand(aCommand);
end;

end.
Programming - a skill for life!

How to write programs in Smart Pascal