Perfect Developer basic tutorial 4 This page last modified 2011-10-30 (JAC)

Creating main

You can create a main program within Perfect Developer like this:

From the Project menu select Create file. Select the Perfect main entry point option and then click OK. The filename Main.pd will be filled in for you.

Next, in the editor, change the import directive to read:

import "Book.pd";

Change the postcondition of the schema main to read:

post ( let thisBook ^= Book
                        {  "Perfect Developer Tutorial",
                           set of string{"David Crocker", "Judith Carlton"}
                        };
        context!print(thisBook.toString ++ "\n")
     ),
     ret! = 0;

Build and verify the project (which now has two files).

How you create an executable program now depends on whether you are using C++ or Java and on what development environment you are using.

If you are using Java, we suggest you read our Knowledge Base article Creating a Java application using Perfect Developer and JDK. The critical factors are:

If you are using C++ under Windows and your compiler is Microsoft Visual C++ 6.0,  see Creating a Perfect console application using Visual C++.

If you are using C++ with the GNU compiler gcc, do the following:

When you have successfully built your C++ or Java project, running it from a command prompt should produce the output:

'Perfect Developer Tutorial' by David Crocker and Judith Carlton

Now you can experiment by making changes to the Main.pd file. What happens if you break a precondition (e.g. by creating a book with no authors)? How does the result depend on the Runtime checks setting on the Code generation tab?

Next:  Schemas

 

Save My Place Glossary Language Reference Manual
Tutorials Overview Main site   
Copyright © 1997-2012 Escher Technologies Limited. All rights reserved. Information is subject to change without notice.