📄 delphi.txt
字号:
Notes to Generate Delphi 2.0 Code
The purpose of this paper is to describe how to generate Delphi 2.0 code from class diagrams, state diagrams, and object interaction diagrams. These scripts are "getting started" scripts that must be updated for your development environment.
These scripts are "getting started" scripts that must be updated for your development environment.
1. Generating Delphi Code from a Class Diagram
*******************************Class Diagram************************************************
Class Diagram: delphcar.omt
Script Files: delphi0.sct and delphi1.sct
The steps to generate Borland Delphi (Object Pascal) code and to compile the generated files are as follows:
>> Launch With Class from Windows
>> Open delpcar.omt
>> Select "Utilities - Generate Class Code per File"
>> Select pas as the custom file extension
>> Select delphi1.sct to generate the Pascal units
>> Select "File - Edit File" to examine the generated files, e.g. car.pas
>> Launch your Delphi environment
>> Add each generated file, e.g. Vehicle.pas, Motor.pas, CellularPhone.pas, Passenger.pas, Tire.pas, and Car.pas
into your project.
Notes for generating Object Pascal (Delphi and Turbo Pascal 5.5. or greater):
(1) The scripts generate class names with a T prefix, e.g. TCar, TVehicle, etc. The scripts generate a unit name based
upon the class name on the diagram, e.g. car, vehicle, etc. The scripts generate a file name based upon the class name
on the diagram, e.g. car.pas, vehicle.pas, etc.
(2) For uses clause, the scripts create the following:
uses SysUtils, Messages, Classes ;
The scripts place unit names for units based upon inheritance, association, and aggregation,
e.g. uses SysUtils, Messages, Classes, Vehicle, Motor, Passenger, Tire, CellularPhone;
You may also place other unit names into the include box, e.g. INCLUDE_FILE
(3) On the class diagram, insert parameters in the C++ form, e.g. Parameter_Type Parameter_Name - Integer
aNumber. The script variable PASCAL_OPERATION_PARAMETERS_WITH_VAR then puts the parameter
into the Pascal form, e.g. (Parameter_Name : Parameter_Type ; Var A_Parameter_Type : Parameter_Type) -
(A_Number : Integer ; Var A_Integer : Integer).
(4) On the class diagram for each operation, check the appropriate check boxes if the operation virtual, abstract,
event, override, etc.
(5) On the class diagram for each attribute, check the appropriate check boxes if the attribute is a property.
(6) In Delphi, create the user interface. In the form unit, enter the unit name of the generated unit, e.g.
CAR. In the form class type section enter the object declaration, e.g. Car: car1;
In the form class procedures enter the messages to invoke generated code procedures, e.g.
car1.start;
2. Generating Delphi Code from a State Diagram
************************************State Diagram*******************************************
State Diagrams: delstat1.omt and delstat2.omt
Script Files: delstat1.sct and delstat2.sct
The following are the general steps to test out the Object Pascal code generation scripts:
1. Create a directory for the state .omt files, script files, and Object Pascal files, e.g. CARCSTATE.
2. Copy the appropriate files into each directory, e.g. copy st*.*.
3. In With Class open a state diagram, e.g. DELSTAT1.OMT.
4. Select Utilities - Generate State Code/Report to generate a text report. Select the script, e.g. DELSTAT1.SCT.
Enter a state unit file name, e.g. CONTROLLER.PAS. Select a state report script, e.g. RPTSTATE.SCT, DDSTATE.SCT, or TABSTATE.SCT.
After report generation, select File - Edit File to examine the generated report.
5. In the Object Pascal environment, compile and run the program.
6. Go back to With Class and update the state diagram with new states, events, conditions,
and actions and repeat the entire process.
3. Generating Delphi Code from an Object Interaction Diagram
*******************************************Object Interaction Diagram*******************************
Object Interaction Diagram: carobj.omt
Script Files: tabobmsg.sct
The steps to generate Borland Delphi (Object Pascal) messages to cut and paste into your Object Pascal code:
1. Open the object interaction diagram, e.g. carobj.omt
2. Select Utilities - Generate Generate Object Code/Report and select tabobmsg.omt
3. Enter the report file name, e.g. tabobmsg.txt
4. Cut each Object Pascal message and paste it into your class code.
4. Comments and suggestions are solicited. Richard Felsinger, RCF Associates 960 Scottland Dr, Mt Pleasant, SC 29464 71162.755@compuserve.com 803-881-3648
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -