This section shows how you can make a simple IDE. We offer suggestions for development after the code on the next page.

These screenshots show error messages from TINY test programs running in the TINY IDE on the Pi. You can see the error messages in the memo below the editor. The cursor is positioned on the row of the error. All the errors are deliberate and intended to predict the type of syntax errors that you are likely to make after programming in Pascal. Remember that TINY does without "syntactic sugar" such as do and to keywords.

"TO" error message

"TO" error message from the TINY IDE

"DO" error message

"DO" error message from the TINY IDE

Note that "do" and "to" are not highlighted as keywords, making it possible to discover some errors as you type.

While TINY14PI allows you add semicolons to separate statements if you wish to, like many languages it uses = and does not accept := for assignment:

":" error message

":" error message from the TINY IDE

For a procedure without parameters, TINY requires an empty pair of brackets. If you forget them, this is your error message:

Testing "(" error message

"(" error message from the TINY IDE

When you compile the TINY_IDE in Lazarus you are advised to select menu item Run > Run Parameters then type the full pathname of the source file into the edit box marked "Command line parameters" e.g. /home/pi/TINY/Demo/PrimesDemo.txt. Alternatively, you can edit the appropriate line in TINY_IDE.lpi.

If you are not planning to develop the IDE, after you have compiled it in Lazarus run TINY_IDE from the command line with your instruction giving the full pathname of source such as TINY/TINY_IDE /home/pi/TINY/Demo/FactDemo.txt. (The output from the TINY program will appear in its own window if the compilation is successful). Thereafter you can browse to other source files and save to other locations. The assembler file and the binary ELF file will be saved to the same directory as the source. The source named myfile.xxx results in an assembly file named myfile.s and an ELF file named myfile.

You must append to some source files a read(DeclaredVariable) statement so that the console does not disappear after the program has been executed. To exit, enter an integer.

You can download a compressed file of the TINY_IDE executable.

Adapting the code of the TINY14PI compiler

  1. In order to direct straightforwardly the compiler error messages to the IDE we must delete the ReadLn statements from procedure Error in uErrors.pas.
  2. In order to output the approximate line number of the error we
    1. declare an integer variable LineCount initialised to 1 in uGlobals.pas
    2. increment LineCount when the linefeed character #10 is scanned in the source file (procedure getChar in uInput.pas);
    3. append the line count to the error message in procedure Error in uErrors.pas;
  3. We have positioned the output of .ltorg after calling procedures (procedure Call in uCodeGenPi.pas), but some programs work when it is emitted instead just before the final lines of each procedure (at the start of procedure ProcEpilog in uCodeGenPi.pas. Sometimes it is possible to prevent runtime errors by moving writeln statements in the source code of the TINY programs from within procedures to the main code.

Code of TINY_IDE.lpr

program TINY_IDE;

{$mode objfpc}{$H+}

 {$IFDEF UseCThreads}
  Interfaces, Forms, uEdit;

  Application.CreateForm(TfrmEdit, frmEdit);

Code of TINY_IDE.lpi

You can change the value of CommandLineParams to the pathname of your start-up source file.

<?xml version="1.0"?>
    <Version Value="9"/>
      <MainUnit Value="0"/>
      <ResourceType Value="res"/>
      <UseXPManifest Value="True"/>
      <Icon Value="0"/>
      <EnableI18N LFM="False"/>
      <StringTable ProductVersion=""/>
    <BuildModes Count="1">
      <Item1 Name="Default" Default="True"/>
        <FormatVersion Value="1"/>
        <CommandLineParams Value="/home/pi/TINY/Demo/PrimesDemo.txt"/>
    <RequiredPackages Count="3">
        <PackageName Value="SynEdit"/>
        <PackageName Value="FCL"/>
        <PackageName Value="LCL"/>
    <Units Count="3">
        <Filename Value="TINY_IDE.lpr"/>
        <IsPartOfProject Value="True"/>
        <Filename Value="uEdit.pas"/>
        <IsPartOfProject Value="True"/>
        <ComponentName Value="frmEdit"/>
        <ResourceBaseClass Value="Form"/>
        <Filename Value="uEdit.lfm"/>
        <ComponentName Value="frmEdit"/>
        <HasResources Value="True"/>
        <ResourceBaseClass Value="Form"/>      
        <DefaultSyntaxHighlighter Value="LFM"/>
    <Version Value="9"/>
      <Filename Value="TINY_IDE"/>
      <UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/>
      <CompilerPath Value="$(CompPath)"/>

See the code of uEdit.pas and the text view of frmEdit.lfm by following the links below.

Programming - a skill for life!

by PPS in association with Jack Crenshaw