Navigation: ESL Documentation > ESL APPC Support Sample Code |
Scroll Prev Top Next More |
# A skeleton of a Chess program that cooperatively runs on two PCs. # The person who initiates the game is WHITE; the partner program # is passed "BLACK" as a parameter. The same program can initiate # the game or accept the initiation. When "BLACK" is passed as an # invocation parameter, the program knows to do an APPCAcceptStart.
include "eslappc.inc" # APPC include file
stimulus APPC_EVENT "eslappc" # APPC_EVENT is a name for the # set of messages/stimuli # generated by the APPC DLL ############################################ # Application Variables ############################################ string InvocationParm AcceptProfileName is "ESLChess" ProfileName is "Chess" FirstMove GetMove ResponseMove MsgReply
integer ChessGame SwitchStates is APPC_Controlled SyncLevel is APPC_Default Returncode NoConvert is APPC_NoConvert Flush is APPC_Flush RdyToReceive is APPC_ReadyToReceive ErrorIndicator WorkRequest Status1 APPCVerb Status2 Abnormal is APPC_Abend
enabled invisible primary dialog region MainWindow size 100 100 at 20 20 in desktop title bar "ESL APPC Chess" system menu
# ESL program initialization response to start make MainWindow permanent make MainWindow visible
if (InvocationParm = "BLACK") then call APPCAcceptStart(ChessGame, # Handle is returned AcceptProfileName, # TP name = profile name SwitchStates ) # APPC_Controlled
call APPCReceiveNotify(ChessGame) # Issue a receive else # program will probably query the user for "what to start" call APPCStart(ChessGame, # Handle is returned ProfileName, # "CHESS" example name SyncLevel, # APPC_Default - no confirm SwitchStates ) # APPC_Controlled
call APPCSendString(ChessGame, # Handle from Start/AcceptStart FirstMove, # First move NoConvert, # Do not convert string Flush, # Send data now RdyToReceive ) # End of this send - expect reply
call APPCReceiveNotify(ChessGame) # Issue a receive end if
# ESL program is terminating response to MainWindow on close if (ChessGame != 0) then # If conversation not ended, call APPCEnd(ChessGame, # end it now Flush ) # Send end of conversation end if
# Start of Input
response to stimulus APPC_EVENT APPC_InputReceived ChessGame begin ProcessInput
# Response to each move by partner response to stimulus APPC_EVENT APPC_Data ChessGame
call APPCGetString(ChessGame, # Handle from Start/AcceptStart GetMove, # String to hold partner's move NoConvert ) # Do not convert string # Now in Send State
response to stimulus APPC_EVENT APPC_SendState ChessGame call APPCSendString(ChessGame, # Handle from Start/AcceptStart ResponseMove, # String containing next move NoConvert, # Do not convert string Flush, # Send data now RdyToReceive ) # This send expects reply
# Only unrecoverable errors response to stimulus APPC_EVENT APPC_SystemError ChessGame call APPCGetSystemError(ChessGame, # Conversation ID ErrorIndicator, # Work-request error code WorkRequest, # ID of work request APPCVerb, # Last APPC Verb called Status1, # APPC error status1 Status2 ) # APPC error status2
call APPCEnd(ChessGame, # End this conversatio Abnormal ) # Abend conversationn
copy 0 to ChessGame # Indicate conversation ended
# Display or record errors
# Partner ended conversation response to stimulus APPC_EVENT APPC_Ended ChessGame call APPCEnd(ChessGame, # Free conversation resources Flush ) # Send end of conversation copy 0 to ChessGame # Indicate conversation ended
# End of input
response to stimulus APPC_EVENT APPC_EndReceive if (ChessGame > 0) then # always want to receive response call APPCReceiveNotify(ChessGame) # Conversation ID end if leave block
end ProcessInput
|
# A skeleton of a Chess program that cooperatively runs on two PCs. # The person who initiates the game is WHITE; the partner program # is passed "BLACK" as a parameter. The same program can initiate # the game or accept the initiation. When "BLACK" is passed as an # invocation parameter, the program knows to do an APPCAcceptStart.
include "eslappc.inc" # APPC include file
stimulus APPC_EVENT "eslappc" # APPC_EVENT is a name for the # set of messages/stimuli # generated by the APPC DLL ############################################ # Application Variables ############################################ string InvocationParm AcceptProfileName is "ESLChess" ProfileName is "Chess" FirstMove GetMove ResponseMove MsgReply
integer ChessGame SwitchStates is APPC_Controlled SyncLevel is APPC_Default Returncode NoConvert is APPC_NoConvert Flush is APPC_Flush RdyToReceive is APPC_ReadyToReceive ErrorIndicator WorkRequest Status1 APPCVerb Status2 Abnormal is APPC_Abend
enabled invisible primary dialog region MainWindow size 100 100 at 20 20 in desktop title bar "ESL APPC Chess" system menu
# ESL program initialization response to start make MainWindow permanent make MainWindow visible
if (InvocationParm = "BLACK") then call APPCAcceptStart(ChessGame, # Handle is returned AcceptProfileName, # TP name = profile name SwitchStates ) # APPC_Controlled
call APPCReceiveNotify(ChessGame) # Issue a receive else # program will probably query the user for "what to start" call APPCStart(ChessGame, # Handle is returned ProfileName, # "CHESS" example name SyncLevel, # APPC_Default - no confirm SwitchStates ) # APPC_Controlled
call APPCSendString(ChessGame, # Handle from Start/AcceptStart FirstMove, # First move NoConvert, # Do not convert string Flush, # Send data now RdyToReceive ) # End of this send - expect reply
call APPCReceiveNotify(ChessGame) # Issue a receive end if
# ESL program is terminating response to MainWindow on close if (ChessGame != 0) then # If conversation not ended, call APPCEnd(ChessGame, # end it now Flush ) # Send end of conversation end if
# Start of Input
response to stimulus APPC_EVENT APPC_InputReceived ChessGame begin ProcessInput
# Response to each move by partner response to stimulus APPC_EVENT APPC_Data ChessGame
call APPCGetString(ChessGame, # Handle from Start/AcceptStart GetMove, # String to hold partner's move NoConvert ) # Do not convert string # Now in Send State
response to stimulus APPC_EVENT APPC_SendState ChessGame call APPCSendString(ChessGame, # Handle from Start/AcceptStart ResponseMove, # String containing next move NoConvert, # Do not convert string Flush, # Send data now RdyToReceive ) # This send expects reply
# Only unrecoverable errors response to stimulus APPC_EVENT APPC_SystemError ChessGame call APPCGetSystemError(ChessGame, # Conversation ID ErrorIndicator, # Work-request error code WorkRequest, # ID of work request APPCVerb, # Last APPC Verb called Status1, # APPC error status1 Status2 ) # APPC error status2
call APPCEnd(ChessGame, # End this conversatio Abnormal ) # Abend conversationn
copy 0 to ChessGame # Indicate conversation ended
# Display or record errors
# Partner ended conversation response to stimulus APPC_EVENT APPC_Ended ChessGame call APPCEnd(ChessGame, # Free conversation resources Flush ) # Send end of conversation copy 0 to ChessGame # Indicate conversation ended
# End of input
response to stimulus APPC_EVENT APPC_EndReceive if (ChessGame > 0) then # always want to receive response call APPCReceiveNotify(ChessGame) # Conversation ID end if leave block
end ProcessInput
|