Product Summary |
www.edelwise.com |
This is the product for the professional developer. It includes all features of the ADVANCED version plus PIPES and an optional C interface. Pipes allow you to exchange streams of data between applications. The C interface allows sharing of variables between VB and conventional C programs. |
Price: $69.95 |
Example “Messaging”: This example is functional similar to the “Listening” example, but instead of beWISE VARIABLES we use beWISE PIPES. One program, called HANS, sends 100 readings (variables that receive random numbers) thru a pipe to program KARL. HANS only sends the data when KARL requests it. KARL can request the data by sending the string "FromKarl: SEND READINGS" to HANS’ pipe. Since beWISE PIPES are unidirectional, each program needs its own pipe in order for the programs to exchange messages in both directions. If a program wants to receive messages, it has to create at least one RECEIVER PIPE. To send messages (to other programs) it has to create SENDER PIPES with the appropriate names. In our example HANS creates a RECEIVER PIPE called “HANS” and a SENDER PIPE called “KARL”. KARL does the opposite. He creates a RECEIVER PIPE called “KARL” and a SENDER PIPE called “HANS”. Now they both can exchange messages with each other. HANS waits until he receives an order from KARL to send the readings. When he receives the order he sends the string “BEGIN”, then each of the 100 values (of type Double) and then the string “END”. KARL uses the “BEGIN” string to synchronize his pipe. He ignores everything until he finds the “BEGIN” string. He then reads and displays the 100 values. After that he empties the pipe from potential garbage (data he does not need). Program HANS:
Dim Create As New beWISE.Functions 'REQUIRED statement Dim WithEvents MyPipe As beWISE.obj_PIPE Dim KarlsPipe As beWISE.obj_PIPE
Private Sub HANS_Load(ByVal sender As System.Object, _ Randomize() MyPipe = Create.New_obj_PIPEforReceiving("HANS") KarlsPipe = Create.New_obj_PIPEforSending("KARL") End Sub
Private Sub MyPipe_Changed() Handles MyPipe.Changed 'we have data Dim message As Object
message = MyPipe.ItemValue 'read (and delete) item from pipe If message = "FromKarl: SEND READINGS" Then Call SendReadingsTo(KarlsPipe) End If
'--- We have to COMPLETELY EMPTY the pipe before exiting; ' otherwise this handler will NOT be called again --- While (MyPipe.PipeIsEmpty = False) 'while pipe no empty message = MyPipe.ItemValue 'read message End While End Sub
Private Sub SendReadingsTo(ByVal pipe As beWISE.obj_PIPE) Dim i As Integer pipe.ItemValue = "BEGIN" 'put "START" into the pipe For i = 0 To 99 'put 100 random numbers into pipe pipe.ItemValue = CDbl(Rnd() * 99) Next i pipe.ItemValue = "END" 'put "END" into the pipe pipe.SendTrigger() 'wake-up trigger End Sub
Program KARL:
Dim WithEvents MyPipe As beWISE.obj_PIPE Dim HansPipe As beWISE.obj_PIPE
Private Sub KARL_Load(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles MyBase.Load
MyPipe = Create.New_obj_PIPEforReceiving("KARL") HansPipe = Create.New_obj_PIPEforSending("HANS") End Sub
Private Sub MyPipe_Changed() Handles MyPipe.Changed 'we have data Dim i, j As Integer Dim s As String Dim message As Object
message = MyPipe.ItemValue 'read (and delete) item from pipe If message = "BEGIN" Then ListBox1.Items.Clear() For i = 0 To 9 Step 1 s = "" For j = 0 To 9 Step 1 If MyPipe.PipeIsEmpty = False Then s = s & Format(MyPipe.ItemValue, "00.0 ") End If Next j ListBox1.Items.Add(s) 'add line with 10 values Next i End If ' ---- that's all we needed.
'--- We have to COMPLETELY EMPTY the pipe before exiting; ' otherwise this handler will NOT be called again --- While (MyPipe.PipeIsEmpty = False) 'while pipe no empty message = MyPipe.ItemValue 'read message End While End Sub
Private Sub StartReporting_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles StartReporting.Click HansPipe.ItemValue = "FromKarl: SEND READINGS" 'send message HansPipe.SendTrigger() 'wake HANS up End Sub |
The Essential Resource for Visual Basic Developers |
Home | beWISE Features | VB6 Products | VB.NET Products | Tools | FAQ | Project List | User Forum | Legal | About Us |