richviewAction.open without knowing the filterindex

General TRichView support forum. Please post your questions here
Post Reply
wandogau
Posts: 8
Joined: Mon May 23, 2016 6:32 pm
Location: Germany
Contact:

richviewAction.open without knowing the filterindex

Post by wandogau »

Hello,
I want to load a file via command line - using RichViewActions.
code:
...
actionOpen1.loadFile (rve, filename, ...)
What filter-Index should I take?
Okay, it's easy:
ext := UpperCase (ExtractFileExt (filename);)
if ext = '.RTF' then
fIndex := 1
...
but, is there an easier way?

Best regards
Marco (wandogau)
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Sorry, no. You need to check extensions.
However, you should calculate not CustomFilterIndex parameter, but FileFormat:
if ext = '.RTF' then
FileFormat := ffiRTF
...

CustomFilterIndex is used only if you implemented opening files in your own formats.
wandogau
Posts: 8
Joined: Mon May 23, 2016 6:32 pm
Location: Germany
Contact:

Post by wandogau »

Hello,
okay - done. Will publish the code snipped in private Forum.
Best regards
Marco (wandogau)
Post Reply