User Tools

Site Tools


sharing_20private_20variables

Differences

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

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
sharing_20private_20variables [2018/04/17 18:43] – Added syntax highlighting tbest3112sharing_20private_20variables [2024/01/05 00:21] (current) – external edit 127.0.0.1
Line 35: Line 35:
 \\  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> <code bb4w>
-        DEF PROCone(parameters) +      DEF PROCone(parameters) 
-        PRIVATE ps{} +      PRIVATE ps{} 
-        PROCprivate(ps{}) +      PROCprivate(ps{}) 
-        REM. Code for PROCone goes here. +      REM. Code for PROCone goes here. 
-        REM. Private variables are ps.alpha, ps.beta%, ps.gamma$ +      REM. Private variables are ps.alpha, ps.beta%, ps.gamma$ 
-        ENDPROC+      ENDPROC
  
-        DEF FNtwo(parameters) +      DEF FNtwo(parameters) 
-        PRIVATE ps{} +      PRIVATE ps{} 
-        PROCprivate(ps{}) +      PROCprivate(ps{}) 
-        REM. Code for FNtwo goes here. +      REM. Code for FNtwo goes here. 
-        REM. Private variables are ps.alpha, ps.beta%, ps.gamma$ +      REM. Private variables are ps.alpha, ps.beta%, ps.gamma$ 
-        = returnvalue+      = returnvalue
  
-        DEF PROCprivate(RETURN t{}) +      DEF PROCprivate(RETURN t{}) 
-        PRIVATE p{} +      PRIVATE p{} 
-        DIM p{alpha, beta%, gamma$} +      DIM p{alpha, beta%, gamma$} 
-        !(^t{}+0) !(^p{}+0) +      DIM t{} = p{} 
-        !(^t{}+4) = !(^p{}+4+      PTR (t{}) = PTR(p{}) 
-        ENDPROC+      ENDPROC
 </code> </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:\\ \\ 
Line 73: Line 73:
         PRIVATE array()         PRIVATE array()
         DIM array(100)         DIM array(100)
-        !^a() = !^array()+        PROCsetarrayptr(a(), FNgetarrayptr(array()))
         ENDPROC         ENDPROC
 +        
 +        DEF FNgetarrayptr(RETURN a%%) = a%%
 +        DEF PROCsetarrayptr(RETURN a%%, p%%) : a%% = p%% : ENDPROC
 </code> </code>
sharing_20private_20variables.1523990583.txt.gz · Last modified: 2024/01/05 00:16 (external edit)