10

Sample Program

The following program, xview.p, makes a window:

program hello(output);

#include "stddefs_p.h" #include "attrgetset_p.h"

var

base_frame :Frame; base_panel :Panel;

message :Xv_panel_or_item_ptr;

text :string;

begin

text := 'Hello, World!';

xv_init(0);

base_frame := xv_create(nil, FRAME, 0);

base_panel := xv_create(base_frame, PANEL, 0);

message := xv_create(panel, PANEL_MESSAGE, 0); set_PANEL_LABEL_STRING(message, text);

window_main_loop(base_frame);

end. {hello}

To compile xview.p and link in the necessary libraries, use the following command-line. Replace local_library_path with the path for the Pascal XView libraries on your system.

hostname% pc -Ilocal_library_pathxview.p -L$OPENWINHOME/lib \ -lpxview -lxview -lolgx -lX11

Now run the executable file:

hostname% a.out

Soon after you run the executable file, the window opens as a single frame, with the string Hello, World! in the frame header.

230

Pascal 4.0 User’s Guide

Page 254
Image 254
HP SunSoft Pascal 4.0 manual Sample Program, 230