SIL Editor ExportTo automation method

All announcements, questions and issues related to the TsiLang Components Suite.
Post Reply
jsweby
Posts: 32
Joined: Wed May 21, 2008 3:07 pm

SIL Editor ExportTo automation method

Post by jsweby »

Using automation I can export a SIL file to a SIB file:

Code: Select all

    FIntf := CreateOleObject('SILEditor.SilEditorIntf');
    try
      FIntf.EditFile(SILFILENAME, 'Captions', False);
      FIntf.ExportTo(SIBFILENAME, etSIB);    
    finally
      FIntf := UnAssigned;
    end;
Can a SIB file be exported to an SIL file using automation? In the SIL Editor itself, SIL appears as an option when exporting manually.

If not, is there any other way of performing this automatically?
Carval Computing Limited
Payroll - HR - T&A
carval.co.uk
isiticov
Site Admin
Posts: 2383
Joined: Thu Nov 21, 2002 3:17 pm

Re: SIL Editor ExportTo automation method

Post by isiticov »

Just use the same code:

Code: Select all

    FIntf := CreateOleObject('SILEditor.SilEditorIntf');
    try
      FIntf.EditFile([b]SIBFILENAME[/b], 'Captions', False);
      FIntf.ExportTo([b]SILFILENAME[/b], etSIB);    
    finally
      FIntf := UnAssigned;
    end;
Actually, etSIB is incorrectly declared. :( It must be etTsiLang which "tells" SIL Editor to perform the conversion from one format to another.
Best regards,
Igor Siticov.
jsweby
Posts: 32
Joined: Wed May 21, 2008 3:07 pm

Post by jsweby »

Hi.

Do you mean like this:

Code: Select all

FIntf := CreateOleObject('SILEditor.SilEditorIntf');
    try
      FIntf.EditFile(SIBFILENAME, 'Captions', False);
      FIntf.ExportTo(SILFILENAME, etTsiLang);
    finally
      FIntf := UnAssigned;
    end;
because this produces a compiler error:

undeclared identifier 'etTsiLang'

Which is what I get if I try using etSIL to go from a SIB to a SIL:

Code: Select all

FIntf := CreateOleObject('SILEditor.SilEditorIntf');
    try
      FIntf.EditFile(SIBFILENAME, 'Captions', False);
      FIntf.ExportTo(SILFILENAME, etSIL);
    finally
      FIntf := UnAssigned;
    end;
undeclared identifier 'etSIL'

Using v5.0.0.2 of the TsiLangFiles Editor, with v6.3 TsiLang Components Suite. The type library produced imported from SILEditor.exe only declares these types:

Code: Select all

// Constants for enum TExportType
type
  TExportType = TOleEnum;
const
  etCSV = $00000000;
  etHTML = $00000001;
  etDOC = $00000002;
  etXLS = $00000003;
  etSIB = $00000004;
  etXML = $00000005;
i.e. no etSIL or etTsiLang.
Carval Computing Limited
Payroll - HR - T&A
carval.co.uk
isiticov
Site Admin
Posts: 2383
Joined: Thu Nov 21, 2002 3:17 pm

Post by isiticov »

No, I mean to use exactly etSIB when exporting to SIL file too. It is just incorrectly declared in our code for SIL Editor type library.
Best regards,
Igor Siticov.
jsweby
Posts: 32
Joined: Wed May 21, 2008 3:07 pm

Post by jsweby »

OK thanks. I re-read your post after I posted, and realised that is probably what you meant.

Unfortunately, I can't seem to export from a SIB file at all. The code I gave above for exporting a SIL file to a SIB file works fine every time. In fact, exporting from a SIL file to any other format works using the automation method.

However, given a SIB file, the ExportTo method simply does nothing, no matter which export type I choose. The call to EditFile() correctly opens the SIB file in SIL Editor, but the next line just does nothing. I have tried etSIB, etHTML, etXLS and etCSV with no resulting file.

Any ideas? Thank you.
Carval Computing Limited
Payroll - HR - T&A
carval.co.uk
isiticov
Site Admin
Posts: 2383
Joined: Thu Nov 21, 2002 3:17 pm

Post by isiticov »

The following code works just fine:

Code: Select all

procedure TForm1.TntButton1Click(Sender: TObject);
var
   FIntf: Variant;
begin
  FIntf := CreateOleObject('SILEditor.SilEditorIntf');
    try
      FIntf.EditFile(Edit1.Text, 'Captions', False);
      FIntf.ExportTo(Edit2.Text, 4);
    finally
      FIntf := UnAssigned;
    end;
end;
Except there will be a prompt for a Delimiter for SIL file.
Best regards,
Igor Siticov.
jsweby
Posts: 32
Joined: Wed May 21, 2008 3:07 pm

Post by jsweby »

From what I can tell, that is exactly the same as:

Code: Select all

procedure TForm1.TntButton1Click(Sender: TObject); 
var 
   FIntf: Variant; 
begin 
  FIntf := CreateOleObject('SILEditor.SilEditorIntf'); 
    try 
      FIntf.EditFile(Edit1.Text, 'Captions', False); 
      FIntf.ExportTo(Edit2.Text, etSIB); 
    finally 
      FIntf := UnAssigned; 
    end; 
end; 
I tried it and it behaved the same, just did nothing. No file is created.
Carval Computing Limited
Payroll - HR - T&A
carval.co.uk
jsweby
Posts: 32
Joined: Wed May 21, 2008 3:07 pm

Post by jsweby »

If anyone is interested, Igor has made a new version of the SIL Editor available (v5.0.0.3) which corrects this:
Igor Siticov wrote:Please try to download updated version of SIL Editor from our site. We've found small piece of code that might cause such behavior and fixed it.
The only thing is that converting a SIB to a SIL, although it now works, asks for the delimiter to be entrered. SIL to SIB doesn't ask.
Carval Computing Limited
Payroll - HR - T&A
carval.co.uk
jsweby
Posts: 32
Joined: Wed May 21, 2008 3:07 pm

Post by jsweby »

Igor Siticov wrote:We will update SIL Editor to don't ask for delimiter when used from COM
v5.0.0.4 of SILEditor.exe provides this functionality. However, now the delimiter returns to the default ~!@#, which isn't the delimiter I had originally specified.
Carval Computing Limited
Payroll - HR - T&A
carval.co.uk
isiticov
Site Admin
Posts: 2383
Joined: Thu Nov 21, 2002 3:17 pm

Post by isiticov »

When exporting to SIL from SIB using COM service SIL Editor doesn't ask for delimiter and as result it uses the default one.
Best regards,
Igor Siticov.
Post Reply