ActionTest demo->load document -> List index out of b

General TRichView support forum. Please post your questions here
Post Reply
starhu
Posts: 49
Joined: Fri Jan 17, 2014 6:33 pm

ActionTest demo->load document -> List index out of b

Post by starhu »

Hello,

I need to use the ActionTest demo project as a base for the application (with multi tabbed documents).


I wanted to load an existing document. I used the following approaches but all gave the error: "List index out of bounds -1"

Approach 1.

ActiveEditor.RichViewEdit.LoadRVF('j:\Test1.rvf') ;

Approach 2.

ActiveEditor.ActiveEditor.LoadRVF('j:\Test1.rvf') ;

By the way it is very confusing that TSrRichView edit has a property named ActiveEditor and the ActionTest demo project has a variable named ActiveEditor .

Approach 3.

SRichViewEdit.ActiveEditor.LoadRVF.LoadRVF('j:\Test1.rvf') ;

Can you help me? Thank you in advance
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

1.
The correct way:

Code: Select all

ActiveEditor.RichViewEdit.LoadRVF('j:\Test1.rvf') ; 
ActiveEditor.Format;
I believe an exception happens because you do not call format.

2.
If you want using New, Open, Save and SaveAs actions, you must load files using TrvActionOpen1.LoadFile method:

Code: Select all

rvActionOpen1.LoadFile(ActiveEditor.RichViewEdit, 'j:\Test1.rvf', ffiRVF);
Otherwise the editor would not be associated with this file.
starhu
Posts: 49
Joined: Fri Jan 17, 2014 6:33 pm

Post by starhu »

Hello,

Thank you for your help. I tried it. It loads the file but it has a big problem:

1. I load the first file, let's say 'Apple.rvf'. It loads well.

2.I load the second file, 'Pear.rvf'. It loads on the second tab, but meanwhile the first tab changes from Apple.rvf to Pear.rvf !
So I have 2 tabs with Pear.rvf.

3.I load the third file, 'Cherry.rvf'. It loads on the third tab, but meanwhile the first tab and the second tab changes to Cherry.rvf.
So I have 3 tabs with Cherry.rvf.

etc.

Thank you very much
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

RichViewActions do not include code for tab management.
In our demos (such as ActionTestTab) all the code related to adding, renaming and closing tabs is placed in the main form unit.
I believe you used it as a base, but some mistake happened when you copied this code to your application.
If it's possible to reproduce it in a simple project, send it to me by email.
starhu
Posts: 49
Joined: Fri Jan 17, 2014 6:33 pm

Post by starhu »

"I believe you used it as a base, but some mistake happened when you copied this code to your application. "

Your were right, thank you!
Post Reply