SET219A

LANSA

SET219A
* =======================================================
* Process ........: SET_219
* Function .......: SET219A
* Created on .....: 7th November, 2001
* Description ....: Caller example -> Calculator
* Version.........: 1
*
* Full Description:
*
* This function is a simple example of how SET219Y can
* be used to manage calls to functions on remote systems.
*
* In this case SET219A acts as a very simple calculator.
*
* It requests input of 2 numbers and passes the values to
* function SET219B which sums the numbers and sends back
* the result.
*
* A simple name is also passed to the server, reversed
* and sent back again to demonstrate how alphanumeric
* values are sent between systems.
*
* While the processing involved here is trivial, SET219A
* and SET219B together demonstrate the essentials of
* parameter passing between RDML functions running on
* different systems.
*
* =======================================================
* ============== D E F I N I T I O N S ================
* =======================================================
Function Options(*LIGHTUSAGE *DIRECT)
Define Field(#SERVERURL) Reffld(#S_219HOST)
Define Field(#NUMBER_1) Reffld(#STD_NUM) Label('First Number') Edit_Code(L)
Define Field(#NUMBER_2) Reffld(#STD_NUM) Label('Second Number') Edit_Code(L)
Define Field(#REV_NAME) Reffld(#STD_TEXTS) Label('Test Name')
Define Field(#SUMOF_1_2) Reffld(#STD_NUM) Label('Sum of Numbers') Edit_Code(L)
*
* =======================================================
* ================ M A I N L O G I C ===============
* =======================================================
*
Execute Subroutine(CALCULATE)
Execute Subroutine(CLOSE)
Exchange Fields(#SERVERURL)
Menu
* =======================================================
* ======= U N I Q U E S U B R O U T I N E S ========
* =======================================================
Subroutine Name(CALCULATE)
*
* Default the server value
*
If_Null Field(#SERVERURL)
Use Builtin(TCONCAT) With_Args(*S_HOSTURL ':' *S_HOSTPORT) To_Get(#SERVERURL)
Endif
*
* Loop until terminated by menu/cancel key
*
Begin_Loop
*
* Ask for input and display last set of results (if any)
*
Request Fields(#SERVERURL #NUMBER_1 #NUMBER_2 (#SUMOF_1_2 *OUTPUT) #REV_NAME) Identify(*LABEL) Exit_Key(*NO) Menu_Key(*YES *RETURN) Prompt_Key(*NO) Cursor_Loc(*atfield #number_1)
*
* Clear any existing argument details
*
Execute Subroutine(CLEAR_ARGS)
*
* Set up the arguments to be passed. They are passed with
* the symbolic names NUMBER1, NUMBER2 and NAME with
* their values mapped from fields #NUMBER_1, #NUMBER_2
* and #REV_NAME respectively.
*
Execute Subroutine(SET_NUMBER) With_Parms(NUMBER1 *BLANKS 1 #NUMBER_1)
Execute Subroutine(SET_NUMBER) With_Parms(NUMBER2 *BLANKS 1 #NUMBER_2)
Execute Subroutine(SET_ALPHA) With_Parms(NAME *BLANKS 1 #REV_NAME)
*
* Call SET219B on the remote server system
*
Execute Subroutine(CALL) With_Parms(SET219B #SERVERURL)
*
* Get the results returned. They are returned with the
* symbolic names NAME and RESULT and the associated
* values are mapped back into fields #REV_NAME and
* #SUMOF_1_2 respectively.
*
Execute Subroutine(GET_ALPHA) With_Parms(NAME *BLANKS 1 #REV_NAME)
Execute Subroutine(GET_NUMBER) With_Parms(RESULT *BLANKS 1 #SUMOF_1_2)
*
* Loop around and show the results
*
End_Loop
*
Endroutine
*
* =======================================================
* ======== C O M M O N S U B R O U T I N E S =========
* =======================================================
* This set of subroutines are simple interfaces to RDML
* function SET219Y. They can be copied from this function
* and used in other similar functions unchanged.
* =======================================================
*
* -------------------------------------------------------
* Use CLEAR_Args to clear the current set of values
* -------------------------------------------------------
Subroutine Name(CLEAR_ARGS)
Execute Subroutine(CALL_219Y) With_Parms(CLEAR)
Endroutine
* -------------------------------------------------------
* Use SET_ALPHA to pass an alphanumeric value
* -------------------------------------------------------
Subroutine Name(SET_ALPHA) Parms((#S_219NAM1 *RECEIVED) (#S_219NAM2 *RECEIVED) (#S_219NAMI *RECEIVED) (#S_219AVAL *RECEIVED))
Execute Subroutine(CALL_219Y) With_Parms(SETALP)
Endroutine
* -------------------------------------------------------
* Use SET_NUMBER to pass a numeric value
* -------------------------------------------------------
Subroutine Name(SET_NUMBER) Parms((#S_219NAM1 *RECEIVED) (#S_219NAM2 *RECEIVED) (#S_219NAMI *RECEIVED) (#S_219NVAL *RECEIVED))
Execute Subroutine(CALL_219Y) With_Parms(SETNUM)
Endroutine
* -------------------------------------------------------
* Use GET_ALPHA to return an alphanumeric value
* -------------------------------------------------------
Subroutine Name(GET_ALPHA) Parms((#S_219NAM1 *RECEIVED) (#S_219NAM2 *RECEIVED) (#S_219NAMI *RECEIVED) #S_219AVAL)
Execute Subroutine(CALL_219Y) With_Parms(GETALP)
Endroutine
* -------------------------------------------------------
* Use GET_NUMBER to return an alphanumeric value
* -------------------------------------------------------
Subroutine Name(GET_NUMBER) Parms((#S_219NAM1 *RECEIVED) (#S_219NAM2 *RECEIVED) (#S_219NAMI *RECEIVED) #S_219NVAL)
Execute Subroutine(CALL_219Y) With_Parms(GETNUM)
Endroutine
* -------------------------------------------------------
* Use CALL to call a function
* -------------------------------------------------------
Subroutine Name(CALL) Parms((#S_219FUNC *RECEIVED) (#S_219HOST *RECEIVED))
Define Field(#W_219HOST) Reffld(#S_219HOST)
Use Builtin(UPPERCASE) With_Args(#S_219HOST) To_Get(#W_219HOST)
If Cond('#W_219HOST = LOCAL')
Call Process(*DIRECT) Function(#S_219FUNC) Exit_Used(*NEXT) Menu_Used(*NEXT) If_Error(*NEXT)
Else
Execute Subroutine(CALL_219Y) With_Parms(CLIENTCALL)
Endif
Endroutine
* -------------------------------------------------------
* Use CLOSE to close down SET219Y
* -------------------------------------------------------
Subroutine Name(CLOSE)
Execute Subroutine(CALL_219Y) With_Parms(CLOSE)
Endroutine
* -------------------------------------------------------
* CALL_219Y is used to consolidate calls to SET219Y
* -------------------------------------------------------
Subroutine Name(CALL_219Y) Parms((#S_219OPER *RECEIVED))
Exchange Fields(#S_219OPER #S_219NAM1 #S_219NAM2 #S_219NAMI #S_219AVAL #S_219NVAL #S_219HOST #S_219FUNC)
Call Process(*DIRECT) Function(SET219Y)
Endroutine