3. The dynamic DFM file application second: The hypermedia system script language design
Hypermedia scripting language design is an important part of hypermedia system design. Scripting languages must be able to express multiple media objects in a card, must be programmable, understandable, must be executable, and should be able to generate cards and chains in hypermedia systems by scripting languages.
The DFM file can be viewed as a hypermedia system card, DFM script can express a variety of control in the DFM file, that is, can express a variety of media objects in the card, coupled with the DFM script object expression, editable, can be converted to DFM files, so as a hyper-media system scripting language better form.
The Objectbinarytotext and objecttexttobinary processes provide the ability to convert between parts and DFM scripts, The Objectresourcetotext and objecttexttoresoure processes provide the ability to transform DFM files and DFM scripts into one another. This makes it easy to convert hypermedia cards and Hyper-media scripting languages into the application.
The following is a procedure for translating cards and scripting languages into one another:
Procedure Tmdichild.cardtoscript;
Var
In, Out:tstream;
Begin
In: = Tmemorystream.create;
Out: = Tmemorystream.create;
Try
In.writecomponentres (Self.classname, Self);
Objectresourcetotext (in, out);
ScriptForm.ScriptEdit.Lines.LoadFromStream (out);
Finally
In.free;
Out.free;
End
End
Scriptedit is a text editor whose Lines property is an object of the tstrings type.
Procedure Tscriptform.scripttocard;
Var
In, Out:tstream;
Begin
In: = Tmemorystream.create;
Out: = Tmemorystream.create;
Try
ScriptForm.ScriptEdit.Lines.SaveToFromStream (in);
Objecttexttoresource (in, out);
In.readcomponentres (Designwin);
Finally
In.free;
Out.free;
End
End
These two programs are converted to the entire card, the form level. The Objectbinarytotext and objecttexttobinary processes can be refined to a component-level transformation. Therefore, the editing of the Hypermedia scripting language can be refined to the media object level.
4. Hypermedia editing and performance system and dynamic DFM file expansion
Media editing and card management in hypermedia systems have special needs, such as link demand. At this time, the existing form parts and media components and according to the general DFM file processing seems powerless. There are two sets of solutions to this paradox:
Using Delphi Component Development technology, inheriting and developing new components to add new hypermedia-specific attributes and processing methods
Extend the DFM file structure so that it can access and transform parts and DFM files arbitrarily and in accordance with its own needs
The former is to make full use of Delphi object-oriented Component Development Technology, in the access and conversion processing and so on still with the regular DFM file the same. The latter needs the DFM's access and conversion to make relatively large changes. The following is an introduction to the idea of expanding DFM documents.
The general idea of extending the dynamic DFM file is to reduce the granularity of data processed by processing, from the original form level to the part level.
The following is an extended demonstration of the access operation:
Var
Filestream:tstream;
I:integer;
Begin
FileStream: = Tfilestream.create (' OVERVIEW.CRD ', fmopenwrite);
With Twriter.create (FileStream, 4096) do
Try
For I: = 0 to Designwin.controlcount-1 do
Begin
Writeinteger (Mmid[i]);
Writerootcomponent (Designwin.controls[i]);
{Write appropriate media extension information}
......
End
Writelistend;
Finally.
Free;
End
Filestream.free;
End
The Writeinteger (Mmid[i]) statement is written to the media identity.
The following is the corresponding read extension DFM program:
Var
Propinfo:ppropinfo;
Method:tmethod;
Filestream:tstream;
I:integer;
Begin
FileStream: = Tfilestream.create (' OVERVIEW.CRD ', fmopenread);
With Treader.create (FileStream, 4096) do
Try
While does Endoflist do
Begin
Case Readinteger of
Idtext:begin
Ctrl: = Tcontrol (readrootcomponent (nil));
Propinfo: = Getpropinfo (Ctrl.classinfo, ' OnClick ');
method.code:= self.methodaddress (methodname);
Method.data: = Self;
If Method.code <> Nil Then
Setmethodprop (Ctrl, Propinfo, method);
Designwin.insertcontrol (Ctrl);
End
Idimage:
......
End
......
Writelistend;
End
Finally.
Free;
End
Filestream.free;
End
The Setmethodprop process is used to reconnect the control and its event-handling process. Similar functions can also be implemented using the process of Onfindmethod events for Treader objects.
The basic method of implementing a scripting language extension is similar to an access extension, but it also converts the extended media information into text and inserts it into the script description of the part.