InterKOM Technology

<< Click to Display Table of Contents >>

Navigation:  3. Script Language > IPC, InterKOM and Exit Code >

InterKOM Technology

TWM. - Text-Window-Message

Previous Top Next


MiniRobotLanguage (MRL)

 

TWM. Command

Text Window Message

 

 

Intention

 

Send a Text-Message to another running robot instance, which must be in receiving mode, using the WFM. command. Usage is simple:

 

' Sent Text to last localized Window use "19" as dwdata

TWM.Text

 

' Sent Text to robot $$CMH, use 19 (default) as dwdata

TWM.Text|$$CMH

 

' Sent Text to Windowhandle in $$MYW, use 21 as dwdata

TWM.Text|$$MYW|21

 

As the PRV. command is much more easy to use, for "Inter-Robot Communication", its the preferred way to exchange data between robots.

 

The TWM. / WFM. method is more complicated, and should be used primarily to communicate with external programs.

 

This command can be used to communicate (send messages) to WinRobots compatible automation-systems.

 

 

 

Syntax

 

TWM.P1[|P2][|P3]

 

 

Parameter Explanation

 

P1 - Text/String to send to the other robot.

 

P2 - (optional) Receiver/Target window handle

    (communications handle). If omitted, last localized

     window is been taken as receiver.

 

P3 - (optional)  dwData, a number, which is 19 by default.

    It's recommended to ignore this number and omit this

    parameter, unless you now what you do.

 

 

Please note that you can get the window-handle of this instance by using the #cbw# Systemvariable.

 

 

 

 

Example

 

'**********************************************

' TWM./WFM. - Sample

' Shows that the Parallel-Robot starts with

' all variables as they have been at starting-time

' of the starting robot.

' It can also use all Subroutines in this file.

'**********************************************

VAR.$$INP=0

VAR.$$CMH=#cbw#

PRT. My Name is Robbi $$CMH.

'-----------------------------------------------------------

PRR.

 PRT.I am Parallel-Robot Robbi: #cbw#

 PRT. I am going to send to: $$CMH

 PAU.2

 TWM.#This is my message!#|$$CMH

 PRT.Parallelrobot Ending.

 PAU.12

 END.

PRE.$$RET|0

PRT. I am waiting for a Message from Robbi: $$RET

'-----------------------------------------------------------

WFM.md|$$WAI|19

MBX.I got: $$WAI

END.

'-----------------------------------------------------------

 

 

 

 

Remarks

 

To implement a communication between the SPR and an external program, you can use the following  Sub-Programs (BASIC-Code). The communication is done using the WM_COPYDATA-Message.

 

'#################################################################

'#

'#################################################################

' T01 - hwnd, T02 - Text$,T05 - eigenes Empfänger-Handel, T03 - optionale Zahl,B01 - wenn >0 dann wird Postmessage statt Sendmessage verwendet

FUNCTION PM_SendPM(BYVAL T01 AS DWORD,BYVAL T02 AS STRING,BYVAL T05 AS DWORD,OPT BYVAL T03 AS LONG,OPT BYVAL B01 AS BYTE) AS LONG

   REGISTER R01 AS DWORD,R02 AS LONG

   LOCAL S01 AS STRING

   ' T05 - Own Handle

   S01="TPMS"+MKDWD$(T05)+T02

    ' hTarget, dwdata-Zahl,Text$,Send/Post

   R02=PM_SendPrivateMsg(T01,T03,S01,B01)

    enx:

    FUNCTION = R02

END FUNCTION

'#################################################################

'#

'#################################################################

' Returns 0 oder 1 (sucess)

' Format: "TPMS"+MKDWD$(Sender)+MSG$

FUNCTION PM_GetPM(BYREF PrivateMsg AS STRING, BYVAL wParam AS LONG, BYVAL lParam AS LONG, BYREF sender AS DWORD,BYREF dwdata AS LONG) AS LONG

  REGISTER R01 AS LONG

  LOCAL S01,S02 AS STRING

  dwdata=PM_GetPrivateMsg(S01,wParam,lParam)

  S02=LEFT$(S01,4)

  IF S02="TPMS" THEN

     S02=MID$(S01,5,4):Sender=CVDWD(S02)

     IF IsNoWin(Sender) THEN R01=0:GOTO ero

     PrivateMsg=MID$(S01,9)

  R01=1

  ELSE

    R01=0:GOTO ero

  END IF

  ero:

  FUNCTION = R01

END FUNCTION

'#################################################################

'#

'#################################################################

'

FUNCTION PM_SendPrivateMsg(BYVAL hTarget AS LONG, BYVAL UseMsg AS LONG, BYVAL Buff AS STRING,OPT BYVAL B01 AS BYTE) AS LONG

   REGISTER LenBuff AS LONG, R02 AS LONG

   DIM Buf(1) AS LOCAL BYTE

   LOCAL cds AS COPYDATASTRUCT

   LenBuff = LEN(Buff)

   REDIM Buf(LenBuff) AS BYTE

   POKE$ VARPTR(Buf(0)), Buff

   cds.dwData = UseMsg

   cds.cbData = UBOUND(Buf) - LBOUND(Buf) + 1

   cds.lpData = VARPTR(Buf(0))

   IF zero(B01) THEN

       R02 = SendMessage(hTarget, %WM_COPYDATA, LenBuff,VARPTR(cds))

    ELSE

       PostMessage(hTarget, %WM_COPYDATA, LenBuff,VARPTR(cds))

       R02=1

    END IF

   FUNCTION=R02

END FUNCTION

'#################################################################

'#

'#################################################################

FUNCTION PM_GetPrivateMsg(BYREF PrivateMsg AS STRING, BYVAL wParam AS LONG, BYVAL lParam AS LONG) AS LONG

   LOCAL cds AS COPYDATASTRUCT

   DIM Buf(1) AS LOCAL BYTE

   REDIM Buf(wParam) AS BYTE

   CALL MoveMemory(cds, BYVAL lParam, SIZEOF(cds))

   CALL MoveMemory(buf(0), BYVAL cds.lpData, cds.cbData)

   PrivateMsg = PEEK$(VARPTR(buf(0)), wParam)

   FUNCTION = cds.dwData

END FUNCTION

'#################################################################

'#

'#################################################################

 

 

Limitations:

 

-

 

See also:

 

    WFM. - Wait-For-Message

    PRR. - Parallel-Robot-Run

    PRE. - Parallelrobot-Run-End

    PRV. - Parallel-Robot send Variable

    WFV. - Wait-For-VariableChange

    SGS - Set Global Signal (Mutex)

    TWM. - Text-Window-Message