1 / 29

Reusable Code For Your Appx Processes

Reusable Code For Your Appx Processes. Presented By: Gary Rogers. Session Topics:. What is Reusable Code in Appx? How Do You Access Reusable Code? Scope of Shared Fields Sharing Fields Between Processes. Creating Reusable Code in Appx. What is reusable code in Appx?.

ellie
Download Presentation

Reusable Code For Your Appx Processes

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Reusable Code For Your Appx Processes Presented By: Gary Rogers

  2. Session Topics: • What is Reusable Code in Appx? • How Do You Access Reusable Code? • Scope of Shared Fields • Sharing Fields Between Processes Creating Reusable Code in Appx

  3. What is reusable code in Appx? Reusable Code are libraries that can be used by multiple processes. In Appx these are usually subroutine processes. With the use of the pass and receive statements almost any process can be made reusable. Creating Reusable Code in Appx

  4. How is reusable code used in Appx? Reusable Code is accessed mainly by the use of three commands in ILF: COPY GOSUB SUBR Each command has a unique way of inserting the code into your process. Creating Reusable Code in Appx

  5. The COPY Command: The COPY command inserts the code from the subroutine process inline with your ILF code. It is compiled into the EM as part of your process. Code included by the COPY command inherits the true/false indicators of your code. All fields within your process are accessible to the called routine. Creating Reusable Code in Appx

  6. The GOSUB Command: The GOSUB command inserts the code from the subroutine at the end of your process and wraps it within a label and return statement. It is also compiled into the EM as part of your process. Code executed by the GOSUB command receives its own set of true/false indicators. All fields within your process can be updated by the called routine. Creating Reusable Code in Appx

  7. The SUBR Command: The SUBR command does not insert code into your process. It is compiled as its own EM and is executed as a separate process at run time. Fields in your process may or may not be accessible to the routine depending on the invocation level of the routine and the share class of your variables. Creating Reusable Code in Appx

  8. Your subroutine looks like this: Creating Reusable Code in Appx

  9. If your ILF looks like this: Creating Reusable Code in Appx

  10. Appx treats it like this: Creating Reusable Code in Appx

  11. And if your ILF is like this: Creating Reusable Code in Appx

  12. Appx treats it like this: Creating Reusable Code in Appx

  13. Sharing Variables Between Routines: Variables are shared by inclusion using the COPY or GOSUB commands. Variables are generally shared between processes two ways: • Setting the share class Creating Reusable Code in Appx

  14. Share Class: Share class sets the level at which a variable is exposed to change within a process. There are three levels of Share Class: • Detached • Related • Subprocess Creating Reusable Code in Appx

  15. Detached Share Class: This is the highest level of sharing. Variables with this class are accessible until the current session of Appx ends. Any process at any share class can modify the variables value and all other processes will see the change. Creating Reusable Code in Appx

  16. Related Share Class: Variables with a related class are accessible to the current process and any related or subprocess tasks of the parent. The variable’s value is not accessible to child processes that are invokes detached. The variable remains accessible until the process tree returns back to a detached process parent. Creating Reusable Code in Appx

  17. Sharing Variables Between Routines: Variables are shared by inclusion using the COPY or GOSUB commands. Variables are generally shared between processes two ways: • Setting the share class • Using PASS and RECEIVE Creating Reusable Code in Appx

  18. The Pass Statement: The PASS statement is used to make a variable available to another process, either internal or external to Appx. When used with the RECEIVE statement you can set a flag to indicate if the PASSed value can be modified or not. Creating Reusable Code in Appx

  19. From the Designer Reference Manual: The PASS statement causes the indicated area to be passed to the next subroutine, process, or external program that is executed via a GOSUB, CALL, RUN, or process-type statement (i.e., INPUT, INQUIRY, JOB, MENU, OUTPUT, QUERY, STATUS, SUBR, UPDATE), or to the next automatic or optional child process that is run. See the next section, PASS Lists, for a discussion of how PASS lists are maintained and cleared.     ••••• PASS     ••• •••••••••••••••••••••• ••• •••••••••••••••  SHARE? •     (1)            (2) (3)                    (4) (5)                    (6) (1) T/F execution conditions(2) Application ID(3) Field name or predefined field(4) Occurrence (constant/index)(5) Area type (FIELD)(6) Share?(Y/N) Creating Reusable Code in Appx

  20. The Pass Stack: As each PASS statement is executed the values are written to the end of a stack. When a statement that receives a value is executed the next value is taken from the top of the stack. Creating Reusable Code in Appx

  21. The Pass Stack: Each PASS statement adds to a single list until the execution of a GOSUB, CALL, RUN, or process-type statement, or the invocation of an automatic or optional child process. Upon such execution, only the values in the current PASS list are passed. Creating Reusable Code in Appx

  22. The Pass Stack: The called process can in turn execute PASS statements. These statements then build another PASS list which is maintained until that process terminated in the same manner. Each PASS list is cleared when execution returns to the routine or level which established it. Creating Reusable Code in Appx

  23. The Receive Statement: The RECEIVE statement is used to make a variable available from another process. Depending on the settings of the PASS statement, the variable may modified by the routine and returned to the calling process or used internally within the routine without affecting the calling process. Creating Reusable Code in Appx

  24. The RECEIVE keyword can be used for different purposes. The RECEIVE statement works with the PASS statement to implement true subroutines. Or, it works without the PASS statement to essentially declare a local variable (a field that is automatically restored to its initial value when the subroutine, event point, or process ends). •     ••••• RECEIVE  ••• •••••••••••••••••••••• •••     (1)            (2) (3)                    (4) • T/F execution conditions(2) Application ID(3) Field name or predefined field(4) Occurrence (constant/index) • Sets True/False Status Indicator • The RECEIVE statement sets the next status indicator to T if a matching PASS statement was found and to F if not. If you RECEIVE without a PASS statement, you are simply declaring a local variable that is restored to its initial value when the subroutine, event point, or process ends. Creating Reusable Code in Appx

  25. The RECEIVE statement can be used in subroutines internal to an event point or in the Start of Process event point of a process. This usage extends the creation of reusable code to processes as well. A generic input can be created to accept values through the receive statement to process and display information to the user. Creating Reusable Code in Appx

  26. The RECEIVE statement originally required that the PASSed and RECEIVEd field types be the same. Appx now supports passing and receiving unlike field types. The equivalent of a SET is performed. Receive will also now allow constant values. Creating Reusable Code in Appx

  27. A RECEIVE statement without a corresponding PASS statement has the effect of creating a variable local to the routine. This variable can be manipulated in the routine without affecting the value in the calling process. This would be the equivalent of a STORE/RESTORE in your code. Creating Reusable Code in Appx

  28. The RECEIVE statement sets the next True/False condition. If there is a value in the pass stack for the RECEIVE the true flag is set. If no value is available then false is set. You can set the RECEIVE in a loop and continue receiving until a false condition in order to create a process with a variable amount of arguments. Creating Reusable Code in Appx

  29. It is not safe to assume that a PASS with a Shared flag of N will protect your variable. If the share class of the variable and the process allow it, the variable may still be affected. To create a truly local variable for that “Black Box” type of routine you can RECEIVE each variable. In Release 4.2 a LOCAL command will be added to accomplish this. Creating Reusable Code in Appx

More Related