Permalink
Browse files

ToStr

  • Loading branch information...
vrybant committed Oct 16, 2018
1 parent 3ddd7d5 commit a9601f6a4b29c7a1eab6400dd444ecf7a7c8dc05
Showing with 50 additions and 35 deletions.
  1. +11 −6 unitlib.pas
  2. +19 −8 unitmain.pas
  3. +16 −17 unitshelf.pas
  4. +2 −2 unitstream.pas
  5. +2 −2 unittitles.pas
View
@@ -33,8 +33,9 @@ function IsNumeral(c: char): boolean;
function IsLetter(c: char): boolean;
function Prefix(ps, st: string): boolean;
function OneUpCase(st: string): string;
function MyStrToInt(s: string): integer;
function StrToBoolean(s: string): boolean;
function ToInt(s: string): integer;
function ToBoolean(s: string): boolean;
function ToStr(value: longint): string;
function CleanString(s: string): string;
function StringPos(subst: string; s: string): TIntegerArray;
procedure Replace(var s: string; const oldPattern, newPattern: String);
@@ -106,21 +107,25 @@ function OneUpCase(st: string): string;
Result := st;
end;
function MyStrToInt(s: string): integer;
function ToInt(s: string): integer;
var v, r : integer;
begin
s := Trim(s);
Val(s, v, r);
if r=0 then Result := v else Result := 0;
end;
function StrToBoolean(s: string): boolean;
function ToBoolean(s: string): boolean;
var v : boolean;
begin
Result := false;
if TryStrToBool(s,v) then Result := v;
end;
function ToStr(value: longint): string;
begin
System.Str(value, Result);
end ;
function CleanString(s: string): string;
var i: integer;
begin
@@ -414,7 +419,7 @@ procedure Output(s: string);
procedure Output(n: integer);
begin
Output(IntToStr(n));
Output(ToStr(n));
end;
initialization
View
@@ -213,6 +213,7 @@ TMainForm = class(TForm)
procedure LoadCompare;
procedure LoadTranslate(Verse: TVerse);
procedure LoadCommentary;
procedure LoadFootnote(s: string);
procedure MakeBookList;
procedure MakeChapterList(n: integer);
{$ifdef darwin} procedure ScrollBoxes; {$endif}
@@ -611,7 +612,7 @@ procedure TMainForm.CmdInterline(Sender: TObject);
begin
if not (ActiveVerse.book in [1..66]) then Exit;
s := BibleHubArray[ActiveVerse.book];
s := s + '/' + IntToStr(ActiveVerse.chapter) + '-' + IntToStr(ActiveVerse.number) + '.htm';
s := s + '/' + ToStr(ActiveVerse.chapter) + '-' + ToStr(ActiveVerse.number) + '.htm';
OpenURL('http://biblehub.com/interlinear/' + s);
end;
@@ -756,10 +757,9 @@ procedure TMainForm.MemoMouseUp(Sender: TObject; Button: TMouseButton; Shift: TS
ActiveVerse.Number := MemoBible.ParagraphStart;
ActiveVerse.Count := MemoBible.ParagraphCount;
if FormTranslate.Visible then LoadTranslate(ActiveVerse);
Exit;
end;
if Memo.hyperlink = '' then Exit;
if Memo.Foreground = fgLink then
begin
Verse := Bible.SrtToVerse(Memo.hyperlink);
@@ -773,7 +773,7 @@ procedure TMainForm.MemoMouseUp(Sender: TObject; Button: TMouseButton; Shift: TS
end;
if Memo.Foreground = fgStrong then FormInfo.ShowModal;
if Memo.Foreground = fgFootnote then FormInfo.ShowModal;
if Memo.Foreground = fgFootnote then LoadFootnote(Memo.Hyperlink);
end;
procedure TMainForm.MemoAttrChange(Sender: TObject);
@@ -1260,7 +1260,7 @@ procedure TMainForm.MakeChapterList(n: integer);
ChapterBox.Items.BeginUpdate;
ChapterBox.Items.Clear;
for i := 1 to n do ChapterBox.Items.Add(IntToStr(i));
for i := 1 to n do ChapterBox.Items.Add(ToStr(i));
{$ifdef darwin} if n = 1 then ChapterBox.Items.Add(''); {$endif}
ChapterBox.ItemIndex := 0;
@@ -1330,7 +1330,7 @@ procedure TMainForm.SearchText(s: string);
MemoSearch.LoadRichText(Stream);
Cursor := crArrow;
SelectPage(apSearch);
UpdateStatus(IntToStr(Count) + ' ' + ms_found);
UpdateStatus(ToStr(Count) + ' ' + ms_found);
Stream.Free;
end;
@@ -1373,6 +1373,17 @@ procedure TMainForm.LoadCommentary;
Stream.Free;
end;
procedure TMainForm.LoadFootnote(s: string);
var
Stream : TRichStream;
begin
Stream := TRichStream.Create;
Load_Footnote(Stream, s);
FormInfo.Memo.LoadRichText(Stream);
FormInfo.ShowModal;
Stream.Free;
end;
{$ifdef windows}
procedure TMainForm.VersesToClipboard;
var
@@ -1461,7 +1472,7 @@ procedure TMainForm.SaveIniFile;
IniFile.WriteInteger('Recent', 'Count', RecentList.Count);
for i := 0 to RecentList.Count - 1 do
IniFile.WriteString('Recent', 'File_' + IntToStr(i), RecentList[i]);
IniFile.WriteString('Recent', 'File_' + ToStr(i), RecentList[i]);
IniFile.Free;
end;
@@ -1509,7 +1520,7 @@ procedure TMainForm.ReadIniFile;
Max := IniFile.ReadInteger('Recent', 'Count', RecentList.Count);
for i := 0 to Max - 1 do
RecentList.Add(IniFile.ReadString('Recent', 'File_' + IntToStr(i), ''));
RecentList.Add(IniFile.ReadString('Recent', 'File_' + ToStr(i), ''));
Shelf.SetCurrent(BibleFile);
View
@@ -262,7 +262,7 @@ procedure TBible.LoadDatabase;
Book := TBook.Create;
n := DecodeID(format, x);
Book.number := n;
Book.title := IntToStr(x);
Book.title := ToStr(x);
Book.id := x;
Book.sorting := SortingIndex(n);
Add(Book);
@@ -357,9 +357,9 @@ function TBible.VerseToStr(verse: TVerse; full: boolean): string;
if full then title := Book.title else title := Book.abbr;
if Pos('.', title) = 0 then title := title + ' ';
Result := title + IntToStr(verse.chapter) + ':' + IntToStr(verse.number);
Result := title + ToStr(verse.chapter) + ':' + ToStr(verse.number);
if (verse.number <> 0) and (verse.count > 1) then
Result := Result + '-' + IntToStr(verse.number + verse.count - 1);
Result := Result + '-' + ToStr(verse.number + verse.count - 1);
end;
function TBible.SrtToVerse(link : string): TVerse;
@@ -389,12 +389,12 @@ function TBible.SrtToVerse(link : string): TVerse;
begin
p := Copy(s,n+1,255);
s := Copy(s,1,n-1);
endVerse := MyStrToInt(p);
endVerse := ToInt(p);
end;
n := Pos(':',s); Result.book := Items[i].number;
p := Copy(s,1,n-1); Result.chapter := MyStrToInt(p);
p := Copy(s,n+1,255); Result.number := MyStrToInt(p);
p := Copy(s,1,n-1); Result.chapter := ToInt(p);
p := Copy(s,n+1,255); Result.number := ToInt(p);
if endVerse > 0 then
Result.count := endVerse - Result.number + 1;
@@ -425,8 +425,8 @@ function TBible.GetChapter(Verse: TVerse): TStringArray;
SetLength(Result,0);
index := EncodeID(format, Verse.book);
id := IntToStr(index);
chapter := IntToStr(Verse.chapter);
id := ToStr(index);
chapter := ToStr(Verse.chapter);
try
try
@@ -454,18 +454,17 @@ function TBible.GetChapter(Verse: TVerse): TStringArray;
function TBible.GetRange(Verse: TVerse): TStringArray;
var
index, i : integer;
id, chapter : string;
verseNumber, toVerse : string;
line : string;
i : integer;
begin
SetLength(Result,0);
index := EncodeID(format, Verse.book);
id := IntToStr(index);
chapter := IntToStr(Verse.chapter);
verseNumber := IntToStr(Verse.number);
toVerse := IntToStr(verse.number + verse.count);
id := ToStr(EncodeID(format, Verse.book));
chapter := ToStr(Verse.chapter);
verseNumber := ToStr(Verse.number);
toVerse := ToStr(verse.number + verse.count);
try
try
@@ -526,8 +525,8 @@ function TBible.Search(searchString: string; SearchOptions: TSearchOptions; Rang
if Range.from > 0 then
begin
from := IntToStr(EncodeID(format, Range.from));
till := IntToStr(EncodeID(format, Range.till));
from := ToStr(EncodeID(format, Range.from));
till := ToStr(EncodeID(format, Range.till));
queryRange := ' AND ' + z.book + ' >= ' + from + ' AND ' + z.book + ' <= ' + till;
end;
@@ -609,7 +608,7 @@ function TBible.ChaptersCount(Verse: TVerse): integer;
Result := 1;
index := EncodeID(format, Verse.book);
id := IntToStr(index);
id := ToStr(index);
try
try
View
@@ -35,7 +35,7 @@ function Utf8ToRTF(const s: string): string;
unicode := UTF8CharacterToUnicode(p,CharLen);
if unicode = 0 then Continue;
if unicode < $80 then Result := Result + char(unicode)
else Result := Result + '\u' + IntToStr(unicode) + endchar;
else Result := Result + '\u' + ToStr(unicode) + endchar;
inc(p,CharLen);
until (CharLen=0) or (unicode=0);
@@ -61,7 +61,7 @@ procedure TRichStream.Open;
WriteLn('}');
Write('\f0\cf1');
Write('\fs' + IntToStr(CurrFont.Size * 2));
Write('\fs' + ToStr(CurrFont.Size * 2));
if RightToLeft then WriteLn('\rtlpar\qr');
WriteLn(''); // important
View
@@ -101,7 +101,7 @@ function TTitles.GetTitleEx(n: integer; abbreviation: boolean): string;
try
try
Query.SQL.Text := 'SELECT * FROM Books WHERE Number=' + IntToStr(n);
Query.SQL.Text := 'SELECT * FROM Books WHERE Number=' + ToStr(n);
Query.Open;
try name := Query.FieldByName('Name').AsString; except end;
@@ -111,7 +111,7 @@ function TTitles.GetTitleEx(n: integer; abbreviation: boolean): string;
end;
finally
Query.Close;
if name = '' then name := IntToStr(n);
if name = '' then name := ToStr(n);
if abbr = '' then abbr := name;
end;

0 comments on commit a9601f6

Please sign in to comment.