Примеры программирования на ORL

Версия 1.0 alpha

В настоящем документе даются примеры изпользования языка ORL для программирования структур данных и бизнес-логик
различных прикладных учетных и финансовых приложений.

Основные конструкции

Методы и запросы

Ведение бухгалтерских счетов

Учет клиентуры

Исчисление предикатов (PROLOG)


Основные конструкции


CLASS
  REMOTE_ADDRESS;
  TEXT Адреса;
  OWNER (NAME DATA);
  TYPE STRUCTURE;
  ATTRIBUTES
    NAME CITY; TEXT "Город"; KEY DUP;;
  ;

CLASS
  REMOTE_PHONE;
  TEXT Телефоны;
  OWNER (NAME DATA);
  TYPE STRUCTURE;
  ATTRIBUTES
    NAME PHONE_NUMBER; TEXT "Номер телефона";KEY UNIQUE;;
  ;

CLASS
  REMOTE_BANK;
  TEXT Банки;
  OWNER (NAME DATA);
  TYPE STRUCTURE;
  ATTRIBUTES
    NAME BANK_NAME; TEXT "Название банка";KEY UNIQUE; TYPE EMB|DEFAULT;;
  ;

CLASS
  REMOTE_GROUP;
  TEXT Группа;
  OWNER (NAME DATA);
  TYPE STRUCTURE;
  ATTRIBUTES
    NAME NAME; TEXT "Название группы";KEY UNIQUE; TYPE EMB|DEFAULT;;
  ;

CLASS
  REMOTE_CLIENT;
  TEXT Клиенты;
  OWNER (NAME DATA);
  TYPE STRUCTURE;
  USAGE ALONE;
;
CLASS
  (REMOTE_CLIENT)
  ATTRIBUTES
    NAME MIDDLENAME; TEXT; KEY DUP;,
    NAME LASTNAME;	TEXT "Фамилия";		KEY UNIQUE;,	
	NAME ADDRESS;	TEXT "Адрес";		TYPE REF;			DOMAIN (REMOTE_ADDRESS);,
	NAME PHONES;	TEXT "Телефоны";	TYPE COLL;			DOMAIN (REMOTE_PHONE);,
	NAME GROUP;		TEXT "Группа";		TYPE REF|SHARED;	DOMAIN (REMOTE_GROUP);,
	NAME BANK;		TEXT "Банки";		TYPE COLL|SHARED;	DOMAIN (REMOTE_BANK);
	;
  ;

CLASS
  REMOTE_SECURITY;
  TEXT ЦБ;
  OWNER (NAME DATA);
  TYPE STRUCTURE;
  USAGE ALONE;
  ATTRIBUTES
    NAME EMITENT; TEXT "Название ЦБ";  TYPE EMBEDDED; NULLS yes; DOMAIN (NAME STRING); key dup;,
    NAME PRICE;   TEXT "Цена ЦБ";  TYPE EMBEDDED; NULLS yes; DOMAIN (NAME NUMBER);;
  ;

CLASS
  REMOTE_DEAL;
  TEXT Сделка;
  OWNER (NAME DATA);
  TYPE STRUCTURE;
  USAGE ALONE;
  ATTRIBUTES
    NAME NUMBER;   TEXT "Номер";       TYPE EMBEDDED; NULLS yes; DOMAIN (NAME STRING);,
    NAME QUANTITY; TEXT "Количество";  TYPE EMBEDDED; NULLS yes; DOMAIN (NAME NUMBER);,
    NAME CLI; TEXT "Клиент";  TYPE REF; NULLS NO; DOMAIN (NAME REMOTE_CLIENT); SHARED YES;,
    NAME SEC; TEXT "ЦБ";      TYPE REF; NULLS NO; DOMAIN (NAME REMOTE_SECURITY);SHARED YES;;
  ;


REMOTE_BANK 
	BANK_NAME "Онэксим";,
	BANK_NAME "Мост";,
	BANK_NAME "Токо";;

REMOTE_GROUP
	NAME "Партнеры";,
	NAME "Оффшоры";,
	NAME "Клиенты";;


REMOTE_CLIENT 
	LASTNAME "Первачев";
	ADDRESS CITY Москва;;
	GROUP (NAME "Партнеры");
	BANK (BANK_NAME "Мост"),(BANK_NAME "Токо");
	PHONES REMOTE_PHONE PHONE_NUMBER "11-11-11";;
	,
	LASTNAME "Вторухин";
	ADDRESS CITY Питер;;
	GROUP (NAME "Партнеры");
	BANK (BANK_NAME "Онэксим"),(BANK_NAME "Токо");
	PHONES PHONE_NUMBER "22-11-11";,PHONE_NUMBER "22-22-22";;
	,
	LASTNAME "Третьяков";
	ADDRESS CITY Новосибирск;;
	GROUP (NAME "Оффшоры");
	BANK (BANK_NAME "Мост"),(BANK_NAME "Онэксим");
	PHONES PHONE_NUMBER "33-11-11";,PHONE_NUMBER "33-22-22";,PHONE_NUMBER "33-33-33";;
	,
	LASTNAME "Четвертушкин";
	ADDRESS CITY Мелитополь;;
	GROUP (NAME "Клиенты");
	BANK (BANK_NAME "Мост"),(BANK_NAME "Онэксим"),(NAME "Токо");
	PHONES PHONE_NUMBER "44-11-11";,PHONE_NUMBER "44-22-22";,PHONE_NUMBER "44-33-33";,PHONE_NUMBER "44-44-44";;
	,
	LASTNAME "a";
	,
	LASTNAME "b";
	;

REMOTE_SECURITY 
	EMITENT "Газпром"; PRICE 123000;,
	EMITENT "ГКО";PRICE 456000;,
	EMITENT "Онэксим";PRICE 789000;;

REMOTE_DEAL 
	NUMBER "XX12345"; QUANTITY 67; CLI (FIRSTNAME Первачев); SEC (EMITENT Онэксим);,
	NUMBER "XX67890"; QUANTITY 33; CLI (FIRSTNAME Вторухин); SEC (EMITENT Газпром);;



METHOD 
	OWNER (REMOTE_CLIENT);
	NAME INCREMENT;
	TEXT "Изменить имя";
	CODE
		LASTNAME += 1
    ;//CODE
;


METHOD 
	OWNER (REMOTE_CLIENT);
	NAME NEW_PHONE;
	TEXT "Завести новый телефон";
	ATTRIBUTES
		NAME _NO; TEXT Нум; TYPE EMB|IN; DOMAIN (STRING); ;
	CODE
//		RUN MESSAGE TEXT XXX;;,
		PHONES += NEW REMOTE_PHONE OWNER THIS; PHONE_NUMBER = _NO;;
    ;//CODE
;

METHOD 
	OWNER (REMOTE_CLIENT);
	NAME CONSTRUCT;
	TEXT "Завести новый телефон и счет в банке";
	ATTRIBUTES
		NAME _BN;	TEXT Бнк; TYPE EMB|IN; DOMAIN (STRING); ,
		NAME _NO;	TEXT Нум; TYPE EMB|IN|OUT; DOMAIN (STRING); ,
		NAME _BNO;	TEXT Банк; TYPE EMB|OUT; DOMAIN (STRING);,
		NAME _NO_;	TYPE EMB; DOMAIN (STRING); 
		;
	CODE
//		RUN MESSAGE TEXT XXX;;,
		LASTNAME += 1,
		BANK	+= NEW REMOTE_BANK	BANK_NAME = _BN;;,
		PHONES	+= NEW REMOTE_PHONE OWNER THIS; PHONE_NUMBER = _NO;;,
		_BNO = "Банк: ",
		_BNO += _BN ,
		_NO_ = "Пхон: ",
		_NO_ += _NO,
		_NO = _NO_
    ;//CODE
;

REMOTE_CLIENT(LASTNAME "Первачев") CONSTRUCT _BN "Банк 1"; _NO "Пхон 1";; INCREMENT; ;


ACCESSGRANT
	NAME "a";
	TEXT "Хороший Юзер";
	PASSWORD "a";
	RIGHTS 
		ACCESSCLASS (OBJECT);	LEVEL (FULL);,
		ACCESSCLASS (CLASS);	LEVEL (FULL);,
		ACCESSCLASS (ATTRIBUTE);	LEVEL (VIEW);,
		ACCESSCLASS (REMOTE_BANK);	LEVEL (FULL);,
		ACCESSCLASS (REMOTE_CLIENT);	LEVEL (FULL);
	;
	,
	NAME "b";
	TEXT "Плохой Юзер";
	PASSWORD "b";
	RIGHTS 
		ACCESSCLASS (OBJECT);	LEVEL (NO);,
		ACCESSCLASS (CLASS);	LEVEL (NO);,
		ACCESSCLASS (ACCESSLOGIN);	LEVEL (FULL);,
		ACCESSCLASS (ATTRIBUTE);	LEVEL (VIEW);,
		ACCESSCLASS (REMOTE_BANK);	LEVEL (FULL);,
		ACCESSCLASS (REMOTE_ADDRESS);	LEVEL (VIEW);
	;
;

 


Методы и запросы

CLASS ELEMENT_CLASS;
  OWNER (NAME "DATA");
  TEXT "Класс элементов M:1";
  ;
CLASS DOMAIN_CLASS;
  OWNER (NAME "DATA");
  TEXT "Класс значений 1:M";
  TABLE "Чегой-то";
  ;
CLASS CLASS_FOR_TEST;
  OWNER (NAME "DATA");
  TEXT "Класс, выбирающий значения";
  ;


METHOD //QUERY
    NAME BUILD_FULL_NAME;
    OWNER (NAME DOMAIN_CLASS);
    TYPE GET;
	ATTRIBUTES NAME _FULLNAME;PARAMETER OUT;;
    RETURN _FULLNAME;
    CODE//INLINE
			_FULLNAME=FIRSTNAME,
			_FULLNAME+=" ",
			_FULLNAME+=LASTNAME
		;//INLINE
    ;

//QUERY DOMAIN_CLASS (PK_NAME=FK_NAME) FULLNAME;
METHOD //QUERY
    NAME SELECT_DOMAIN_CLASS; //TEXT "Ку";
    OWNER (NAME DOMAIN_CLASS);
    RETURN FULLNAME;
    TYPE GET;
    CODE
      PK_NAME=FK_NAME
      ;
    ;

METHOD //QUERY
    NAME SELECT_ELEMENT; 
    OWNER (ELEMENT_CLASS);
    RETURN THIS;
    TYPE GET;
    CODE
      PK_NAME=FK_NAME
      ;
    ;

CLASS(ELEMENT_CLASS)
  ATTRIBUTES
    NAME FK_NAME; KEY DUP;,
    NAME VALUE; KEY UNIQUE;
	;
  ;

CLASS(NAME DOMAIN_CLASS)
  ATTRIBUTES
    NAME PK_NAME; KEY UNIQUE;,
    NAME FIRSTNAME;,
    NAME LASTNAME;,
    NAME FULLNAME; TYPE EMB|CALC; QUERY (BUILD_FULL_NAME);,
    NAME ELEMENTS; TEXT "Элементики"; TYPE COLL|CALC; DOMAIN (ELEMENT_CLASS); QUERY (SELECT_ELEMENT); CONDITION "FK_NAME=PK_NAME";
	;
  ;

CLASS(NAME CLASS_FOR_TEST)
  ATTRIBUTES
    NAME NUMBER; DOMAIN (NUMBER);,
    NAME FK_NAME;,
    NAME FK_DATA; TYPE EMB|CALC; QUERY (NAME SELECT_DOMAIN_CLASS);
    ;
  ;

ELEMENT_CLASS
	FK_NAME XXX; VALUE XXX1;,
	FK_NAME XXX; VALUE XXX2;,
	FK_NAME XXX; VALUE XXX3;,
	FK_NAME YYY; VALUE YYY1;,
	FK_NAME YYY; VALUE YYY2;,
	FK_NAME ZZZ; VALUE ZZZ1;
	;

DOMAIN_CLASS
	PK_NAME XXX; FIRSTNAME Икс; LASTNAME Иксов;,
	PK_NAME YYY; FIRSTNAME Игрек; LASTNAME Игреков;,
	PK_NAME ZZZ; FIRSTNAME Зет; LASTNAME Зетов;
	;

CLASS_FOR_TEST
	NUMBER 33; FK_NAME "XXX";,
	NUMBER 44; FK_NAME "ZZZ";
	;

CLASS SYSTEM_COUNTER;
	TEXT "Счетчик идентификаторов";
	OWNER (NAME OBJECT);
	ATTRIBUTES
		NAME NAME;DOMAIN (NAME STRING);,
		NAME COUNTER;DOMAIN (NAME NUMBER);
		;
	;

SYSTEM_COUNTER COUNTER 100;;


METHOD //QUERY
    NAME INCREMENT_ID;
    OWNER (NAME DOMAIN_CLASS);
    TYPE SET;
    CODE
		IF (CLASS.TABLE != "")
			LET SYSTEM_COUNTER() COUNTER += 1;;,
			ID=SYSTEM_COUNTER().COUNTER
		;
	;
;

ATTRIBUTE(NAME ID) QUERY(NAME INCREMENT_ID);;


///////////////////////////////////////////////////////////////////////////
// Описание того, как могут реализовываться учетные регистры
///////////////////////////////////////////////////////////////////////////

CLASS SOURCE_CLASS;
	OWNER (NAME "DATA");
	TEXT "Класс представления";
	ATTRIBUTES
		NAME NAME;KEY UNIQUE;,
		NAME SOURCE; TYPE REF|SHARED; DOMAIN (NAME CLASS);
	;
;

CLASS SOURCE_ATTRIBUTE;
	OWNER (NAME "DATA");
	TEXT "Атрибут представления";
;
METHOD 
    NAME SOURCE_ATTRIBUTE_CLASS;
    OWNER (NAME ATTRIBUTE);
    RETURN THIS;
    TYPE GET;
    CODE
      OWNER=SOURCE.OWNER
      ;
    ;
CLASS (SOURCE_ATTRIBUTE)
	ATTRIBUTES
		NAME NAME;KEY UNIQUE;,
		NAME SOURCE;	TYPE REF|SHARED; DOMAIN (SOURCE_CLASS);,
		NAME ATTRIBUTE; TYPE REF|SHARED; DOMAIN (ATTRIBUTE); QUERY(SOURCE_ATTRIBUTE_CLASS); 
	;
;


CLASS SUMMARY;
	OWNER (NAME "DATA");
	TEXT "Сводное представление";
	ATTRIBUTES
		NAME TYPE;		TEXT "Режим обновления";, // PERMANENT|SNAPSHOT
		NAME SOURCES;	TEXT "Откуда выбирать";		TYPE COLL|OWNED;	DOMAIN (SOURCE_CLASS);,
		NAME FIELDS;	TEXT "Что выбирать";		TYPE COLL|OWNED;	DOMAIN (SOURCE_ATTRIBUTE);,
		NAME DISPLAY;	TEXT "Что показывать";		TYPE COLL|SHARED;	DOMAIN (SOURCE_ATTRIBUTE);,
		NAME ORDERS;	TEXT "Как упорядочивать";	TYPE COLL|SHARED;	DOMAIN (SOURCE_ATTRIBUTE);,
		NAME GROUPS;	TEXT "Как группировать";	TYPE COLL|SHARED;	DOMAIN (SOURCE_ATTRIBUTE);,
		NAME FILTER;	TEXT "Метод фильтрации";	TYPE REF|SHARED;	DOMAIN (METHOD);,
		NAME CONDITION;	TEXT "Условие отбора";
	;
;

// SELECT FROM DOMAIN_CLASS X, CLASS_FOR_TEST Y
//		Y.NUMBER, X.FULLNAME
//		WHERE X.PK_NAME=Y.FK_NAME
//		ORDER BY Y.NUMBER
//		GROUP BY X.FULLNAME

SUMMARY 
	TYPE SNAPSHOT;
	SOURCES
		NAME X; SOURCE (DOMAIN_CLASS);,
		NAME Y; SOURCE (CLASS_FOR_TEST);
	;
	FIELDS
		NAME X_PK;			SOURCE(X);	ATTRIBUTE (PK_NAME);,
		NAME X_FULLNAME;	SOURCE(X);	ATTRIBUTE (FULLNAME);,
		NAME Y_FK;			SOURCE(Y);	ATTRIBUTE (FK_NAME);,
		NAME Y_NUMBER;		SOURCE(Y);	ATTRIBUTE (NUMBER);
	;
	DISPLAY
		(Y_NUMBER),
		(X_FULLNAME)
	;
	ORDERS
		(Y_NUMBER)
	;
	GROUPS
		(X_FULLNAME)
	;
	CONDITION "X_PK=Y_FK";
;

 


Ведение бухгалтерских счетов


////////////////////////////////////// Классы
CLASS ACCOUNT;
  TEXT "Счет";
  OWNER (NAME DATA);
  ATTRIBUTES
    NAME NUMBER;   TEXT "Код счета"; 	TYPE Embedded; KEY unique; 	NULLS no;  DOMAIN (NAME STRING); ,
    NAME ACC_TYPE; TEXT "Тип счета"; 	TYPE Embedded; KEY no; 		NULLS no;  DOMAIN (NAME STRING); ,
    NAME DEBET;    TEXT "Дебет"; 	TYPE Embedded; KEY no; 		NULLS yes; DOMAIN (NAME NUMBER); ,
    NAME CREDIT;   TEXT "Кредит"; 	TYPE Embedded; KEY no; 		NULLS yes; DOMAIN (NAME NUMBER); ,
    NAME SALDO;    TEXT "Сальдо"; 	TYPE Embedded; KEY no; 		NULLS yes; DOMAIN (NAME NUMBER); ;
  ;

CLASS RECORD;
  TEXT "Проводка двойного учета";
  OWNER (NAME DATA);
  ATTRIBUTES
    NAME DATE;     TEXT "Дата проводки"; 	TYPE EMB; KEY duplicate; NULLS yes; DOMAIN (NAME DATE); ,
    NAME DEBET;    TEXT "Счет дебета"; 	    TYPE REF; SHARED YES; KEY no; NULLS yes; DOMAIN (NAME ACCOUNT); ,
    NAME CREDIT;   TEXT "Счет кредита"; 	TYPE REF; SHARED YES; KEY no; NULLS yes; DOMAIN (NAME ACCOUNT); ,
    NAME AMOUNT;   TEXT "Сумма проводки"; 	TYPE EMB; KEY no; NULLS yes; DOMAIN (NAME NUMBER); ;
  ;


////////////////////////////////////// Данные
ACCOUNT   NUMBER "01";  ACC_TYPE А;  DEBET 1000; ;
ACCOUNT   NUMBER "02";  ACC_TYPE П;  CREDIT 100; ;
ACCOUNT   NUMBER "03";  ACC_TYPE П;  CREDIT 100; ;
ACCOUNT   NUMBER "04";  ACC_TYPE П;  DEBET  100; ;
ACCOUNT   NUMBER "05";  ACC_TYPE П;  CREDIT  10; ;
ACCOUNT   NUMBER "10";  ACC_TYPE А;  DEBET  40;  ;
ACCOUNT   NUMBER "12";  ACC_TYPE А;  DEBET  20;  ;
ACCOUNT   NUMBER "41";  ACC_TYPE А;  DEBET  60;  ;
ACCOUNT   NUMBER "50";  ACC_TYPE А;  DEBET 100;  ;
ACCOUNT   NUMBER "51";  ACC_TYPE А;  DEBET 1000;  ;
ACCOUNT   NUMBER "98";  ACC_TYPE ;   DEBET 100;  CREDIT 1100;  ;
ACCOUNT   NUMBER "99";  ACC_TYPE П;  CREDIT 100;  ;

ACCOUNT   NUMBER "a"; DEBET 1; ;
ACCOUNT   NUMBER "b"; DEBET 1; ;
ACCOUNT   NUMBER "c"; DEBET 1; ;
ACCOUNT   NUMBER "d"; DEBET 1; ;
ACCOUNT   NUMBER "e"; DEBET 2; ;
ACCOUNT   NUMBER "f"; DEBET 2; ;
ACCOUNT   NUMBER "g"; DEBET 2; ;
ACCOUNT   NUMBER "h"; DEBET 2; ;

RECORD ID 12345;  DEBET (NUMBER "51");  CREDIT (NUMBER "50");  AMOUNT 12345;  ;
RECORD ID 54321;  DEBET (NUMBER "51");  CREDIT (NUMBER "99");  AMOUNT 54321;  ;


////////////////////////////////////// Методы
CLASS
	ACCOUNT_UPDATE_TYPE;
	OWNER (NAME DATA);
	TEXT "Тип проводки";
	ATTRIBUTES
		NAME VALUE; TYPE EMB|DEF;
		;
	;

ACCOUNT_UPDATE_TYPE
	VALUE Д;
	,
	VALUE К;
	;


METHOD
  NAME CONVERT_SALDO;
  OWNER (NAME ACCOUNT);
  TEXT "Свернуть сальдо";
  CODE
		SALDO := DEBET,
		SALDO -= CREDIT
		;
	;

  
METHOD 
	NAME UPDATE_DEBET;
	OWNER (NAME ACCOUNT);
	TEXT "Изменить";
//  LOGIC NONE;
	LOGIC ANY;
	RETURN NOTHING;
	ATTRIBUTES
		NAME _UTYPE;   TEXT Тип;  NULLS no; TYPE REF|IN|SHAR; DOMAIN (ACCOUNT_UPDATE_TYPE); ,
		NAME _ACCOUNT; TEXT Счет;  NULLS no; TYPE REF|IN; SHARED YES; DOMAIN (NAME ACCOUNT); ,
		NAME _AMOUNT;  TEXT Сумма; NULLS no; TYPE EMB|IN; DOMAIN (NAME NUMBER); ,
		NAME _DATE;    TEXT Дата;  NULLS no; TYPE EMB|IN; DOMAIN (NAME DATE); ;
	CODE
		IF (_UTYPE.VALUE Д)
			DEBET += _AMOUNT,
			_ACCOUNT.CREDIT += _AMOUNT ,
			NEW RECORD 
				DEBET THIS; 
				CREDIT _ACCOUNT; 
				AMOUNT _AMOUNT; 
				DATE _DATE;
			;
		;,
		IF (_UTYPE.VALUE К)
			CREDIT += _AMOUNT,
			_ACCOUNT.DEBET += _AMOUNT ,
			NEW RECORD 
				CREDIT THIS; 
				DEBET _ACCOUNT; 
				AMOUNT _AMOUNT; 
				DATE _DATE;
			;
		;,
		run MESSAGE TEXT "Проводка проведена";, // выплюнуть сообщение //?
		CONVERT_SALDO, _ACCOUNT.CONVERT_SALDO
		;//CODE
	;



METHOD 
	OWNER (NAME RECORD);
	NAME ENTER_RECORD;
	TEXT "Провести проводку";
	CODE
	/*
		DEBET.UPDATE_DEBET _AMOUNT 50; _DATE "12/12/97"; // конец запроса
		, // конец оператора
		CREDIT.UPDATE_DEBET _AMOUNT 50; _DATE "12/12/97"; // конец запроса
		; // конец кода
	*/
	//    DEBET.UPDATE_DEBET AMOUNT AMOUNT, DATE "12/12/97"; //?

		DEBET .DEBET  += AMOUNT, // увеличить обороты по дебету
		DEBET .CONVERT_SALDO,
		CREDIT.CREDIT += AMOUNT, // увеличить обороты по кредиту
		CREDIT.CONVERT_SALDO,
		
		run MESSAGE TEXT "Проводка проведена";; // выплюнуть сообщение //?
		;
	;



////////////////////////////////////// Запросы
ACCOUNT( {DEBET 1, DEBET 2}, {NUMBER a, NUMBER c, NUMBER e, NUMBER g} ) CREDIT 77;;
ACCOUNT{ (CREDIT 0,DEBET 1), (CREDIT 0,DEBET 2) } CREDIT 88;;
ACCOUNT( {(NUMBER=a, {CREDIT=77,CREDIT=88}), (NUMBER b, {CREDIT=77,CREDIT=88}), (NUMBER=e, {CREDIT=77,CREDIT=88}), (NUMBER=f,{CREDIT=77,CREDIT=88})}, {DEBET=1, DEBET=2} ).CONVERT_SALDO;

ACCOUNT(NUMBER0,{NUMBER1,NUMBER5}).CONVERT_SALDO;



////////////////////////////////// Формы
FONT "MS Sans Serif";

FORM
	NAME MAIN_MENU;
	TEXT "Главное меню";
	PRINTER_NAME "Епсон";
	FONT_NAME "Arial Cyr";
	BACK "200,220,250";
	PAGE_WIDTH  200;
	PAGE_HEIGHT 140;
	CONTROLS
		TYPE STATIC; X  50; Y  10; WIDTH 100; HEIGHT 20; FONT_SIZE 32; COLOR "50,150,230"; TEXT "Счета и проводки";
		,
		TYPE BUTTON; X  50; Y  40; WIDTH 100; HEIGHT 20; TEXT "Счета";
		EVENTS
			NAME LCLICK; CODE RUN FORM(NAME EDIT_ACCOUNT);;
			;
		,
		TYPE BUTTON; X  50; Y  70; WIDTH 100; HEIGHT 20; TEXT "Проводки";
		EVENTS
			NAME LCLICK; CODE RUN FORM(NAME EDIT_RECORD);;
			;
		,
		TYPE BUTTON; X  50; Y 100; WIDTH 100; HEIGHT 20; TEXT "Выход"; NAME QUIT;
		;
	;

FORM
	NAME EDIT_ACCOUNT;
	TEXT "Просмотр и редактирование счетов";
	OWNER (NAME ACCOUNT);
	PRINTER_NAME "Стилус";
	FONT_NAME "Arial Cyr";
	BACK "200,220,200";
	PAGE_WIDTH  200;
	PAGE_HEIGHT 140;
	COLOR "255,255,255";
	CONTROLS
		TYPE STATIC; X  50; Y  5; WIDTH 100; HEIGHT 10; FONT_SIZE 32; COLOR "10,100,10"; TEXT "Счета";,
		TYPE GRID; X  10; Y 20; WIDTH 180; HEIGHT 100; NAME THIS;,
/*
		TYPE BUTTON; X  10; Y 125; WIDTH 40; HEIGHT 10; TEXT "Изменить счет";
		EVENTS
			NAME LCLICK; 
			ATTRIBUTES 
				NAME _ACCOUNT; TYPE REF|SHARED|IN; DOMAIN(ACCOUNT);
				;
			CODE 
//				RUN MESSAGE TEXT TARGET.NUMBER;;
				_ACCOUNT=TARGET,
				_ACCOUNT.CONVERT_SALDO
				;
			;
		,
*/
		TYPE BUTTON; X  10; Y 125; WIDTH 38; HEIGHT 10; TEXT "Исправить"; NAME "TARGET.EDIT";,
		TYPE BUTTON; X  50; Y 125; WIDTH 38; HEIGHT 10; TEXT "Свернуть";
		EVENTS
			NAME LCLICK; 
			CODE 
				TARGET.CONVERT_SALDO,
				RUN MESSAGE TEXT "Обновите таблицу, чтобы увидеть результят";;
				;
			;
		,
		TYPE BUTTON; X  90; Y 125; WIDTH 38; HEIGHT 10; TEXT "Проводка";
		EVENTS
			NAME LCLICK; 
			CODE 
				TARGET.UPDATE_DEBET,
				RUN MESSAGE TEXT "Обновите таблицу, чтобы увидеть результят";;
				;
			;
		,
		TYPE BUTTON; X 160; Y 125; WIDTH 38; HEIGHT 10; TEXT "Закрыть"; NAME BACK;
		;
  ;//FORM


FORM
  NAME EDIT_RECORD;
  TEXT "Просмотр и редактирование проводок";
  OWNER (NAME RECORD);
  PRINTER_NAME "Стилус";
  FONT_NAME "Times New Roman Cyr";
  BACK "250,250,200";
  PAGE_WIDTH  210;
  PAGE_HEIGHT 140;
  COLOR "255,255,255";
  CONTROLS
		TYPE STATIC; X  50; Y  5; WIDTH 100; HEIGHT 10; FONT_SIZE 32; COLOR "120,80,15"; TEXT "Проводки";,
		TYPE GRID; X  10; Y 20; WIDTH 180; HEIGHT 100; NAME THIS;,

		TYPE BUTTON; X  10; Y 125; WIDTH 40; HEIGHT 10; TEXT "Провести проводку";
		EVENTS
			NAME LCLICK; 
			CODE 
				TARGET.ENTER_RECORD,
				;
			;
		,
		TYPE BUTTON; X  60; Y 125; WIDTH 40; HEIGHT 10; TEXT "Исправить"; NAME "TARGET.EDIT";,
		TYPE BUTTON; X 110; Y 125; WIDTH 40; HEIGHT 10; TEXT "Закрыть"; NAME BACK;
		;
  ;//FORM


FORM(MAIN_MENU).RUN;
RUN MESSAGE TEXT 'Загружено "Ведение счетов"';;

 


 Учет клиентуры


////////////////////////////////// Классы
CLASS
    DICTIONARY;
    OWNER (NAME DATA);
    TEXT "Справочная информация";
    ;

CLASS
  PHONE;
  TEXT "Контактный телефон";
  OWNER (NAME DICTIONARY);
  ATTRIBUTES
    NAME NUMBER;    TEXT "Номер телефона"; ACCESS public; TYPE Embedded; KEY unique; NULLS no; DOMAIN (NAME STRING); ,
    NAME FROM_TIME; TEXT "С какого времени"; ACCESS public; TYPE Embedded; KEY unique; NULLS no; DOMAIN (NAME STRING); ,
    NAME TO_TIME;   TEXT "По какое время"; ACCESS public; TYPE Embedded; KEY unique; NULLS no; DOMAIN (NAME STRING); ;
  ;

CLASS
  ADDRESS;
  TEXT "Адрес";
  OWNER (NAME DICTIONARY);
  ATTRIBUTES
    NAME STREET;   TEXT "Улица"; ACCESS public; TYPE Embedded; KEY unique; NULLS no; DOMAIN (NAME STRING); ,
    NAME CITY; TEXT "Город"; ACCESS public; TYPE Embedded; KEY unique; NULLS no; DOMAIN (NAME STRING); ;
  ;

CLASS
  SUBJECT;
  TEXT Субъекты;
  OWNER (NAME DICTIONARY);
  TYPE STRUCTURE;
  USAGE ALONE;
  ATTRIBUTES
    NAME CODE; TEXT Код; ACCESS public; TYPE Embedded; KEY unique; NULLS no; OWNER (NAME SUBJECT); DOMAIN (NAME NUMBER); ,
    NAME ADDRESS; TEXT "Фактический адрес";  TYPE REF; SHARED NO; NULLS yes; DOMAIN (NAME ADDRESS); ,
    NAME PHONES;  TEXT "Контактные телефоны"; TYPE COLLECTION; SHARED NO; DOMAIN (NAME PHONE);;
  ;

CLASS
  PERSON;
  OWNER (NAME DICTIONARY);
  TEXT "Физические лица";
  TYPE STRUCTURE;
  USAGE ALONE;
  ATTRIBUTES
    NAME FIRSTNAME; TEXT Имя; 	ACCESS public; TYPE Embedded; KEY duplicate; 	NULLS yes; 	OWNER (NAME PERSON); DOMAIN (NAME STRING); ,
    NAME LASTNAME;  TEXT Фамилия;ACCESS public; TYPE Embedded; KEY no; 		NULLS no; 	OWNER (NAME PERSON); DOMAIN (NAME STRING); ;
  ;

CLASS
  ENTERP;
  TEXT Предприятия;
  OWNER (NAME DICTIONARY);
  TYPE STRUCTURE;
  USAGE ALONE;
  ATTRIBUTES
    NAME ORGNAME;	TEXT Название; 	ACCESS public; TYPE Embedded; KEY duplicate; NULLS no; OWNER (NAME ENTERP); DOMAIN (NAME STRING); ,
    NAME INN;	TEXT ИНН; 	ACCESS public; TYPE Embedded; KEY unique; NULLS no; 	OWNER (NAME ENTERP); DOMAIN (NAME STRING); ;
  ;


/////////////////////////////////////// Данные
SUBJECT CODE 111;;

SUBJECT CODE 222;
  ADDRESS CITY Новосибирск; STREET "Морской 1-2"; ;
  PHONES NUMBER 35-35-35; FROM_TIME "01:01";, NUMBER 12-34-56; FROM_TIME "02:02";, NUMBER 00-00-01;, NUMBER 77-77-77;  ;
  ;

SUBJECT CLASS (name PERSON); CODE 333; FIRSTNAME Ильич;;
SUBJECT CLASS (name ENTERP); CODE 444; ORGNAME "ТОО ЗАО"; ;

//Multiple inheritance danger!!!
PERSON  CLASS (name SUBJECT); FIRSTNAME Кот; LASTNAME "Матроскин"; CODE 555;;
ENTERP  CLASS (name SUBJECT); INN 0010020071; CODE 666;;
//Multiple inheritance danger!!!

PERSON  LASTNAME Чубайс;;
SUBJECT  CODE 12345;;
PERSON(LASTNAME Чубайс) CLASS (NAME SUBJECT); CODE 67890;;
SUBJECT(CODE 12345) CLASS (NAME PERSON); LASTNAME Ельцин;;
OBJECT(CLASS SUBJECT, code 111) CLASS (name ENTERP); ORGNAME "ABC"; INN "987654321";;
SUBJECT(CODE 222) CLASS (name PERSON); FIRSTNAME "Сидор"; LASTNAME "Петров"; ;
PERSON  LASTNAME Лоханкин; FIRSTNAME "Васисуалий";;
SUBJECT CODE 777; joins PERSON(FIRSTNAME "Васисуалий", LASTNAME Лоханкин) ;;
SUBJECT CODE 888; JOINS PERSON FIRSTNAME "Варвара";;;
SUBJECT(CODE 888) CLASS (PERSON); LASTNAME Лоханкина;;
OBJECT(CLASS SUBJECT,CODE 222) LASTNAME "Петров-Водкин";;
SUBJECT(CODE 222) FIRSTNAME "Иван";;
PERSON(FIRSTNAME Ильич) LASTNAME Ленин;;

//?
SUBJECT CODE 999;; // OBJECT CLASS (NAME SUBJECT); CODE 999;; // Pure Abstract !!!
OBJECT(CLASS SUBJECT, CODE 999) CLASS (NAME PERSON); FIRSTNAME Инженер; LASTNAME Птибурдуков;;
//?



////////////////////////////////// Формы
FONT "MS Sans Serif";

FORM
	NAME MAIN_MENU;
	TEXT "Главное меню";
	PRINTER_NAME "Епсон";
	FONT_NAME "Arial Cyr";
	BACK "230,230,230";
	PAGE_WIDTH  200;
	PAGE_HEIGHT 140;
	CONTROLS
		TYPE STATIC; X  50; Y  10; WIDTH 100; HEIGHT 20; FONT_SIZE 32; COLOR "100,100,100"; TEXT "Справочник субъектов";
		,
		TYPE BUTTON; X  50; Y  40; WIDTH 100; HEIGHT 20; TEXT "Субъекты";
		EVENTS
			NAME LCLICK; CODE RUN FORM(NAME VIEW_SUBJECTS);;
			;
		,
		TYPE BUTTON; X  50; Y  80; WIDTH 100; HEIGHT 20; TEXT "Выход"; NAME QUIT;
		;
	;


FORM
	NAME VIEW_SUBJECTS;
	TEXT "Просмотр и редактирование субъектов";
	OWNER (NAME SUBJECT);
	BACK "230,230,230";
	FONT_SIZE  12;
	PAGE_WIDTH  200;
	PAGE_HEIGHT 140;
	CONTROLS
		TYPE STATIC; X  50; Y  5; WIDTH 100; HEIGHT 10; FONT_SIZE 24; COLOR "100,100,100"; TEXT "Список всех субъектов";
		,
		TYPE GRID; X 10; Y 20; NAME THIS; WIDTH 180; HEIGHT 100; UPDATE YES;
		   CONTROLS
			 NAME "CODE";  TEXT "КОД СУБЪЕКТА"; DOMAIN (NAME ACCOUNT); ,
			 NAME "ORGNAME"; TEXT "ОРГАНИЗАЦИЯ"; ,
			 NAME "FIRSTNAME"; TEXT "ФИО"; ,
			 NAME "ADDRESS.STREET"; TEXT "УЛИЦА"; ,
			 NAME "ADDRESS.CITY"; TEXT "ГОРОД"; ;
		,
		TYPE BUTTON; X  10; Y 125; WIDTH 18; HEIGHT 10; TEXT "Исправить";   NAME "TARGET.EDIT";,
		TYPE BUTTON; X  30; Y 125; WIDTH 18; HEIGHT 10; TEXT "&<";          NAME PREV;,
		TYPE BUTTON; X  50; Y 125; WIDTH 18; HEIGHT 10; TEXT "&";          NAME NEXT;,
		TYPE BUTTON; X  70; Y 125; WIDTH 18; HEIGHT 10; TEXT "&Новый";      NAME NEW;,
		TYPE BUTTON; X  90; Y 125; WIDTH 18; HEIGHT 10; TEXT "&Записать";   NAME POST;,
		TYPE BUTTON; X 110; Y 125; WIDTH 18; HEIGHT 10; TEXT "&Удалить";    NAME DEL;,
		TYPE BUTTON; X 130; Y 125; WIDTH 18; HEIGHT 10; TEXT "&Закрыть";    NAME BACK;
		;//CONTROLS
	;//FORM



FORM(MAIN_MENU).RUN;
RUN MESSAGE TEXT 'Загружен "Справочник субъектов"';;

 


Исчисление предикатов (PROLOG)

CLASS
	NAME HUMAN;
	TEXT "Human";
  	ATTRIBUTES
		NAME NAME;
	;
CLASS
	PARENT (NAME HUMAN);
	NAME MALE;
	TEXT "Male";
	;
CLASS
	PARENT (NAME HUMAN);
	NAME FEMALE;
	TEXT "Female";
	;
CLASS
	PARENT (NAME ENTITY);
	TEXT "Male/Female";
  	ATTRIBUTES
		NAME SEX;,
		NAME HUMAN;;
	;
CLASS
	PARENT (NAME ENTITY);
	NAME PARENT;
	TEXT "Parent of child";
  	ATTRIBUTES
    	NAME PARENT;,
    	NAME CHILD;;
  	;
PARENT
  	PARENT PAM; CHILD BOB;,
  	PARENT TOM; CHILD BOB;,
  	PARENT TOM; CHILD LIZ;,
  	PARENT BOB; CHILD ANN;,
  	PARENT BOB; CHILD PAT;,
  	PARENT PAT; CHILD JIM;;

//  Who are BOB's kids?
//? PARENT( PARENT BOB ).EDIT;
//! ANN, PAT

//  Is BOB parent of PAT?
//? PARENT( PARENT BOB, CHILD PAT );
//! TRUE

//  Is LIZ parent of PAT?
//? PARENT( PARENT LIZ, CHILD PAT );
//! NO

PARENT( CHILD (CHILD JIM).PARENT ).EDIT;

//? PARENT( PARENT (CHILD BOB).PARENT ).CHILD;

 


 Объектно-реляционный язык ORL и системное ядро