TextConverter methods and properties provide the ability to access different TextConverter objects and their data to modify TextConverter's default behavior. The methods and properties can be referenced from the script by the "this" keyword: this.MethodName. The Script editor conveniently shows all object methods when a period is placed after "this" (pictured below). Once the hint list appears, the method or property name can be typed in either manually or selected from the list.
Click a method below for an explanation:
Most methods can be used strictly in the context methods, which are called on a per-input-record basis (OnRecord, OnRecordDone). The only exception is IsRunning method, which can be called in any context method. PropertiesappendThis property provides access to TextConverters output option. Append is boolean. When Append is true, TextConverter will append the existing output file or table or attempt to create the output file or table if it does not exist. When append is false, TextConverter will always attempt to create the output file or table. You can read or update this property.
bufferBuffer related methods and functions are grouped under this object. In the functions section below see AddRecord, Flush, GetCount, GetField, and GetRecord.
Buffer supports an auto-fill mode. Input records are placed in the buffer automatically in this mode (up to the ‘Buffer size’ property). When the buffer is full it works as a FIFO queue. When ‘auto buffer’ mode is OFF buffer’s behavior/size is controlled by the GetField method which allows scrolling to a buffer’s record and getting a field value in a single operation. The buffer command syntax found in previous versions (AddToBuffer...) does not work in the current version of TextConverter. In order to have an error-free operation, make sure to change any of the older buffer methods to the new group method. DictInThis property provides access to the input fields. The input field values are automatically initialized by TextConverter for each new input record. You may want to retrieve the input field values in your script in order to customize field delimiter recognition or to modify the calculation of output fields. (See samples and walkthroughs for more information)
Function OnRecord DictOutThis property provides access to the output fields. All connected output fields are assigned values from the corresponding input fields automatically by TextConverter for each new input record. You can make any customization to the output values through DictOut. (See samples and walkthroughs to learn more) You can select an output field from the list which appears when you type in DictOut. Each output field has a single property value, which you can set or get. VB sampleFunction OnRecord DSoutDSout related properties, methods, and functions are grouped under this object. These methods relate directly to the output dictionary (internal data source). These methods cannot be used to modify or use an external data source (use "DB." to for a lit of methods to modify external sources). Examples:
You can set output table using two methods: setting the table name (assuming you are connected to a database) - (a) and setting the entire data source - (b): If you
are writing script outside TextConverter the API looks like this: DS.table = "tablename" ) ‘- (a) DS.SetDS( "c:\data\output.dbf" ) ‘- (b)
If you are writing script inside TextConverter it looks like this: This.DSOut.table = "tablename" ) ‘- (a) This.DSOut.SetDS( "c:\data\output.dbf" ) ‘- (b)
An Excel file is also considered as a database, so you can set the worksheet as: Set DS = TextConverter.GetOutputDS() DS.table = "worksheetname" ) ‘- (a) DS.SetDS( "...\file.mdb:worksheetname" ) ‘- (b)
MethodsSkipRecordCall this method from your implementation of the OnRecord context methods to indicate that the current output record should not be inserted into the output database table. This function is usually used with a heterogeneous input text when multi-level information should be filtered out in order to insert only a specific level into the output database. (See samples and walkthroughs for more information) Function SkipRecord() Function OnRecord GetValueByTagUse GetValueByTag when the input fields are marked by tags and are not separated by constant delimiters. After the input value is retrieved, it can be assigned to an arbitrary output field. Function GetValueByTag( tag, delimiter(optional), start(optional) ) You could handle an input like this: Author="Aberer, Karl", with the following script: Function OnRecord GetVarThis method can only be implemented in TextConverter Developer (not in TextConverter Standard). Call this function to set the variable both in and out of TextConverter in automation (API). Function GetVar() set crt = cnv.GetVar ("crt") GoNextCall this function to move through the records of the selected database. Function GoNext() If IsSSN(c) Then CancelCall this function to stop the conversion procedure. No output records will be appended to the output database table after you call this method. Function Cancel() Function OnRecordDone( ok ) FStrGetCall this function to receive extended information about a string. Can be used in conjunction with IsFontBold and IsFontItalic. Function FStrGet(rec_num, from_pos, to_pos)
Function OnRecord CloseOutputDSCall this function to close the output data source. It can be used when a data source needs to be closed after appending. This function can only be used in the OnFinishProcess part of the script. Function CloseOutputDS() Function OnFinish GetInputFieldsUse this function to grab input fields names to insert into an output field. Function GetInputFields() Function OnRecord IsRunningThe function is helpful if some portions of your script should run in the real mode only, not in the preview mode. The Preview mode is run when any change is made to your setup if preview auto update option is turned on. Real mode is executed when you press the Run button (
Function IsRunning() Create a proxy database table only in the real mode. Function OnStartProcess( ok ) System buffer management methods (Advanced)Sometimes it is not enough to operate on a per record basis. Let's assume that your input text consists of the following text areas: 219434342 GASKET SET 123.35 3 370.05 19980301 19980630 SUBTOTAL ENGINE PARTS 22 2,446.88 987293744 TORSION BAR 218.50 2 437.00 19980427 19981010 SUBTOTAL SUSPENSION 9 3,139.25 and we would like to merge the subtotal information for each group into each detailed record. The methods, which accumulate, query and extract the data from the system buffer can facilitate the task.
1. Function OnRecord AddToBufferAddToBuffer adds the current input record to the system buffer. Function AddToBuffer() (See the sample for System buffer management methods ) GetBufferCountReturns the number of input records in the system buffer. Function GetBufferCount() (See the sample for System buffer management methods.) GetFromBufferFetches an input record from the system buffer using its index and initializes the input fields of the DictIn object. You can consider the fetched record to be the current input record. Function GetFromBuffer(index) (See the sample for System buffer management methods.) FlushBufferFlushes the content of the system buffer to get it ready for another cycle of record accumulation. Function FlushBuffer() (See the sample for System buffer management methods.) AppendStartPrepares for a record insertion into the output database table. Useful for splitting an input record into several output records or for simply generating a new output record. You must finish the process with AppendRecord (below) Function AppendStart() Function OnRecord this.AppendStart DictOut.Field1.value = val1 DictOut.Field2.value = val2 DictOut.Field3.value = val3 this.AppendRecord End Function 'Example 2 '----------------- OnStartProcess ----------------- Function OnStartProcess 'creates header record this.AppendStart DictOut.Field_1.value = "HEADER RECORD" 'literal value can be anything this.AppendRecord End Function
AppendRecordInserts the current output record into the output database table. Returns the unique identifier for the record if such supported by the underlying database system. Function AppendRecord( get_id(optional) ) Function OnRecord this.AppendStart DictOut.Field1.value = val1 DictOut.Field2.value = val2 DictOut.Field3.value = val3 this.AppendRecord End Function 'Example 2 '----------------- OnFinishProcess -----------------
Function OnFinishProcess 'creates footer this.AppendStart For i = 1 to dictout.GetFieldCount(): Dictout.SetFieldValue i, Empty: Next ' clears the fields of prior data DictOut.Field_1.value = "FOOTER RECORD" ' insets leteral but could be variable this.AppendRecord this.AppendStart 'creates empty line For i = 1 to dictout.GetFieldCount(): Dictout.SetFieldValue i, Empty: Next ' clears the fields of prior data this.AppendRecord End Function
GetInputFileInserts the current input data source file name into the output database table. Function GetInputFile() Function OnRecord GetOutputFieldsUse this function to grab output fields names to insert into an output field. Function GetOutputFields() Function OnRecord GetPageNumberInserts the page number from which the record was obtained into the output. Function GetPageNumber() Function OnRecord GetRecordNumberCalls on the record number to use as part of a function. Function GetRecordNumber() Function OnRecord IsDelimitedWhen using automatic extraction and the "Show all lines" option, IsDelimited separates records extracted by implied delimiters from other text data in the document. The main distinction between the lines suppressed by default (or shown with the "Show all lines" option) and the rest of the document is that for the rest of the document TextConverter's AI was able to identify implied delimiters. This function separates the data that IsDelimited from the data that is not. The example script will use SkipRecord to keep the non-delimited records from the automated extraction. You can then extract those records manually. Function IsDelimited() Function OnRecord SetInputFileDefines the input file if processing multiple documents. Can only be called when using OnSetUp (or through the API). Do not SetInputFile OnStartProcess as the results may be inconsistent. Function SetInputFile() Function OnSetUp Related Sections |