trichview.com

trichview.support




Re: AllUpercase procedure


Return to index


Author

Message

Sergey Tkachenko

Posted: 08/16/2002 0:55:37


Hi,


You should not use methods of editor (such as InsertText, ApplyTextStyle)

together with direct text modification (assigning to Items[i], calling

DeleteItems).

Such mixing is a great source of problems.

Direct modification (methods of viewer) can be used after Clear or

ClearUndo - before calling any method of editor.


DeleteItems must work: change the main cycle to

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

and remove code for inserting.


For inserting items I recommend to use here InsertRVFFromStream.




> hi!

>

> I got it all running to replace my "variables" with your given

> AllUpercase procedure but have still one big problem:

>

> I need to delete the old item after used "InsertString" to insert two

> new items.

> I can set RVData.Items[i] := ''; but that only sets empty text, the item

> still exists.

> So I tried to to call RVData.DeleteItems(i, 1); before I use

> InsertString() but that doesn't work. See my (pseudo-code) I use for

> this and tell me what am I doing wrong here?

>

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

>      begin

>        x := RVData.GetItemStyle(i);

>        if x>=0 then

>        begin // this is a text item

>          s := RVData.Items[i];

>          if LowerCase(trim(S)) = '[#MYVAR#]' then

>          begin

>            RVData.Items[i] := '';

>            if Trim(Item.Themes) = '' then

>            begin

>              //

>            end else

>            begin

>              Offs := RVD.GetOffsBeforeItem(i);

>              RVD.SetSelectionBounds(i,Offs,i,Offs);

>              Buffer := RVD.CurTextStyleNo;

>              try

>                Str := TStringList.Create;

>                Str.Text := Item.Themes;

>                for k:=0 to Str.Count-1 do

>                begin

>                  try

>                    RVD.InsertString('TEST');

>                    if k < Str.count-1 then

>                    begin

>                      RVD.ApplyTextStyle(0);

>                      RVD.InsertText(#32 + '|' + #32);

>                      RVD.ApplyTextStyle(Buffer);

>                    end;

>                  except //

>                  end;

>                end;

>              finally

>                if Assigned(Str) then Str.Free;

>              end;

>             // Rvd.DeleteItems(i + k + 1, 1);

>              //

>            end;

>          end;

>        end else if x=rvsTable then

>        begin

>          table := TRVTableItemInfo(RVData.GetItem(i));

>          for r := 0 to table.Rows.Count-1 do

>            for c := 0 to table.Rows[r].Count-1 do

>              if table.Cells[r,c]<>nil then

>                ReplaceSeeAlso(table.Cells[r,c].GetRVData);

>        end;

>      end;

>

> thanks,

> Alex

>





Powered by ABC Amber Outlook Express Converter