User Tools

Site Tools


sharing_20private_20variables

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

sharing_20private_20variables [2018/03/31 13:19]
127.0.0.1 external edit
sharing_20private_20variables [2018/04/17 18:43] (current)
tbest3112 Added syntax highlighting
Line 4: Line 4:
 ===== Method one ===== ===== Method one =====
 \\  This method relies on providing a common //entry point// for the procedures and functions, so that the **PRIVATE** statement may be placed there, as follows:\\ \\  \\  This method relies on providing a common //entry point// for the procedures and functions, so that the **PRIVATE** statement may be placed there, as follows:\\ \\ 
 +<code bb4w>
         DEF PROCone(parameters) : LOCAL type% : type% = 1         DEF PROCone(parameters) : LOCAL type% : type% = 1
         DEF PROCtwo(parameters) : LOCAL type% : type% = 2         DEF PROCtwo(parameters) : LOCAL type% : type% = 2
Line 14: Line 15:
         ENDCASE         ENDCASE
         ENDPROC         ENDPROC
 +</​code>​
 This method can be expanded to as many procedures and functions as are required to share the PRIVATE data. It is even possible to share the data between a procedure and a function, so long as the **ENDPROC** or **=** statement is placed within the appropriate **WHEN** clause:\\ \\  This method can be expanded to as many procedures and functions as are required to share the PRIVATE data. It is even possible to share the data between a procedure and a function, so long as the **ENDPROC** or **=** statement is placed within the appropriate **WHEN** clause:\\ \\ 
 +<code bb4w>
         DEF PROCone(parameters) : LOCAL type% : type% = 1         DEF PROCone(parameters) : LOCAL type% : type% = 1
         DEF FNtwo(parameters) : LOCAL type% : type% = 2         DEF FNtwo(parameters) : LOCAL type% : type% = 2
Line 27: Line 30:
         ENDCASE         ENDCASE
         REM. Execution should never reach here.         REM. Execution should never reach here.
 +</​code>​
 \\  \\ 
 ===== Method two ===== ===== Method two =====
 \\  This method relies on creating a **structure** to hold the private data, as follows:\\ \\  \\  This method relies on creating a **structure** to hold the private data, as follows:\\ \\ 
 +<code bb4w>
         DEF PROCone(parameters)         DEF PROCone(parameters)
         PRIVATE ps{}         PRIVATE ps{}
Line 50: Line 55:
         !(^t{}+4) = !(^p{}+4)         !(^t{}+4) = !(^p{}+4)
         ENDPROC         ENDPROC
 +</​code>​
 The **PROCprivate** procedure sets the supplied structure parameter to point to the private structure declared therein, allowing any routine which calls this procedure to access the private data.\\ \\  You can use the same technique to share PRIVATE arrays:\\ \\  The **PROCprivate** procedure sets the supplied structure parameter to point to the private structure declared therein, allowing any routine which calls this procedure to access the private data.\\ \\  You can use the same technique to share PRIVATE arrays:\\ \\ 
 +<code bb4w>
         DEF PROCone(parameters)         DEF PROCone(parameters)
         PRIVATE array()         PRIVATE array()
Line 68: Line 75:
         !^a() = !^array()         !^a() = !^array()
         ENDPROC         ENDPROC
 +</​code>​
sharing_20private_20variables.txt ยท Last modified: 2018/04/17 18:43 by tbest3112