|
Pages: [1]
|
 |
|
Author
|
Topic: REBOL and VB (Read 727 times)
|
|
PeterD
|
Hello there, I need to exchange some messages between REBOL and a VB program. Any idea how this is best done? First I considered using the clipboard, got into a lot of "Error ‘521’ Unable to Open Clipboard" on the VB side, now I consider using a file and read / write to the file to exchange information. Any better ideas / solutions ? Thanks Peter
|
|
|
|
|
Logged
|
|
|
|
|
Gregg
|
Depending on what you need to do, there are probably a lot of options.
* You can call the apps, passing info on the command line.
* You can use TCP sockets.
* You can send WM_ messages (requires REBOL/pro for DLL access). I've never used the system event stuff in REBOL to catch custom message but, with the limitation that you have a console window open, you can catch things like WM_DRPOFILE, so it should work.
* The clipboard should work. I've used it to send bitmaps to other apps, and I've never had trouble with writing basic text to the clipboard.
* Pump keystrokes (again, requires /pro and I haven't tried pumping key events to a REBOL app, just outgoing with a dialect I wrote)
* Files
* Have a COM interface in VB and call that with the code some folks have written, or a custom DLL that acts as a go-between.
I would probably recommend an IPC approach using TCP sockets, but it really depends on your specific needs; what kind of data, how often, how fast, one-way or two-way, what version of VB (I specialized in VB for 11 years, but bailed from .NET).
|
|
|
|
|
Logged
|
|
|
|
|
PeterD
|
Thanks for the info:
The clipboard is my first option because it is easy to implement. Maybe I just have to play more with it.
The messages are all text and very short. Example: REBOL_RQ_Offset 1 2 3 VB_RQ_Offset 1 2 3 "OK"
REBOL_RQ_Scaling 110 55 89 VB_RQ_Scaling 110 55 89 "Can not change scaling at his time"
The general scheme is : REBOL places a request somewhere (clipboard, file or such) VB gets the message, executes some stuff and echos the message back followed by some status information
The Request can happen at any time, at any interval,l so a timer based routine on both the REBOL and VB side are probably needed. (Guessing 1 to 2 second timer interval will do)
I have REBOL and VB app running side by side, able to "talk" to each other but it rains with " Runtime Error 521: Unable to Open Clipboard " on the VB side.
I'm using VB6, don't intend to ever go .NET
|
|
|
|
« Last Edit: April 18, 2007, 03:18:14 PM by elaserbay »
|
Logged
|
|
|
|
|
Gregg
|
Can you open up clipview after writing to the clipboard from REBOL, to see what's there?
Are you just doing "write clipboard:// string-var"?
|
|
|
|
|
Logged
|
|
|
|
|
PeterD
|
It took me a while to find the clipbook viewer in XP. (yes the messages show OK.)
REBOL: write clipboard:// to-string var Last_Var: var wait 2
I added a dummy error handler in VB to ignore and try again later. Seems to work OK. (See below).
VB: Private Sub Timer1_Timer() On Error GoTo Clip_error 'get message msg = Clipboard.GetText()
'check if this is from REBOL id = Mid$(msg, 1, 6) If id = "REBOL_" Then 'must be from REBOL If msg <> last_msg Then ' just show it for now Label1.Caption = msg ' code for action here last_msg = msg Else ' SAME AS LAST Label1.Caption = msg & vbCrLf & "Same as last, no action " End If Else ' Not from REBOL >>> IGNORE Label1.Caption = msg & vbCrLf & " not for me" End If Exit Sub Clip_error: If Err = 521 Then Sleep 100 Label1.Caption = "error" Resume End If
End Sub
Thanks again for your help. I seems to work OK for now, let's see what the next surprise is
Peter
|
|
|
|
|
Logged
|
|
|
|
|
|
Pages: [1]
|
|
|
 |
News: 01-09-08 Alpha version of REBOL 3 has been released!
2311 Posts in 595 Topics by 4142 Members
Latest Member: FoxxxTrott
|