trichview.com

trichview.support




Re: text file


Return to index


Author

Message

dca

Posted: 12/12/2002 17:45:07


thank you for the program you send me..


but I've still got a few questions.


1. Everything that is between \B\    TEST   \B\

    nameley TEST will be converted in bold. I don't want only this  that is

on that line.


2. It doesn't go to the end of my file, if I put many \B\ in my program it

will not take each line.

If a \B\ is found in one line he will create 2 other lines so my counter 'i'

will be increased without changing from lines.


thanks again for the program

dominick

"Yernar" <[email protected]> schreef in bericht

news:[email protected]...

>

> Thank you, I've received your mail.

> Maybe that's what you need (of course, it's not perfect, but I hope it

will

> be enough in your case):

>

> const

>   MAKEBOLD = 1;

>

> procedure TForm1.MakeItBold(RVData: TCustomRVData);

> var

>   i, r, c: Integer;

>   table: TRVTableItemInfo;

>   function StrIPos(const s1, s2: string; pos, max: Integer): Integer;

>   var

>     s, l1, l2, j: Integer;

>   begin

>     Result := -1;

>     l1 := Length(s1);

>     l2 := Length(s2);

>     if max <= 0 then

>       max := l2;

>     if pos < 0 then

>       pos := 0;

>     if (l1 <= 0) or (pos > max) then

>       Exit;

>     for s := pos to (max - l1) do

>     begin

>       for j := 1 to l2 do

>       begin

>         if (s1[j] <> s2[s + j]) then

>           BREAK;

>         if (j = l1) then

>         begin

>           Result := s;

>           Exit;

>         end;

>       end;

>     end;

>   end;

>   procedure ProcessToBold(ProcessStr: string);

>   var

>     BPos, BPos2: Integer;

>     BoldStr: string;

>   begin

>     BPos := StrIPos('\B\', ProcessStr, 1, Length(ProcessStr));

>     if BPos > 0 then

>     begin

>       BPos2 := StrIPos('\B\', ProcessStr, BPos + 1, Length(ProcessStr));

>       if BPos2 > 0 then

>       begin

>         BoldStr := Copy(ProcessStr, BPos + 4, BPos2 - BPos - 3);

>         RichViewEdit1.SetSelectionBounds(0, 1, 0, 1);

>         while RichViewEdit1.SearchText(BoldStr, [rvseoDown]) do

>           RichViewEdit1.ApplyStyleConversion(MAKEBOLD);

>         RichViewEdit1.Deselect;

>       end;

>     end;

>   end;

> begin

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

>     if RVData.GetItemStyle(i) >= 0 then

>       ProcessToBold(RVData.Items[i]);

> end;

>

> procedure TForm1.RichViewEdit1StyleConversion(Sender: TCustomRichViewEdit;

>   StyleNo, UserData: Integer; AppliedToText: Boolean;

>   var NewStyleNo: Integer);

> var

>   FontInfo: TFontInfo;

> begin

>   FontInfo := TFontInfo.Create(nil);

>   try

>     FontInfo.Assign(RVStyle2.TextStyles[StyleNo]);

>     case UserData of

>       MAKEBOLD:

>         FontInfo.Style := FontInfo.Style + [fsBold]

>     end;

>     NewStyleNo := RVStyle2.TextStyles.FindSuchStyle(StyleNo, FontInfo,

>       RVAllFontInfoProperties);

>     if NewStyleNo = -1 then

>     begin

>       RVStyle2.TextStyles.Add;

>       NewStyleNo := RVStyle2.TextStyles.Count - 1;

>       RVStyle2.TextStyles[NewStyleNo].Assign(FontInfo);

>       RVStyle2.TextStyles[NewStyleNo].Standard := False;

>     end;

>   finally

>     FontInfo.Free;

>   end;

> end;

>

>

> >"dca" <[email protected]> wrote:

> >>hi,

> >>

> >>i hope you can help me with the following question

> >>

> >>question:

> >>I'm reading a textfile in and it has the following characters in

between...

> >>if something is between

> >>/Bthis must be bold/B

> >>

> >>(between 2x /B)

> >>How can I read this textfile in my richtedit so that he will place the

> text

> >>between 2X /B in bold in my tricheditview

> >>

> >>kind regards

> >>dominick

>





Powered by ABC Amber Outlook Express Converter