unit GBFMain; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, Buttons, StdCtrls, ExtCtrls, GBF; const sTitlePar = '\pard\plain \s1\fi432\sb240\sa60\keepn\widctlpar \b\f5\fs28\kerning28 '; sNormalPar = '\pard\plain \fi432\widctlpar \f4 '; sNormalQuotePar = '\pard\plain \s20\fi432\li432\widctlpar \f4 '; sPoetryPar = '\pard\plain \s18\fi-432\li432\widctlpar \f4 '; sPoetryQuotePar = '\pard\plain \s21\fi-432\li864\widctlpar \f4 '; sHebrewTitlePar = '\pard\plain \s16\fi432\keep\keepn\widctlpar \f4\fs20 '; sSelahPar = '\pard\plain \s19\qr\widctlpar \f4 '; ANSI2OEM: array[0..255] of char = ( #0, #1, #2, #3, #4, #5, #6, #7, #8, #9, #10, #11, #12, #13, #14, #15, #16, #17, #18, #19, #20, #21, #22, #23, #24, #25, #26, #27, #28, #29, #30, #31, #32, #33, #34, #35, #36, #37, #38, #39, #40, #41, #42, #43, #44, #45, #46, #47, #48, #49, #50, #51, #52, #53, #54, #55, #56, #57, #58, #59, #60, #61, #62, #63, #64, #65, #66, #67, #68, #69, #70, #71, #72, #73, #74, #75, #76, #77, #78, #79, #80, #81, #82, #83, #84, #85, #86, #87, #88, #89, #90, #91, #92, #93, #94, #95, #96, #97, #98, #99,#100,#101,#102,#103, #104,#105,#106,#107,#108,#109,#110,#111, #112,#113,#114,#115,#116,#117,#118,#119, #120,#121,#122,#123,#124,#125,#126,#127, #128,#129, ',', 'a', '"',#133,#197,#216, '^', '%', 'S', '<',#140,#141,#142,#143, #144, #96, #97, '"', '"',#249,#150,#151, '~',#153, 's', '>',#156,#157,#158, 'Y', ' ',#173,#155,#156,#232,#157,#124, #21, #168,#169, 'a',#174,#170, '-',#174, '_', #167,#241,#253, '3', #39,#230, #20,#254, ',', '1', 'o',#175,#172,#171,#190,#168, 'A', 'A', 'A', 'A',#142,#143,#198,#128, 'E',#144, 'E',#142, 'I', 'I', 'I', 'I', 'D',#165, 'O', 'O', 'O', 'O',#153, 'x', '0', 'U', 'U', 'U',#154, 'Y', 'b',#225, #133,#130,#131, 'a',#132,#134,#230,#135, #138,#130,#136,#137,#141,#161,#140,#139, #148,#164,#149,#162,#147, 'o',#148,#246, 'o',#151,#163,#150,#129, 'y', 'b',#152); type TGBFConverterMainForm = class(TForm) SourceEdit: TEdit; Label1: TLabel; BrowseButton: TButton; SaveDialog1: TSaveDialog; OpenDialog1: TOpenDialog; DestEdit: TEdit; Label2: TLabel; BrowseDestButton: TButton; FormatRadioGroup: TRadioGroup; GoBitBtn: TBitBtn; CloseBitBtn: TBitBtn; Timer1: TTimer; VerseLabel: TLabel; ApocryphaCheckBox: TCheckBox; WdLabel: TLabel; Label3: TLabel; Label4: TLabel; WEBDraftCheckBox: TCheckBox; QuickButton: TButton; procedure CloseBitBtnClick(Sender: TObject); procedure GoBitBtnClick(Sender: TObject); procedure Timer1Timer(Sender: TObject); procedure FormShow(Sender: TObject); procedure FormatRadioGroupClick(Sender: TObject); procedure QuickConversion; procedure DoConversion; procedure QuickButtonClick(Sender: TObject); procedure FormActivate(Sender: TObject); private { Private declarations } public { Public declarations } end; var GBFConverterMainForm: TGBFConverterMainForm; implementation {$R *.DFM} var InFile: TReadGBF; OutGBF: TWriteGBF; OutFile: TextFile; function ANSIToOEM(s: string): string; var i, j: integer; begin Result := s; j := 1; for i := 1 to length(s) do begin case s[i] of #133: begin Result[j] := '.'; inc(j); Insert('..', Result, j); inc(j); end; #140: begin Result[j] := 'O'; inc(j); Insert('E', Result, j); end; #150: begin Result[j] := '-'; inc(j); Insert('-', Result, j); end; #151: begin Result[j] := '-'; inc(j); Insert('-', Result, j); end; #153: begin Result[j] := '('; inc(j); Insert('TM)', Result, j); inc(j,2); end; #156: begin Result[j] := 'o'; inc(j); Insert('e', Result, j); end; #169: begin Result[j] := '('; inc(j); Insert('C)',Result, j); inc(j); end; #174: begin Result[j] := '('; inc(j); Insert('R)',Result, j); inc(j); end; #198: begin Result[j] := 'A'; inc(j); Insert('E', Result, j); end; #230: begin Result[j] := 'a'; inc(j); Insert('e', Result, j); end; else Result[j] := ANSI2OEM[ord(s[i])]; end; inc(j); end; end; procedure TGBFConverterMainForm.CloseBitBtnClick(Sender: TObject); begin Close; end; procedure TGBFConverterMainForm.DoConversion; var LastBook, wd, ParagraphAttributes, s, sLine, sPrint, sSave, OutFileName: string; LinePos, i, iFileNumber: integer; tok: TToken; fInclude, fProse, fSkip, fHTMLisOpen, fRed, fASCIIisOpen: boolean; bLastBook, bChap: byte; procedure CheckEOL; begin if Length(sLine) > 65 then begin i := 65; while (i > 0) and (sLine[i] <> ' ') do dec(i); if i < 1 then begin if fASCIIisOpen then WriteLn(OutFile,sLine); if fProse then sLine := '' else sLine := ' '; end else begin sPrint := system.copy(sLine,1,i-1); if fProse then sSave := system.copy(sLine,i+1,Length(sLine)-i) else sSave := ' '+system.copy(sLine,i+1,Length(sLine)-i); if fASCIIisOpen then WriteLn(OutFile,sPrint); sLine := sSave; end end; end; procedure StartNewLine; begin if fInclude then begin CheckEol; if fASCIIisOpen then WriteLn(OutFile, sLine); sLine := ''; end; end; procedure CloseHTML; begin if fHTMLisOpen then begin WriteLn(OutFile,sLine); sLine := ''; WriteLn(OutFile,'
'); WriteLn(OutFile,'