Creation of the Pzl-Component

Материал из wikiru.visual-prolog.com

Автор: Виктор Юхтенко

Pzl-component is the package of the Visual Prolog programming system. The IDE of the Visual Prolog system can create the class and the package within the currently opened project. The Elementary PzlStudio cannot deal with the Visual Prolog projects fully. The Elementary Studio performs the elementary operation, which creates the pzl-component independent of the project. The newly created pzl-component may be later placed to any pzl-container.

To create the pzl-component it needs to fill the form, which contains the properties of the pzl-component such as the component identifier, component alias, the name of the base class and the name of the interface etc..

When the form is filled, you press the button and you get the pzl-component, which may be now embedded to any pzl-container (executable application or the DLL).

Invoking the Operation

The form to create the pzl-component is invoked via the menu item File/New.../Component.

PzlStudio CreateNewComponent.png

The list of properties is shown below

The editing of the option is performed in the right side of the table. The Editing supposed to be done by the explicit editing or it may be done by the pressing the button on the right side of the active field. Double clicking makes the same as pressing the button.

The operation is performed by clicking the button Create.

The button may be inactive if there is not enough data entered.

After the operation completion you may create any other pzl-component.

The button Close closes the form.

Performing the Operation

While the performing the operation the Message Window gets the report regarding the changes made in the project.

PzlStudio CreatedNewComponentReport.png

The newly created the Pzl-component may be embedded now to the pzl-container.

Properties of the Pzl-Component

Components Base Directory

This is the name of the directory, which was set in the Basic Options. If you have no reasons to change the directories organization, then you may leave this property with no changes.

You may change the Components Base Directory. Just make a double click or press the button at the right side. This will invoke the file dialog to choose the name of the directory. If you set the name of the directory, which doesn’t exist, then Elementary PzlStudio will create it, if possible

If you have changed the Components Base Directory compare to what was set in the basic options, then when the form will be closed you will get the question whether you wish to make changes in the Basic Options.

PzlStudio ChangeBaseComponentsDirectory.png

If you agree, then the new value will be used each time, when it participates in any operation.

Sub-Directory

The Component Sub-Directory is exactly the directory, where all files of the package of the pzl-component will be generated.

The Sub-Directory must be considered as the path (say Dir1/Dir2/Dir3 or just Dir1), which together with the base directory of the components gives the final path to the directory, where all files of the component will be placed.

The property Sub-Directory is mandatory. It may not be empty.

If the final directory does not exist, then it will be created with no announcement.

If it is impossible to create the final directory, then the error dialog appeared with the error message.

Please notice: the name of the final directory of the pzl-component and the name of the package may differ. It has some difference from the rule used in the IDE of the Visual Prolog system. In the Visual Prolog, the name of the package defines also the name of the directory. Initially they proposed equal.

Component Name

The name of the component defines the name of the set of files

  • <Component Name>.pack,
  • <Component Name>.ph,
  • <Component Name>.cl,
  • <Component Name>.i,
  • <Component Name>.pro

Interface Name

The name of the Interface defines the base interface of the component. The base interface is the interface, which provides the class by the feature to create objects.

interface iMyInterface
    supports pzlComponent
...

Base Interface contains also all needed constants all needed constants.

The name of the base interface of the pzl-component may not be the same as the name of the class. If this demand is not maintained, then the error message appears.

PzlStudio NewComponentError SameName.png

The name of the base interface may not be empty.

Class Name

The class name defines the base class of the component, i.e. the class, which will be used to create the instances of the component.

class myComponent : iMyComponent
    open core
...

The name of the base class of the pzl-component may not be the same as the name of the interface. If this demand is not maintained, then the error message appears.

The name of the class may not be empty.

Component Alias

The component Alias may be any (not empty, no spaces) sequence of chars and serves to identify the type of the component like "TextEditor".

Идентификатор компоненты

Идентификатор компоненты при ее назначении в форме может быть:

  • либо любой (не пустой и не содержащей пробелов) строкой символов
  • либо строкой символов, соответствующей уникальному идентификатору UID.

Первая форма идентификатора получается простым набором текста, являющегося идентификатором компоненты

PzlStudio ComponentIDAsString.png

Вторая форма идентификатора получается нажатием кнопки справа.

PzlStudio ComponentIDAsUID.png

Автономная Запускаемость

Параметр Автономной Запускаемости (RunAble) определяет возможность выполнения компонентой своей функции самостоятельно.

В форме может быть выбрано одно из двух значений: Yes и No. Если выбрано Yes, то компонента будет поддерживать интерфейс SpbRun

interface iMyInterface
    supports pzlComponent
    supports spbRun
...

и в файле <Имя Компоненты>.pro будет создан код, который должен быть конкретизирован:

clauses
  spbRun(_UserText).

Пользовательский интерфейс

Параметр Пользовательский Интерфейс определяет тип пользовательского интерфейса и выбирается из списка возможных значений:

  • VPI - традиционный механизм графики
  • GUI - объектный механизм графики
  • Consol - консольный - без графического интерфейса.

Атрибуты из базовых свойств

Последние три позиции в форме

  • Company
  • Author
  • Copyright

устанавливаются в Базовых свойствах и здесь могут быть переопределены в случае, отличном от типового. Если Вы их здесь изменили, то значения этих параметров в Базовых свойствах не изменяются.

Ссылки