In this example, we call the following RPG program using nested structures:
D
DS_A
DS
D
MBR1
10a
D
MBR2
8p 2
D
MBR3
8p 2
D
DS_P
DS
qualified
D
MBRD
likeds(ds_A)
D
PARM1
DS
likeds(ds_P)
D
PARMT
S
10a
D
PARMA
S
8p 2 Dim(3)
D
PARMI
S
8p 2
C
*entry
plist
C
PARM
PARM1
C
PARM
PARMT
C
PARM
PARMA
C
PARM
PARMI
/free
PARM1.MBRD.MBR2 =
PARM1.MBRD.MBR3;
PARMT =
'azeOK';
PARMA(1) = 1 +
PARMA(1);
PARMA(2) = 2 +
PARMA(2);
PARMA(3) = 3 +
PARMA(3);
PARMI = PARMI +
1;
return;
/end-free
From Windev 27, we can directly send a complex Windev structure (Windev structures containing other Windev structures), thus faithfully representing the parameters of their programs (structure description and/or program of a PCML) even the most complicated, and this without mapping, splitting, into a single variable which will be filled/updated directly by Easycom.
sPCML est une chaîne
sPCML = [
<pcml version="6.0">
<struct name="DS_A">
<data name="MBR1"
type="char" length="10" usage="inherit" />
<data name="MBR2"
type="packed" length="8" precision="2"
usage="inherit" />
<data name="MBR3"
type="packed" length="8" precision="2"
usage="inherit" />
</struct>
<!-- 7 -->
<struct name="DS_P">
<data name="MBRD"
type="struct" struct="DS_A" usage="inherit" />
</struct>
<program name="SAMPLEDS6"
entrypoint="SAMPLEDS6">
<data name="PARM1"
type="struct" struct="DS_P" usage="inputoutput"
/>
<data name="PARMT"
type="char" length="10" usage="inputoutput" />
<data name="PARMA"
type="packed" length="8" precision="2"
usage="inputoutput" count="3" />
<data name="PARMI"
type="packed" length="8" precision="2"
usage="inputoutput" />
</program>
</pcml>
]
DS_A est Structure
mbr1 est une chaîne sur
10
mbr2 est un réel
mbr3 est un réel
FIN
sDS_A est DS_A
DS_P est Structure
mbrd est une DS_A
FIN
sDS_P est DS_P
sDS_A:mbr1 =
"aura"
sDS_A:mbr2 = 1
sDS_A:mbr3 = 3
sDS_P.mbrd = sDS_A
PARMA est un tableau de 3
réels
PARMA[1] = 10
PARMA[2] = 20
PARMA[3] = 30
PARMT est une chaîne
PARMT = "qsd"
PARMI est un réel
PARMI = 2;
completeStruc est une Structure
PARM1 est DS_P
PARMT est une chaîne
PARMA est un tableau de 3
réels
PARMI est un réel
FIN
SAMPLEDS6 est completeStruc
SAMPLEDS6.PARM1 =
sDS_P
SAMPLEDS6.PARMT =
PARMT
SAMPLEDS6.PARMA =
PARMA
SAMPLEDS6.PARMI =
PARMI
HOuvreConnexion(MaConnexion)
ASExec("ADDLIBLE EASYCOMXM3",MaConnexion)
// New way, compatible with complex and nested structures
SI PAS ASPgmCall(sPCML, "SAMPLEDS6",MaConnexion,
SAMPLEDS6) ALORS
Info(ErreurInfo(errComplet))
Info("PARM1.MBRD.MBR2=" + sDS_P:mbrd:mbr2)
SINON
Trace("PARM1.MBRD.MBR2=" + SAMPLEDS6:PARM1:mbrd:mbr2)
Trace("PARM1.MBRD.MBR3=" + SAMPLEDS6:PARM1:mbrd:mbr3)
Trace("PARMT=" + SAMPLEDS6:PARMT)
Trace("PARMA[1]=" + SAMPLEDS6:PARMA[1])
Trace("PARMA[2]=" + SAMPLEDS6:PARMA[2])
Trace("PARMA[3]=" + SAMPLEDS6:PARMA[3])
Trace("PARMI=" + SAMPLEDS6:PARMI)
FIN
Before Windev 27, the program was called as follows:
SI PAS ASPgmCall(sPCML, "SAMPLEDS6",MaConnexion, sDS_P, PARMT, PARMA, PARMI) ALORS
Info(ErreurInfo(errComplet))
Info("PARM1.MBRD.MBR2=" + sDS_P:mbrd:mbr2)
SINON
Trace("sDS_P.MBRD.MBR2=" + sDS_P:mbrd:mbr2)
Trace("sDS_P.MBRD.MBR3=" + sDS_P:mbrd:mbr3)
Trace("PARMT=" + PARMT)
Trace("PARMA[1]=" + PARMA[1])
Trace("PARMA[2]=" + PARMA[2])
Trace("PARMA[3]=" + PARMA[3])
Trace("PARMI=" + PARMI)
FIN