Дело вкуса.
А вот когда Dilma говорил про "корректнее", он видимо имел ввиду что-то типа такого (это я типа расшифровать пытаюсь)
#sha
Add(MainForm,11176470,175,35)
{
Left=20
Top=105
Width=527
Point(onClose)
link(onCreate,2371655:doOpen,[])
link(onClose,2371655:doClose,[])
}
Add(RichEdit,2797906,343,105)
{
Left=10
Top=35
Width=495
Height=225
Align=5
FileName=".\compiler\Fpc\kol.pas"
ScrollBars=3
}
Add(InlineCode,2371655,287,49)
{
WorkPoints=#6:doOpen|7:doClose|
VarPoints=#6:Stream|
Code=#15:unit HiAsmUnit;|0:|9:interface|0:|29:uses windows,kol,Share,Debug;|0:|4:type|14: {$ifndef F_P}|33: TStreamEx = object(TStream) end;|24: PStreamEx = ^TStreamEx;|8: {$else}|32: TStreamEx = class(TStream) end;|23: PStreamEx = TStreamEx;|9: {$endif}|0:|28: THiAsmClass = class(TDebug)|10: private|18: hMMF:THandle;|16: Data:PChar;|18: ST:PSTreamEx;|21: procedure Close;|9: public|24: constructor Create;|33: destructor Destroy;override;|46: procedure doOpen(var _D:TData; idx:word);|47: procedure doClose(var _D:TData; idx:word);|46: procedure Stream(var _D:TData; idx:word);|5: end;|0:|14:implementation|0:|22:const Size = 10000000;|0:|79:function WriteExMemoryStream( Strm: PStream; var Buffer; Count: DWORD ): DWORD;|3:asm|20: PUSH EBX|25: XCHG EBX, EAX|49: MOV EAX, [EBX].TStreamEx.fData.fSize|53: SUB EAX, [EBX].TStreamEx.fData.fPosition|25: CMP EAX, ECX|20: JGE @@1|25: XCHG ECX, EAX|4:@@1:|45: MOV EAX, [EBX].TStreamEx.fMemory|53: ADD EAX, [EBX].TStreamEx.fData.fPosition|25: XCHG EDX, EAX|20: PUSH ECX|28: CALL System.Move|20: POP EAX|53: ADD [EBX].TStreamEx.fData.fPosition, EAX|20: POP EBX|4:end;|0:|37:var SharedMethods: TStreamMethods = (|25: fSeek: SeekMemStream;|30: fGetSiz: GetSizeMemStream;|26: fSetSiz: DummySetSize;|25: fRead: ReadMemStream;|32: fWrite: WriteExMemoryStream;|28: fClose: DummyStreamProc;|17: fCustom: nil;|15: fWait: nil;|4: );|0:|31:constructor THiAsmClass.Create;|5:begin|100: hMMF := CreateFileMapping(INVALID_HANDLE_VALUE, nil, PAGE_READWRITE, 0, Size, 'MySuperPuperName');|4:end;|0:|29:procedure THiAsmClass.doOpen;|14:var P:Pointer;|5:begin|22: if hMMF=0 then exit;|8: Close;|55: P := MapViewOfFile(hMMF, FILE_MAP_WRITE, 0, 0, Size);|21: if P=nil then exit;|45: ST := PStreamEx(_NewStream(SharedMethods));|18: ST.fMemory := P;|29: ST.fData.fCapacity := Size;|25: ST.fData.fSize := Size;|4:end;|0:|28:procedure THiAsmClass.Close;|5:begin|22: if ST=nil then exit;|30: UnmapViewOfFile(ST.fMemory);|19: free_and_nil(ST);|4:end;|0:|30:procedure THiAsmClass.doClose;|5:begin|8: Close;|4:end;|0:|31:destructor THiAsmClass.Destroy;|5:begin|8: Close;|20: CloseHandle(hMMF);|4:end;|0:|29:procedure THiAsmClass.Stream;|5:begin|18: dtStream(_D,ST);|4:end;|0:|4:end.|
}
Add(Menu,9436858,28,105)
{
Menu=#6:Append|5:Write|4:Read|
Point(onSelectNum)
link(onSelectNum,12401350:doEvent,[])
}
Add(IndexToChanel,12401350,77,112)
{
Count=3
Data=Integer(0)
link(onEvent1,2934282:doOperation,[])
link(onEvent2,9182042:doEvent2,[])
link(onEvent3,1104125:doEvent1,[(118,132)(118,160)])
}
Add(DoData,2298906,231,119)
{
link(onEventData,1143428:doPut,[])
link(Data,2797906:Text,[(237,108)(333,108)(333,155)(349,155)])
}
Add(DataToFile,1143428,287,119)
{
Type=6
Point(doPosition)
Point(Position)
link(onGet,2797906:doText,[])
link(Stream,2371655:Stream,[])
}
Add(Hub,9182042,175,112)
{
InCount=2
link(onEvent1,2836025:doWork1,[(221,118)])
link(onEvent2,2298906:doData,[])
}
Add(HubEx,2836025,217,126)
{
link(onEvent,1143428:doPosition,[])
}
Add(Hub,1104125,175,154)
{
link(onEvent1,2836025:doWork3,[(221,160)])
link(onEvent2,1143428:doGet,[(271,167)(271,132)])
}
Add(Math,2934282,126,112)
{
OpType=1
Op2=1
link(onResult,9182042:doEvent1,[])
link(Op1,1143428:Position,[(132,101)(149,101)(149,176)(300,176)])
}