Page 1 of 1

SIL Editor ExportTo automation method

Posted: Tue Sep 23, 2008 11:37 am
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?

Re: SIL Editor ExportTo automation method

Posted: Wed Sep 24, 2008 6:21 am
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.

Posted: Wed Sep 24, 2008 9:00 am
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.

Posted: Wed Sep 24, 2008 11:15 am
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.

Posted: Wed Sep 24, 2008 11:21 am
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.

Posted: Wed Sep 24, 2008 12:40 pm
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.

Posted: Wed Sep 24, 2008 12:50 pm
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.

Posted: Tue Sep 30, 2008 11:48 am
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.

Posted: Thu Oct 02, 2008 8:15 am
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.

Posted: Thu Oct 02, 2008 9:29 am
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.