Research1456.java, a 1456 applet landscape.

William Overington

Copyright 2000 William Overington

This document is intended for people who have a knowledge of Java and would like to learn more about how a 1456 applet landscape is programmed in Java. This section may be safely missed out by people who are reading these documents just to program in 1456 object code itself without learning about the underlying Java software that allows it to run.

Here is the source code of the Research1456.java program.

import java.awt.*;
import java.awt.event.*;
 
public class Research1456 extends java.applet.Applet implements
             ActionListener,AdjustmentListener,MouseListener

// Software written by William Overington
// WOverington@ngo.globalnet.co.uk
// 23 September 2000
// Copyright 2000 William Overington
//
// This software is a 1456 Applet Landscape for use with
// 1456 object code.
// The 1456 object code system is explained at
// http://www.users.globalnet.co.uk/~ngo

  {
    Engine1456 firefly = new Engine1456();
    String software,software01,software02,software03,software04,
           software05,software06,software07,software08,software09;
    int length,length01,length02,length03,length04,length05,length06,
               length07,length08,length09;
    int obeycode;
    char resultchar;
    String string00,string01,string02,string03,string04,
                    string05,string06,string07,string08,string09;
    Button go1Button = new Button("go1");
    Button go2Button = new Button("go2");
    Button go3Button = new Button("go3");
    Button go4Button = new Button("go4");
    String go1ButtonLabel,go2ButtonLabel,
           go3ButtonLabel,go4ButtonLabel;
    TextField text1TextField = new TextField(12);
    TextField text2TextField = new TextField(12);
    TextField text3TextField = new TextField(12);
    TextField text4TextField = new TextField(12);
    Scrollbar sb1 = new Scrollbar(Scrollbar.VERTICAL,
                                 0, // initial value is 0
                                 5, // width of slider
                                 -100, 105); // range -100 to 100
    int value81 = 0;
    Scrollbar sb2 = new Scrollbar(Scrollbar.VERTICAL,
                                 0, // initial value is 0
                                 5, // width of slider
                                 -100, 105); // range -100 to 100
    int value82 = 0;
    Scrollbar sb3 = new Scrollbar(Scrollbar.VERTICAL,
                                 0, // initial value is 0
                                 5, // width of slider
                                 -100, 105); // range -100 to 100
    int value83 = 0;
    Scrollbar sb4 = new Scrollbar(Scrollbar.VERTICAL,
                                 0, // initial value is 0
                                 5, // width of slider
                                 -100, 105); // range -100 to 100
    int value84 = 0;
    int value8x = 0;
    String text1,text2,text3,text4;
    double text1asadouble = 0.0;
    double text2asadouble = 0.0;
    double text3asadouble = 0.0;
    double text4asadouble = 0.0;
    boolean needsclearing = false;
    int pressx,pressy;
    boolean shiftdown,controldown,altdown;

    public void init()
      {
        setLayout(null);
        setBounds(0,0,500,300);
        go1Button.addActionListener(this);
        go1Button.setLocation(30,200);
        go1Button.setSize(110,30);
        add(go1Button);
        go2Button.addActionListener(this);
        go2Button.setLocation(30,250);
        go2Button.setSize(110,30);
        add(go2Button);
        go3Button.addActionListener(this);
        go3Button.setLocation(30,300);
        go3Button.setSize(110,30);
        add(go3Button);
        go4Button.addActionListener(this);
        go4Button.setLocation(30,350);
        go4Button.setSize(110,30);
        add(go4Button);
        text1TextField.setLocation(30,20);
        text1TextField.setSize(110,20);
        add(text1TextField);
        text2TextField.setLocation(30,60);
        text2TextField.setSize(110,20);
        add(text2TextField);
        text3TextField.setLocation(30,100);
        text3TextField.setSize(110,20);
        add(text3TextField);
        text4TextField.setLocation(30,140);
        text4TextField.setSize(110,20);
        add(text4TextField);
        sb1.addAdjustmentListener(this);
        sb1.setLocation(560,50);
        sb1.setSize(20,300);
        add(sb1);
        firefly.integer1456Set(1,value81);
        sb2.addAdjustmentListener(this);
        sb2.setLocation(590,50);
        sb2.setSize(20,300);
        add(sb2);
        firefly.integer1456Set(2,value82);
        sb3.addAdjustmentListener(this);
        sb3.setLocation(620,50);
        sb3.setSize(20,300);
        add(sb3);
        firefly.integer1456Set(3,value83);
        sb4.addAdjustmentListener(this);
        sb4.setLocation(650,50);
        sb4.setSize(20,300);
        add(sb4);
        firefly.integer1456Set(4,value84);
        addMouseListener(this);

        go1ButtonLabel = getParameter("BUTTON01");
        if (go1ButtonLabel != null)
          {
            firefly.loadStringFromString(0,go1ButtonLabel);
            go1ButtonLabel=firefly.string1456Get(0);
            go1Button.setLabel(go1ButtonLabel);
          }


        go2ButtonLabel = getParameter("BUTTON02");
        if (go2ButtonLabel != null)
          {
            firefly.loadStringFromString(0,go2ButtonLabel);
            go2ButtonLabel=firefly.string1456Get(0);
            go2Button.setLabel(go2ButtonLabel);
          }


        go3ButtonLabel = getParameter("BUTTON03");
        if (go3ButtonLabel != null)
          {
            firefly.loadStringFromString(0,go3ButtonLabel);
            go3ButtonLabel=firefly.string1456Get(0);
            go3Button.setLabel(go3ButtonLabel);
          }

        go4ButtonLabel = getParameter("BUTTON04");
        if (go4ButtonLabel != null)
          {
            firefly.loadStringFromString(0,go4ButtonLabel);
            go4ButtonLabel=firefly.string1456Get(0);
            go4Button.setLabel(go4ButtonLabel);
          }

        software="";
        software01 = getParameter("SOFTWARE01");
        if (software01 != null)
          {
            length01=software01.length();
            if (length01 > 0)
              {
                software=software+software01;
                firefly.loadSoftwareFromAppletParameters(software);
              }
          }

        software="";
        software02 = getParameter("SOFTWARE02");
        if (software02 != null)
          {
            length02=software02.length();
            if (length02 > 0)
              {
                software=software+software02;
                firefly.loadSoftwareFromAppletParameters(software);
              }
          }

        software="";
        software03 = getParameter("SOFTWARE03");
        if (software03 != null)
          {
            length03=software03.length();
            if (length03 > 0)
              {
                software=software+software03;
                firefly.loadSoftwareFromAppletParameters(software);
              }
          }
        
        software="";
        software04 = getParameter("SOFTWARE04");
        if (software04 != null)
          {
            length04=software04.length();
            if (length04 > 0)
              {
                software=software+software04;
                firefly.loadSoftwareFromAppletParameters(software);
              }
          }

        software="";
        software05 = getParameter("SOFTWARE05");
        if (software05 != null)
          {
            length05=software05.length();
            if (length05 > 0)
              {
                software=software+software05;
                firefly.loadSoftwareFromAppletParameters(software);
              }
          }

        software="";
        software06 = getParameter("SOFTWARE06");
        if (software06 != null)
          {
            length06=software06.length();
            if (length06 > 0)
              {
                software=software+software06;
                firefly.loadSoftwareFromAppletParameters(software);
              }
          }

        software="";
        software07 = getParameter("SOFTWARE07");
        if (software07 != null)
          {
            length07=software07.length();
            if (length07 > 0)
              {
                software=software+software07;
                firefly.loadSoftwareFromAppletParameters(software);
              }
          }

        software="";
        software08 = getParameter("SOFTWARE08");
        if (software08 != null)
          {
            length08=software08.length();
            if (length08 > 0)
              {
                software=software+software08;
                firefly.loadSoftwareFromAppletParameters(software);
              }
          }

        software="";
        software09 = getParameter("SOFTWARE09");
        if (software09 != null)
          {
            length09=software09.length();
            if (length09 > 0)
              {
                software=software+software09;
                firefly.loadSoftwareFromAppletParameters(software);
              }
          }
      
        string01 = getParameter("STRING01");
        if (string01 != null)
          {
            firefly.loadStringFromString(1,string01);
          }

        string02 = getParameter("STRING02");
        if (string02 != null)
          {
            firefly.loadStringFromString(2,string02);
          }

        string03 = getParameter("STRING03");
        if (string03 != null)
          {
            firefly.loadStringFromString(3,string03);
          }

        string04 = getParameter("STRING04");
        if (string04 != null)
          {
            firefly.loadStringFromString(4,string04);
          }

        string05 = getParameter("STRING05");
        if (string05 != null)
          {
            firefly.loadStringFromString(5,string05);
          }

        string06 = getParameter("STRING06");
        if (string06 != null)
          {
            firefly.loadStringFromString(6,string06);
          }

        string07 = getParameter("STRING07");
        if (string07 != null)
          {
            firefly.loadStringFromString(7,string07);
          }

        string08 = getParameter("STRING08");
        if (string08 != null)
          {
            firefly.loadStringFromString(8,string08);
          }

        string09 = getParameter("STRING09");
        if (string09 != null)
          {
            firefly.loadStringFromString(9,string09);
          }

        setBackground(Color.yellow);
        Font typeface = new Font("Arial", Font.PLAIN, 12);
        setFont(typeface);
        firefly.landscapeAuthorIs("William Overington" +
                                  "    " +
                                  "WOverington@ngo.globalnet.co.uk");

        text1TextField.setText("0.0");
        text2TextField.setText("0.0");
        text3TextField.setText("0.0");
        text4TextField.setText("0.0");

        obeycode=1;
      }

    public void actionPerformed(ActionEvent event)
      {
        Object source = event.getSource();

        if (source == go1Button)
          {
            obeycode=51;  // the label in the 1456 code where
                          // obeying should start
                          // if the "go1" button is clicked
            repaint();
          }

        if (source == go2Button)
          {
            obeycode=52;  // the label in the 1456 code where
                          // obeying should start
                          // if the "go2" button is clicked
            repaint();
          }

        if (source == go3Button)
          {
            obeycode=53;  // the label in the 1456 code where
                          // obeying should start
                          // if the "go3" button is clicked
            repaint();
          }

        if (source == go4Button)
          {
            obeycode=54;  // the label in the 1456 code where
                          // obeying should start
                          // if the "go4" button is clicked
            repaint();
          }
      }

    public void adjustmentValueChanged(AdjustmentEvent adjustevent)
      {
        Object source = adjustevent.getSource();

        if (source == sb1)
          {
            obeycode=81;
            value81=adjustevent.getValue();
            value8x=value81;
            firefly.integer1456Set(1,value81);
            repaint();
          }

        if (source == sb2)
          {
            obeycode=82;
            value82=adjustevent.getValue();
            value8x=value82;
            firefly.integer1456Set(2,value82);
            repaint();
          }

        if (source == sb3)
          {
            obeycode=83;
            value83=adjustevent.getValue();
            value8x=value83;
            firefly.integer1456Set(3,value83);
            repaint();
          }

        if (source == sb4)
          {
            obeycode=84;
            value84=adjustevent.getValue();
            value8x=value84;
            firefly.integer1456Set(4,value84);
            repaint();
          }

      }

    public void mousePressed(MouseEvent e)
      {
        obeycode=41;
        pressx=e.getX();
        pressy=e.getY();
        shiftdown=e.isShiftDown();
        controldown=e.isControlDown();
        altdown=e.isAltDown();
        firefly.integer1456Set(5,pressx);
        firefly.integer1456Set(6,pressy);
        if (shiftdown)
          {
            firefly.integer1456Set(7,1);
          }
        else
          {
            firefly.integer1456Set(7,0);
          }
        if (controldown)
          {
            firefly.integer1456Set(8,1);
          }
        else
          {
            firefly.integer1456Set(8,0);
          }
        if (altdown)
          {
            firefly.integer1456Set(9,1);
          }
        else
          {
            firefly.integer1456Set(9,0);
          }
        repaint();
      }

    public void mouseReleased(MouseEvent e)
      {

      }

    public void mouseClicked(MouseEvent e)
      {

      }

    public void mouseEntered(MouseEvent e)
      {
       
      }

    public void mouseExited(MouseEvent e)
      {
       
      }

     public void paint(Graphics screen)
      {                                                             
        text1=text1TextField.getText();

        if (text1 == "")
          {
            text1=" ";
          }

        text2=text2TextField.getText();

        if (text2 == "")
          {
            text2=" ";
          }

        text3=text3TextField.getText();

        if (text3 == "")
          {
            text3=" ";
          }

        text4=text4TextField.getText();

        if (text4 == "")
          {
            text4=" ";
          }

        if (obeycode > 1)
          {

            try
              { 
                double localdouble1 =
                  Double.valueOf(text1).doubleValue();
                text1asadouble=localdouble1;  
              } 
            catch(NumberFormatException nfe) 
              {
                text1asadouble=0.0; 
              }
            try
              { 
                double localdouble2 =
                  Double.valueOf(text2).doubleValue();
                text2asadouble = localdouble2;  
              } 
            catch(NumberFormatException nfe) 
              {
                text2asadouble=0.0; 
              }
            try
              { 
                double localdouble3 =
                  Double.valueOf(text3).doubleValue();
                text3asadouble=localdouble3;                  
              } 
            catch(NumberFormatException nfe) 
              {
                text3asadouble=0.0; 
              }
            try
              { 
                double localdouble4 =
                  Double.valueOf(text4).doubleValue();
                text4asadouble = localdouble4;  
              } 
            catch(NumberFormatException nfe) 
              {
                text4asadouble=0.0; 
              }
          }

          firefly.double1456Set(1,text1asadouble);
          firefly.double1456Set(2,text2asadouble);
          firefly.double1456Set(3,text3asadouble);
          firefly.double1456Set(4,text4asadouble);
          
          firefly.loadStringFromString(1,text1);
          firefly.loadStringFromString(2,text2);
          firefly.loadStringFromString(3,text3);
          firefly.loadStringFromString(4,text4);

          resultchar =
            firefly.obeySoftwareAtLabel(screen,obeycode);

          if (resultchar == '?')
            {
              do
                {
                  int functionchoice=
                    firefly.softwareinterruptparameterGet();

                  if (functionchoice == 1)
                    {
                      firefly.string1456Set
                        (19,"The 1456 engine in action.");
                    }

                  resultchar =
                  firefly.obeySoftwareAfterSoftwareInterrupt(screen);
                } while (resultchar == '?');
            }

          double double1=firefly.double1456Get(1);
          text1TextField.setText("" + double1); 
          double double2=firefly.double1456Get(2);
          text2TextField.setText("" + double2);
          double double3=firefly.double1456Get(3);
          text3TextField.setText("" + double3); 
          double double4=firefly.double1456Get(4);
          text4TextField.setText("" + double4);       
      }

    public void update(Graphics screen)
      {
        paint(screen);
      }

  }

An interesting feature to note is that I have allowed the user to give labels to the buttons using the 'u format. In doing this, I was about to copy my routine for converting a 'u format sequence into a unicode character from the 1456 engine source code into this program. However, I realized that I could use the 1456 engine to carry out the converting of any 'u sequences. It is not necessary to run any 1456 object code to carry out this conversion. All that is needed is to load the string into the 1456 engine using the loadStringFromString method and then obtain the result from the 1456 engine using the string1456Get method. Any 'u sequences that were present in the string loaded into the 1456 engine using the loadStringFromString method would have been resolved during that loading into the 1456 engine. This would be of advantage as a technique for other people writing a 1456 applet landscape to use if they so choose. Here is the sequence used for the first button.

        go1ButtonLabel = getParameter("BUTTON01");
        if (go1ButtonLabel != null)
          {
            firefly.loadStringFromString(0,go1ButtonLabel);
            go1ButtonLabel=firefly.string1456Get(0);
            go1Button.setLabel(go1ButtonLabel);
          }

The other button labels are handled in a similar manner, with detail differences.

The HTML file is shown in the next section.

1456 object code

Copyright 2000 William Overington