HPlogo Understanding Your System: HP 3000 Series 9X8LX Computer Systems > Chapter 6 Behind the Scenes

A Practical Problem

» 

Technical documentation

Complete book in PDF
» Feedback

 » Table of Contents

 » Index

If you were writing a program designed to put out a fire, you might write something like this:

program stopfire(telephone, first aid, water){what is needed}

begin                               {start the program}

  call firemen                       {a simple command}

  get people out of the house       {a simple command}

  if someone is hurt then           {a single question}

    begin                              {start special action}

       call a doctor                       {a simple command}

       administer first aid               {a simple command}

    end                                 {stop special action}

    look at the house                {a simple command}

    while the house is burning        {a continuing question}

       begin                            {start special action}

          pour on more water                    {a simple command}

          look at the house                {a simple command}

      end                               {stop special action}

  end                              {stop the program}

The idea behind creating programs is no more complicated than this. True, most computer programs are more complicated. But the idea is the same.

You might re-write the program to specify even more details about what to do.

Here, begin and end are commands--not to perform a particular action, but to show where particular actions (or groups of actions) start and stop.

Make note of while. It introduces a question that will be asked not once, but many times. The begin and end that follow it surround particular actions that will be performed over and over, until the house is no longer burning.

The ability of programs to control repetitive actions such as these give computers much of their power to solve problems. Programs divide big problems into small problems and speedily work at solving the small problems until all of the little solutions add up to a big solution.

Feedback to webmaster