midrange.com code scratchpad |
Name:
Demonstrate %OCCUR being module-based value
|
Scriptlanguage:
Plain Text
|
Tabwidth:
4
|
Date:
10/16/2010 05:03:07 pm
|
IP:
Logged
|
|
Description:
Setting occurrence of variable has no impact on other modules that use the same (imported) variable
CRTMOD OCCTEST0
CRTMOD OCCTEST1
CRTMOD OCCTEST2
CRTPGM OCCTEST MODULE(OCCTEST0 OCCTEST1 OCCTEST2)
STRDBG OCCTEST
(set breakpoint at *INLR...)
CALL OCCTEST
Result shows that all modules "see" %Occur(myMODS) independently.
|
Code:
- < OCCTEST_H >
-
- D testOccur1 PR 3I 0 ExtProc('testOccur1')
-
- D testOccur2 PR 3I 0 ExtProc('testOccur2')
-
- D MAX_OCC C 10
-
- D myDS DS based(proto_only)
- D occnbr 3I 0
-
- D myMODS DS Occurs(MAX_OCC) LikeDS(myDS)
- D/If DEFINED(p0)
- D Export
- D/Else
- D Import
- D/Endif
-
-
- < OCCTEST0 >
-
- H
-
- /Define P0
- /Include OCCTEST_H
-
- D i S 3I 0
- D occur0a S 3I 0
- D occur0b S 3I 0
- D occur1 S 3I 0
- D occur2 S 3I 0
-
- /Free
-
- %Occur(myMODS) = 5 ;
- occur1 = testOccur1() ;
- occur0a = %Occur(myMODS) ;
- occur2 = testOccur2() ;
- occur0b = %Occur(myMODS) ;
-
- *INLR = *On ;
- Return ;
-
- /End-free
-
-
- < OCCTEST1 >
-
- H nomain
-
- /Include OCCTEST_H
-
- P testOccur1 B Export
- D testOccur1 PI 3I 0
-
- D o S 3 0
-
- /Free
- o = %Occur(myMODS) ;
- %Occur(myMODS) = 3 ;
- Return o ;
- /End-free
-
- P testOccur1 E
-
- < OCCTEST2 >
-
- H nomain
-
- /Include FTPSRC,FTEST_H
-
- P testOccur2 B Export
- D testOccur2 PI 3I 0
-
- D o S 3 0
-
- /Free
- o = %Occur(myMODS) ;
- %Occur(myMODS) = 5 ;
- Return o ;
- /End-free
-
- P testOccur2 E
-
-
|
|
|