home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 May / CMCD0504.ISO / Software / Shareware / Comunicatii / pyrobatch / pyrobatchftp.exe / setup.fil / pyrobatchcontrol / vb60demo / pyrobatchcontrol.frm (.txt) next >
Encoding:
Visual Basic Form  |  2002-08-22  |  3.3 KB  |  101 lines

  1. VERSION 5.00
  2. Begin VB.Form PyroBatch 
  3.    Caption         =   "PyroBatch"
  4.    ClientHeight    =   3195
  5.    ClientLeft      =   -165
  6.    ClientTop       =   135
  7.    ClientWidth     =   4680
  8.    LinkTopic       =   "Form1"
  9.    ScaleHeight     =   3195
  10.    ScaleWidth      =   4680
  11.    Begin VB.CommandButton Run 
  12.       Caption         =   "Run PyroBatch Script"
  13.       Height          =   615
  14.       Left            =   240
  15.       TabIndex        =   1
  16.       Top             =   240
  17.       Width           =   3015
  18.    End
  19.    Begin VB.Label Label1 
  20.       Caption         =   "-"
  21.       Height          =   255
  22.       Left            =   240
  23.       TabIndex        =   3
  24.       Top             =   1920
  25.       Width           =   4095
  26.    End
  27.    Begin VB.Label Label0 
  28.       Caption         =   "-"
  29.       Height          =   255
  30.       Left            =   240
  31.       TabIndex        =   2
  32.       Top             =   1440
  33.       Width           =   3975
  34.    End
  35.    Begin VB.Label Label2 
  36.       Caption         =   "Current Command Status:"
  37.       Height          =   255
  38.       Left            =   240
  39.       TabIndex        =   0
  40.       Top             =   1080
  41.       Width           =   2295
  42.    End
  43. Attribute VB_Name = "PyroBatch"
  44. Attribute VB_GlobalNameSpace = False
  45. Attribute VB_Creatable = False
  46. Attribute VB_PredeclaredId = True
  47. Attribute VB_Exposed = False
  48. ' define entry point to pyrobatchcontrol.dll
  49. Private Declare Function PyroBatch Lib "W:\pyrotrans\pyrobatchcontrol\Debug\pyrobatchcontrol.dll" Alias "_PyroBatch@16" (ByVal lpApp As String, ByVal lpBuffer As String, ByVal lpResult As String, ByVal nSize As Long) As Long
  50. Private Sub Run_Click()
  51.     Dim result As String
  52.     Dim rc As Integer
  53.     ' init communication to pyrobatch.exe
  54.     rc = DoControl("START", result)
  55.     If rc >= 200 And rc <= 299 Then ' ok
  56.         rc = DoControl("Connect 'duke', 'test', 'asdf'", result)
  57.         If rc >= 200 And rc <= 299 Then ' ok, now connected
  58.             rc = DoControl("LocalChDir 'd:\t'", result)
  59.             
  60.             rc = DoControl("Get 'new.mdb'", result)
  61.         
  62.             rc = DoControl("Disconnect", result)
  63.         End If
  64.         
  65.         ' terminate communication
  66.         rc = DoControl("TERM", result)
  67.     End If
  68.     'done
  69. End Sub
  70. Function DoControl(ByVal command As String, ByRef result As String) As Integer
  71.     Dim rc As Integer   ' return code (200 OK, 300 WARN, 400 PROBLEM, 500 ERROR)
  72.     Dim pos As Integer  ' helper variable
  73.         Dim app As String       ' appname parameter
  74.     Dim buffer As String * 128
  75.     Dim howmany As Long
  76.     app = "pyrobatch"  ' use "pyrobatchftp" for PyroBatchFtp
  77.     howmany = 128
  78.     ' display current command
  79.     Label0.Caption = command
  80.     ' exec command and convert result from DLL style to VB
  81.     rc = PyroBatch(app, command, buffer, howmany)
  82.     pos = InStr(buffer, Chr(0)) - 1
  83.     If pos > 0 Then result = Left(buffer, pos)
  84.        
  85.     ' display result string
  86.     Label1.Caption = result
  87.     ' process windows message queue
  88.     For i = 1 To 25
  89.         DoEvents
  90.     Next
  91.     ' determine result
  92.     If rc Then
  93.          rc = Val(Mid(result, 2))
  94.     Else
  95.         rc = 500 ' error
  96.     End If
  97.      
  98.     ' return the return code
  99.     DoControl = rc
  100. End Function
  101.