<!doctype HTML public "-//W3C//DTD HTML 4.0 Frameset//EN">

<html>

<!--(==============================================================)-->
<!--(Document created with RoboEditor. )============================-->
<!--(==============================================================)-->

<head>

<title>VB_to_VT</title>

<!--(Meta)==========================================================-->

<meta http-equiv=content-type content="text/html; charset=windows-1252">
<meta name=generator content="RoboHELP by eHelp Corporation - www.ehelp.com">
<meta name=generator-major-version content=0.1>
<meta name=generator-minor-version content=1>
<meta name=filetype content=kadov>
<meta name=filetype-version content=1>
<meta name=page-count content=1>
<meta name=layout-height content=1259>
<meta name=layout-width content=1027>


<!--(Links)=========================================================-->

<link rel="StyleSheet" href="default.css">



</head>

<!--(Body)==========================================================-->


<body>

<h1>VB_to_VT</h1>

<p>A Visual Basic .NET driver program that demonstrates how to call a VisualText 
 analyzer. <!--kadov_tag{{<spaces>}}-->&nbsp;<!--kadov_tag{{</spaces>}}-->It 
 uses the new VTAPI_VB.dll library built to provide a simple programmer's 
 API to VisualText. <!--kadov_tag{{<spaces>}}-->&nbsp;<!--kadov_tag{{</spaces>}}-->The 
 main code file is repeated here for convenience. <!--kadov_tag{{<spaces>}}-->&nbsp;<!--kadov_tag{{</spaces>}}-->All 
 the API functions are invoked in this sample.</p>

<p style="color: #008080;">'''''''''''''''''''''''''''''''''''''<br>
'VB_TO_VT = Driver to call a VisualText analyzer from a Visual Basic program.<br>
'ASSUMES:<br>
' <!--kadov_tag{{<spaces>}}-->&nbsp;<!--kadov_tag{{</spaces>}}-->Global 
 environment variable APPS = d:\apps<br>
' <!--kadov_tag{{<spaces>}}-->&nbsp;<!--kadov_tag{{</spaces>}}-->Minanalyzer 
 available in d:\apps. <!--kadov_tag{{<spaces>}}-->&nbsp;<!--kadov_tag{{</spaces>}}-->(Copy 
 from c:\Program Files\TextAI\VisualText\apps)<br>
'''''''''''''''''''''''''''''''''''''</p>

<p>Module Module1</p>

<p><!--kadov_tag{{<spaces>}}-->&nbsp;&nbsp;<!--kadov_tag{{</spaces>}}-->Private 
 Declare Function <span style="color: #0000ff;">makeVTRUN_VB</span> Lib 
 &quot;VTAPI_VB.dll&quot; () As Integer<br>
 <!--kadov_tag{{<spaces>}}-->&nbsp;<!--kadov_tag{{</spaces>}}-->Private 
 Declare Function <span style="color: #0000ff;">makeNLP_VB</span> Lib &quot;VTAPI_VB.dll&quot; 
 (ByVal ana As String, ByVal vtrun As Integer) As Integer<br>
 <!--kadov_tag{{<spaces>}}-->&nbsp;<!--kadov_tag{{</spaces>}}-->Private 
 Declare Function <span style="color: #0000ff;">cleanup_VB</span> Lib &quot;VTAPI_VB.dll&quot; 
 (ByVal nlp As Integer, ByVal vtrun As Integer) As Integer<br>
 <!--kadov_tag{{<spaces>}}-->&nbsp;<!--kadov_tag{{</spaces>}}-->Private 
 Declare Function <span style="color: #0000ff;">setbatchstart_VB</span> 
 Lib &quot;VTAPI_VB.dll&quot; (ByVal flag As Boolean, ByVal nlp As Integer) 
 As Integer<br>
 <!--kadov_tag{{<spaces>}}-->&nbsp;<!--kadov_tag{{</spaces>}}-->Private 
 Declare Function <span style="color: #0000ff;">analyzeFile_VB</span> Lib 
 &quot;VTAPI_VB.dll&quot; (ByVal inf As String, ByVal ob As String, ByVal 
 osiz As Integer, ByVal datum As String, ByVal compiled As Boolean, ByVal 
 nlp As Integer) As Integer<br>
 <!--kadov_tag{{<spaces>}}-->&nbsp;<!--kadov_tag{{</spaces>}}-->Private 
 Declare Function <span style="color: #0000ff;">analyzeBuffer_VB</span> 
 Lib &quot;VTAPI_VB.dll&quot; (ByVal ib As String, ByVal ob As String, 
 ByVal osiz As Integer, ByVal datum As String, ByVal compiled As Boolean, 
 ByVal nlp As Integer) As Integer</p>

<p><!--kadov_tag{{<spaces>}}-->&nbsp;&nbsp;&nbsp;<!--kadov_tag{{</spaces>}}-->Sub 
 Main()</p>

<p><!--kadov_tag{{<spaces>}}-->&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #008080;">&nbsp;<!--kadov_tag{{</spaces>}}-->'NAME 
 OF ANALYZER</span><br>
 <!--kadov_tag{{<spaces>}}-->&nbsp;&nbsp;&nbsp;&nbsp;<!--kadov_tag{{</spaces>}}-->Dim 
 analyzerName As String = &quot;minanalyzer&quot;</p>

<p><!--kadov_tag{{<spaces>}}-->&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #008080;">&nbsp;<!--kadov_tag{{</spaces>}}-->'RUNTIME 
 ENVIRONMENT HANDLES.</span><br>
 <!--kadov_tag{{<spaces>}}-->&nbsp;&nbsp;&nbsp;&nbsp;<!--kadov_tag{{</spaces>}}-->Dim 
 vtrun As Integer = 0<br>
 <!--kadov_tag{{<spaces>}}-->&nbsp;&nbsp;&nbsp;&nbsp;<!--kadov_tag{{</spaces>}}-->Dim 
 nlp As Integer = 0</p>

<p><!--kadov_tag{{<spaces>}}-->&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #008080;">&nbsp;<!--kadov_tag{{</spaces>}}-->'SET 
 UP PARAMETERS FOR ANALYZER.</span><br>
 <!--kadov_tag{{<spaces>}}-->&nbsp;&nbsp;&nbsp;&nbsp;<!--kadov_tag{{</spaces>}}-->Dim 
 infile As String = &quot;D:\apps\minanalyzer\input\misc\xyz.txt&quot;<br>
 <!--kadov_tag{{<spaces>}}-->&nbsp;&nbsp;&nbsp;&nbsp;<!--kadov_tag{{</spaces>}}-->Dim 
 inbuf As String = &quot;This is an input buffer&quot;<br>
 <!--kadov_tag{{<spaces>}}-->&nbsp;&nbsp;&nbsp;&nbsp;<!--kadov_tag{{</spaces>}}-->Dim 
 outsiz As Integer = 512<br>
 <!--kadov_tag{{<spaces>}}-->&nbsp;&nbsp;&nbsp;&nbsp;<!--kadov_tag{{</spaces>}}-->Dim 
 outbuf As String = Space(outsiz)<br>
 <!--kadov_tag{{<spaces>}}-->&nbsp;&nbsp;&nbsp;&nbsp;<!--kadov_tag{{</spaces>}}-->Dim 
 datum As String = &quot;Parameters to pass to analyzer&quot;</p>

<p><!--kadov_tag{{<spaces>}}-->&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #008080;">&nbsp;<!--kadov_tag{{</spaces>}}-->'Todo: 
 After you compile the analyzer in VisualText, you can turn on this flag.</span><br>
 <!--kadov_tag{{<spaces>}}-->&nbsp;&nbsp;&nbsp;&nbsp;<!--kadov_tag{{</spaces>}}-->Dim 
 compiled As Boolean = False</p>

<p><!--kadov_tag{{<spaces>}}-->&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #008080;">&nbsp;<!--kadov_tag{{</spaces>}}-->'INITIALIZE 
 VISUALTEXT RUNTIME SYSTEM (Onetime call)<br>
 <!--kadov_tag{{<spaces>}}-->&nbsp;&nbsp;&nbsp;&nbsp;<!--kadov_tag{{</spaces>}}-->'(Handles 
 multiple analyzers)</span><br>
 <!--kadov_tag{{<spaces>}}-->&nbsp;&nbsp;&nbsp;&nbsp;<!--kadov_tag{{</spaces>}}-->vtrun 
 = <span style="color: #0000ff;">makeVTRUN_VB</span>()</p>

<p><!--kadov_tag{{<spaces>}}-->&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #008080;">&nbsp;<!--kadov_tag{{</spaces>}}-->'INITIALIZE 
 CURRENT ANALYZER RUNTIME (Onetime call)</span><br>
 <!--kadov_tag{{<spaces>}}-->&nbsp;&nbsp;&nbsp;&nbsp;<!--kadov_tag{{</spaces>}}-->nlp 
 = <span style="color: #0000ff;">makeNLP_VB</span>(analyzerName, vtrun)</p>

<p><!--kadov_tag{{<spaces>}}-->&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span 
 style="color: #008080;"><!--kadov_tag{{</spaces>}}-->'''''''''''''''''''''''''''''''''''''''''''''''''<br>
 <!--kadov_tag{{<spaces>}}-->&nbsp;&nbsp;&nbsp;&nbsp;<!--kadov_tag{{</spaces>}}-->'Analyzer 
 calls below can be placed into a loop.<br>
 <!--kadov_tag{{<spaces>}}-->&nbsp;&nbsp;&nbsp;&nbsp;<!--kadov_tag{{</spaces>}}-->'''''''''''''''''''''''''''''''''''''''''''''''''</span></p>

<p><!--kadov_tag{{<spaces>}}-->&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span 
 style="color: #008080;"><!--kadov_tag{{</spaces>}}-->'Inform analyzer 
 of first file in a batch.<br>
 <!--kadov_tag{{<spaces>}}-->&nbsp;&nbsp;&nbsp;&nbsp;<!--kadov_tag{{</spaces>}}-->'Note: 
 Analyzer automatically resets flag to false.</span><br>
 <!--kadov_tag{{<spaces>}}-->&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff;"><!--kadov_tag{{</spaces>}}-->setbatchstart_VB</span>(True, 
 nlp)</p>

<p><!--kadov_tag{{<spaces>}}-->&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span 
 style="color: #008080;"><!--kadov_tag{{</spaces>}}-->'RUN ANALYZER ON 
 FILE.</span><br>
 <!--kadov_tag{{<spaces>}}-->&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff;"><!--kadov_tag{{</spaces>}}-->analyzeFile_VB</span>(infile, 
 outbuf, outsiz, datum, compiled, nlp)<br>
 <!--kadov_tag{{<spaces>}}-->&nbsp;&nbsp;&nbsp;&nbsp;<!--kadov_tag{{</spaces>}}-->Console.WriteLine(&quot;outbuf: 
 &quot; &amp; Trim(outbuf))</p>

<p><!--kadov_tag{{<spaces>}}-->&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #008080;">&nbsp;<!--kadov_tag{{</spaces>}}-->'RUN 
 ANALYZER ON BUFFER.</span><br>
 <!--kadov_tag{{<spaces>}}-->&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff;"><!--kadov_tag{{</spaces>}}-->analyzeBuffer_VB</span>(inbuf, 
 outbuf, outsiz, datum, compiled, nlp)<br>
 <!--kadov_tag{{<spaces>}}-->&nbsp;&nbsp;&nbsp;&nbsp;<!--kadov_tag{{</spaces>}}-->Console.WriteLine(&quot;outbuf: 
 &quot; &amp; Trim(outbuf))</p>

<p><!--kadov_tag{{<spaces>}}-->&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #008080;">&nbsp;<!--kadov_tag{{</spaces>}}-->'''''''''''''''''''''''''''''''''''''''''''''''''<br>
 <!--kadov_tag{{<spaces>}}-->&nbsp;&nbsp;&nbsp;&nbsp;<!--kadov_tag{{</spaces>}}-->'CLEAN/DELETE 
 THE RUNTIME ENVIRONMENT (Onetime call)</span><br>
 <!--kadov_tag{{<spaces>}}-->&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff;"><!--kadov_tag{{</spaces>}}-->cleanup_VB</span>(nlp, 
 vtrun)</p>

<p><!--kadov_tag{{<spaces>}}-->&nbsp;&nbsp;&nbsp;<!--kadov_tag{{</spaces>}}-->End 
 Sub<br>
End Module</p>

<p>&nbsp;</p>

</body>

</html>
