home *** CD-ROM | disk | FTP | other *** search
- VERSION 2.00
- Begin Form vbdemo
- AutoRedraw = -1 'True
- BorderStyle = 3 'Fixed Double
- Caption = "WPLOTCMD.DLL DEMO"
- ClientHeight = 2775
- ClientLeft = 1170
- ClientTop = 1545
- ClientWidth = 5940
- Height = 3210
- Left = 1095
- LinkTopic = "vbdemo"
- ScaleHeight = 2775
- ScaleWidth = 5940
- Top = 1185
- Width = 6090
- Begin CommandButton butok
- Caption = "OK"
- Height = 375
- Left = 2640
- TabIndex = 1
- Top = 1920
- Width = 735
- End
- Begin Label laby
- Caption = " "
- Height = 255
- Left = 3240
- TabIndex = 3
- Top = 2400
- Width = 1455
- End
- Begin Label labx
- Caption = " "
- Height = 255
- Left = 1680
- TabIndex = 2
- Top = 2400
- Width = 1335
- End
- Begin Label labprompt
- Alignment = 2 'Center
- BorderStyle = 1 'Fixed Single
- Caption = " "
- Height = 255
- Left = 120
- TabIndex = 0
- Top = 1560
- Width = 5655
- End
- ' VBDEMO.FRM - Visual Basic Demo of using WPLOTCMD.DLL to send commands & data
- ' to WPlot. Windows must know the path to WPLOTCMD.DLL, i.e., the DLL file
- ' must be in the Windows directory or the application's working directory or
- ' the path to the DLL file must be specified in the declarations of the DLL
- ' functions. WPlot must be in the path specified as a parameter to the
- ' StartWPlot function. This demo specifies a path of "c:\wplot\" for both
- ' WPlot and WPLOTCMD.DLL. Programmers: William G. Hood & Eric A. Hood, 9-16-95
- Option Explicit
- ' Can use just "wplotcmd.dll" if the DLL file is in the Windows directory
- Declare Function StartWPlot Lib "c:\wplot\wplotcmd.dll" (ByVal id As Integer, ByVal path As String) As Integer
- Declare Function WPlotcmd Lib "c:\wplot\wplotcmd.dll" (ByVal id As Integer, ByVal pcmd As String, ByVal nocheck As Integer) As Integer
- Const id = 1
- Dim state As Integer
- Dim errmes(4) As String
- Dim ydata(8) As Integer
- Sub butok_Click ()
- Dim errcode As Integer
- Dim i As Integer
- Dim x As Double
- Dim y As Double
- Select Case state
- Case 1
- ' Launch WPlot from the specified path (use "" for default directory)
- errcode = StartWPlot(id, "c:\wplot\")
- If errcode > 0 Then
- If errcode > 5 Then errcode = 5
- MsgBox errmes(errcode - 1), 16, "ERROR"
- End
- End If
-
- send id, "winpos 0.5 45.0" ' Set window position
- send id, "plotsize 1" ' Set small plot size
-
- labprompt.Caption = " Press the OK button to see a plot of data sent to WPlot."
- state = 2
- Case 2
- send id, "title Demo of Controlling WPlot"
- send id, "xlabel X-Axis"
- send id, "ylabel Y-Axis"
- send id, "xstart 0"
- send id, "xend 10"
- send id, "xstep 1"
- send id, "ystart 0"
- send id, "yend 1000"
- send id, "ystep 200"
- send id, "grids"
- send id, "read 9" ' Data points can be sent after a READ command
- For i = 0 To 8
- send id, Str$(i + 1) + " " + Str$(ydata(i))
- Next i
- send id, "curve 1" ' The data set will be plotted as a smooth curve.
- send id, "symbols" ' A symbol will be plotted at each data point.
- send id, "plot" ' Plot previously read data points.
- labprompt.Caption = " Press the OK button to plot data points as they are calculated."
- state = 3
- Case 3
- ' Some special commands were added to WPlot for real-time data display:
- ' rtplot - Displays axes, title and labels even if no data.
- ' rtdata m - Allocates memory for a maximum of m data points.
- ' rtpoint x y - Inputs and plots point (x,y).
- ' rtend - Terminates real-time plot & frees Windows resources.
- send id, "rtdata 51"
- For i = 0 To 50
- x = i / 5#
- y = x ^ 3 + 2# * x ^ 2 - 30# * x + 90
- y = y + 20# * (2# * Rnd - 1)
- labx.Caption = " X = " + Format(x, "0.00")
- laby.Caption = " Y = " + Format(y, "0.00")
- send id, "rtpoint " + Str$(x) + " " + Str$(y)
- Next i
- send id, "rtend"
- labprompt.Caption = " Press the OK button to make a polynomial curve fit."
- state = 4
- Case 4
- send id, "poly 3"
- send id, "title Polynomial Curve Fit"
- send id, "plot"
- labprompt.Caption = " Press the OK button to exit."
- labx.Caption = ""
- laby.Caption = ""
- state = 5
- Case 5
- send id, "exit"
- End
- End Select
- End Sub
- Sub Form_Load ()
- left = 2 ' Position form at upper left corner of screen
- top = 2
- state = 1
- errmes(0) = " Out of Memory"
- errmes(1) = " Invalid ID"
- errmes(2) = " File WPLOT.EXE not found"
- errmes(3) = " Path to WPLOT.EXE not found"
- errmes(4) = " Unspecified error"
- ydata(0) = 125 ' Example data
- ydata(1) = 175
- ydata(2) = 350
- ydata(3) = 750
- ydata(4) = 900
- ydata(5) = 750
- ydata(6) = 350
- ydata(7) = 175
- ydata(8) = 125
- Print
- Print " WPlot can be used to plot data collected, calculated, or"
- Print " processed by a user written C or Visual Basic program."
- Print
- Print " This is an example of a Visual Basic program that plots data"
- Print " by sending the data and plot commands to WPlot using the"
- Print " functions in the Dynamic Link Library WPLOTCMD.DLL."
- labprompt.ForeColor = QBColor(12) ' Light Red
- labprompt.Caption = " Press the OK button to start WPlot."
- End Sub
- Sub send (id As Integer, cmd As String)
- ' Sends command in string pcmd to WPLOTCMD.DLL using buffer #id.
- ' The routine keeps trying until the DLL is ready to accept the command.
- ' It displays an error message and terminates if it times out after 30 seconds.
- Dim tstart As Long
- tstart = Timer
- If WPlotcmd(id, cmd, 0) = 0 Then Exit Sub
- Loop While Timer - tstart < 30
- MsgBox "WPlot is not responding", 16, "ERROR"
- End
- End Sub
-