VB Script samples

Script samples demonstrate a way to use the TextConverter component from multiple scripting environments. You can:

- create a simple .vbs file and run it with cscript.exe or wscript.exe

- create a simple web page with your own user interface and use JavaScript to pass data to TextConverter and run conversions

- use TextConverter as a server component for your web application and automate it from an ASP page.

This sample creates an instance of the TextConverter object, loads a project file and runs the conversion.

Dim cnv, path, n_recs
Set cnv = CreateObject( "ConverterX.ConverterX.1" )
path = cnv.GetStartPath()
path = path & "Samples/TextConverter/Manual Mode/1 Well formed input/1.1 Products.ConverterX"
cnv.OpenProject( path )
n_recs = cnv.Convert()
MsgBox n_recs & " records were converted successfully.", vbOKOnly, "TextConverter Sample"

The following sample script creates the TextConverter object, sets the output database table, sets several conversion options, loads an input text file and runs the process.

Dim cnv, path, n_recs, ds
Set cnv = CreateObject( "ConverterX.ConverterX.1" )
path = cnv.GetStartPath()
path = path & "Samples/TextConverter/Manual Mode/1 Well formed input/"
Set ds = cnv.GetOutputDS()
ds.SetDS( path & "1.1 Products.dbf" )
cnv.field_delimiter    = ","
cnv.record_delimiter   = "<LF>"
cnv.names_line         = 1
cnv.skip               = 1
cnv.LoadTextFile path & "1.1 Products.txt", true
n_recs = cnv.Convert()
MsgBox n_recs & " records were converted successfully to the output database table:" & vbLf &_
       path & "Products.dbf", vbOKOnly, "TextConverter Sample"

 

Comments