Contents | Prev | Next | Index


A first Example

Canterbury Pascal for Java can be easily called from a simple command prompt. For example, in order to compile and execute the Slides.pas sample on a Windows-95 system, just open a DOS-prompt and enter the following commands (shown here in red color):

C:\COM.webcom.mhc\mhc\pas\samples\slides>java mhc.pas Slides -m
Pascal 2.5.1 (c) 1998 Mill Hill & Canterbury Corporation, Ltd.
Unlicenced time-limited evaluation version
Compiling interface: C:\COM.webcom.mhc\mhc\runtime\pas\SYSTEM.pas
Importing Java class: java.lang.RuntimeException
Importing Java class: java.io.InputStreamReader
Importing Java class: java.io.OutputStreamWriter
Compiling implementation: C:\COM.webcom.mhc\mhc\runtime\pas\SYSTEM.pas
Importing Java class: java.applet.Applet
Importing Java class: java.lang.Runnable
Importing Java class: java.lang.Thread
Importing Java class: java.awt.Image
Importing Java class: java.awt.Graphics
Importing Java class: java.awt.Event
Compiling interface: Slides.pas
Importing Java class: java.lang.String
Compiling implementation: Slides.pas
Compilation done: Slides.pas
C:\COM.webcom.mhc\mhc\pas\samples\slides>javac Slides.java -nowarn

C:\COM.webcom.mhc\mhc\pas\samples\slides>appletviewer Slides.html
C:\COM.webcom.mhc\mhc\pas\samples\slides>

As can be seen, the command

java mhc.pas Slides -m

causes the file Slides.pas to be compiled into various *.java files:

Slides.java

Slides_ClickAnimation_init_Frame.java

Slides_ClickAnimation.java 

The -m switch tells the compiler also to recompile other imported Pascal unit files if they are updated. This is like a Make-utility for Pascal files integrated into the Pascal compiler.

The command

javac Slides.java -nowarn

gets the *.java files translated into the final byte code:

Slides.class

Slides_ClickAnimation_init_Frame.class

Slides_ClickAnimation.class

Unit Slides.pas has a Pascal class type called ClickAnimation extending the imported class java.applet.Applet. It also overrides some inherited methods. In order to run ClickAnimation, an applet-tag has to be declared in a HTML-document. In this case, file Slides.html has an applet-tag (highlighted in green) as follows:

Slides.html
<HTML>
<HEAD>
  <TITLE>A simple click animation applet</TITLE>
</HEAD>
<BODY>
<P>
<APPLET CODE="Slides_ClickAnimation.class"
    CODEBASE=.
    NAME="A simple click animation applet"
    WIDTH="170" HEIGHT="170">
</APPLET>
</BODY>
</HTML>

Calling this file using the JDK appletviewer utility:

appletviewer Slides.html

will launch the Slides_ClickAnimation.class.


Contents | Prev | Next | Index

Canterbury Pascal for Java  (Last documentation update Apr 19, 2000)
Copyright © 1998 Mill Hill & Canterbury Corporation, Ltd. All rights reserved
Please send any comments or corrections to mhc@webcom.com