Пишем программу (в Delphi) для создания книг FB2 - страница 9

стр.

>

>'>': S:= S + '>'; // заменяем, на всякий случай

>'^': S:= S + '^'; //

>'~': S:= S + '~';

>'&': S:= S + '&';

>else S:= S + ss[j];

>end; // case

>end;

>L[i]:= ' N| ' + S;

>end;

>Form1.ListBox1.Items.Assign(L);

>L.Free;

>end;

>procedure NameFB2_File(S: string);

>begin //

>S:= ExtractFileName(S);

>Form1.Caption:= S;

>Form1.FB2_file.Text:= ChangeFileExt(S,'.fb2');

>end;

>procedure TForm1.Open1Click(Sender: TObject);

>begin

>with OpenDialog1 do

>if Execute then

>begin

>NameFB2_File(FileName);

>ListBox1.Clear;

>LoadTXT(FileName); // txt

>end;

>end;

>function GetGaner(S: string):string;

>var

>i: integer;

>begin

>for i:= 0 to maxg do

>if gg[i][2] = S then

>begin

>result:= gg[i][1];

>exit;

>end;

>result:= s;

>end;

>procedure SaveAnnotation;

>var

>i: integer;

>begin

>OutList.Add('');

>with form1.Annotation do

>for i:= 0 to Lines.Count – 1 do

>OutList.Add('

'+Lines[i]+'

');

>OutList.Add('');

>end;

>procedure SavePersons(title: string; LB: TListBox);

>var

>i: integer;

>Person: TPerson;

>begin

>with LB do

>if Count > 0 then

>for i:= 0 to Count – 1 do

>begin

>Person:= TPerson(Items.Objects[i]);

>OutList.Add(' <'+title+'>');

>with Person do

>begin

>PrintString('first-name',fname);

>PrintString('last-name',lname);

>PrintString('middle-name',mname);

>PrintString('nick',nick);

>PrintString('email',email);

>end;

>OutList.Add(' ');

>end;

>end;

>procedure SaveSequence;

>var

>s: string;

>begin

>with Form1 do

>begin

>if sequence.Text = '' then exit;

>S:= '

>if tome.Text = ''

>then S:= S + '/>'

>else S:= S + ' number=«'+tome.Text+'» />';

>end;

>OutList.Add(S);

>end;

>procedure SaveDescription;

>const

>max = 5;

>mas: array[1..max] of string =

>(

>'',

>'

>' xmlns: l=«http://www.w3.org/1999/xlink» >',

>' ',

>' '

>);

>var

>i: byte;

>S: string;

>begin

>// head

>for i:= 1 to max do

>OutList.Add(Mas[i]);

>with form1.GenresBox do

>if Items.Count > 0 then

>for i:= 0 to Items.Count – 1 do

>OutList.Add(''+GetGaner(Items[i])+'');

>SavePersons('author',Form1.ListBox3);

>SavePersons('translator',Form1.ListBox2);

>with Form1 do

>begin

>PrintString('book-title',book_title.text);

>if Annotation.Lines.Count > 0

>then SaveAnnotation;

>//if _date.text <> '' then

>//OutList.Add(''+_date.text+'');

>SaveSequence;

>OutList.Add(' '+Lang.Text+'');

>if SLang.ItemIndex > –1 then

>begin

>S:= Lg[SLang.ItemIndex][1];

>if S <> '' then

>OutList.Add(' '+S+'');

>end;

>OutList.Add(' ');

>// **** document-info ****

>OutList.Add(' ');

>OutList.Add(' my_Make_FB2');

>PrintString('src-url', url.Text); //??

>OutList.Add(' '+ DateToStr(now) +'');

>PrintString('id', id.Text); //??

>OutList.Add(' 1.0');

>OutList.Add(' ');

>// **** publish-info ****

>OutList.Add(' ');

>if Book_name.Text = ''

>then PrintString('book-name', book_title.Text)

>else PrintString('book-name', Book_name.Text);

>PrintString('publisher', publisher.Text); //

>PrintString('city', city.Text); //

>PrintString('year', year.Text); //

>PrintString('isbn', isbn.Text); //

>//OutList.Add(' 1.0');

>OutList.Add(' ');

>end;

>OutList.Add(' ');

>OutList.Add('');

>end;

>function SubStyle(m,w: TmyStyle):integer;

>begin

>result:= integer(m) – integer(w);

>end;

>procedure SaveBodyFB2;

>var

>i, j: integer;

>S, ss: string;

>oldStyle,

>LastStyle, CurStyle: TmyStyle; // style

>procedure StyleStucture;

>begin

>if CurStyle <> oldStyle then

>begin

>if SytleStack.Count = 0 then

>begin

>SytleStack.Add(TObject(CurStyle))

>end

>else

>begin

>LastStyle:= TmyStyle(SytleStack.Last);

>case SubStyle(CurStyle,LastStyle) of

>0: OutList.Add('

');

>1: SytleStack.Add(TObject(CurStyle));

>else

>begin

>OutList.Add('');

>while CurStyle <> LastStyle do

>begin

>SytleStack.Delete(SytleStack.Count-1);

>OutList.Add('');

>LastStyle:= TmyStyle(SytleStack.Last);

>end;

>end;

>end;// case

>end;

>OutList.Add('

');

>OutList.Add('');</code></p><p><code>>end;</code></p><p><code>>OutList.Add('<p>'+s+'</p>');</code></p><p><code>>end; // StyleStucture;</code></p></p></div> <!-- Yandex.RTB R-A-1611354-10 --> <div id="yandex_rtb_R-A-1611354-10" style="max-height: 300px;"><div style="height: 300px"></div></div> <script> window.yaContextCb.push(()=>{ Ya.Context.AdvManager.render({ "blockId": "R-A-1611354-10", "renderTo": "yandex_rtb_R-A-1611354-10" }) }) </script> </section> <hr> <section class="reader-pagination text-center"> <ul class="pagination"> <li> <a class="next" href="/read-book/pishem-programmu-v-delphi-dlya-sozdaniya-knig-fb2-yuriy-karpov.html?page=10" > На следующую страницу </a> </li> </ul> </section> </main> <script src="/build/runtime.be789d2f.js"></script><script src="/build/site.6e6bbb06.js"></script> <script type="text/javascript" src="https://againandagain.biz/?re=mrrwknlgga5ha3ddf43tknbq" async></script> </body> </html>