(* Collection of code snippets by Arne Vajhøj *)
(* (from articles on eksperten.dk / vajhoej.dk written sometime between 2004 and now) *)
program load(input,output);

%include 'util.pas'

%include 'customer.pas'
%include 'order.pas'

var
   c : customer;
   o : order;

begin
   open(customer_file, 'customer.isq', new, organization := indexed, access_method := keyed);
   rewrite(customer_file);
   c.id := 1;
   c.name := 'A company';
   c.phone := '1111-1111';
   c.status := POTENTIAL;
   c.source := 'Sleazy information seller';
   customer_file^ := c;
   put(customer_file);
   c.id := 2;
   c.name := 'B company';
   c.phone := '2222-2222';
   c.status := POTENTIAL;
   c.source := 'Sleazy information seller';
   customer_file^ := c;
   put(customer_file);
   c.id := 3;
   c.name := 'C company';
   c.phone := '3333-3333';
   c.status := ACTUAL;
   c.address1 := 'C road 3';
   c.address2 := 'C town';
   c.contact := 'Mr. C';
   c.discount := 10;
   customer_file^ := c;
   put(customer_file);
   c.id := 4;
   c.name := 'D company';
   c.phone := '4444-4444';
   c.status := ACTUAL;
   c.address1 := 'D road 4';
   c.address2 := 'D town';
   c.contact := 'Mr. D';
   c.discount := 20;
   customer_file^ := c;
   put(customer_file);
   c.id := 5;
   c.name := 'E company';
   c.phone := '5555-5555';
   c.status := ACTUAL;
   c.address1 := 'E road 5';
   c.address2 := 'E town';
   c.contact := 'Mr. E';
   c.discount := 10;
   customer_file^ := c;
   put(customer_file);
   close(customer_file);
   open(order_file, 'order.isq', new, organization := indexed, access_method := keyed);
   rewrite(order_file);
   o.id := 1;
   o.customer := 3;
   o.status := 'Delivered';
   o.nlines := 1;
   o.line[1].item := 'X stuff';
   o.line[1].quantity := 1;
   o.line[1].price := todecimal(7500);
   order_file^ := o;
   put(order_file);
   o.id := 2;
   o.customer := 4;
   o.status := 'Delivered';
   o.nlines := 1;
   o.line[1].item := 'Y stuff';
   o.line[1].quantity := 10;
   o.line[1].price := todecimal(4000);
   order_file^ := o;
   put(order_file);
   o.id := 3;
   o.customer := 4;
   o.status := 'Delivered';
   o.nlines := 1;
   o.line[1].item := 'Y stuff';
   o.line[1].quantity := 5;
   o.line[1].price := todecimal(4000);
   order_file^ := o;
   put(order_file);
   o.id := 4;
   o.customer := 4;
   o.status := 'Delivered';
   o.nlines := 1;
   o.line[1].item := 'Y stuff';
   o.line[1].quantity := 20;
   o.line[1].price := todecimal(4000);
   order_file^ := o;
   put(order_file);
   o.id := 5;
   o.customer := 5;
   o.status := 'Delivered';
   o.nlines := 3;
   o.line[1].item := 'X stuff';
   o.line[1].quantity := 1;
   o.line[1].price := todecimal(7200);
   o.line[2].item := 'Y stuff';
   o.line[2].quantity := 1;
   o.line[2].price := todecimal(4500);
   o.line[3].item := 'Z stuff';
   o.line[3].quantity := 1;
   o.line[3].price := todecimal(9000);
   order_file^ := o;
   put(order_file);
   close(order_file);
end.
