Para ilustrar que se pueden manipular metadatos, el ejemplo siguiente de una aplicación externa imprime lo siguiente:
Esta subrutina utiliza una rutina denominada StdOut, que imprime los argumentos en un recuadro de mensaje.
Sub DumpOneEntityDef(edef) ' the parameter is an EntityDef object
Dim names ' Variant
Dim name ' String
Dim limit ' Long
Dim index ' Long
StdOut "Dumping EntityDef " & edef.GetName
StdOut " FieldDefs:"
names = edef.GetFieldDefNames
If IsArray(names) Then
index = LBound(names)
limit = UBound(names) + 1
Do While index < limit
name = names(index)
StdOut " " & name & " type=" & edef.GetFieldDefType(name)
index = index + 1
Loop
End If
names = edef.GetActionDefNames
If IsArray(names) Then
index = LBound(names)
limit = UBound(names) + 1
Do While index < limit
name = names(index)
StdOut " " & name & " type=" & _
edef.GetActionDefType(name)
index = index + 1
Loop
End If
If edef.GetType() = AD_REQ_ENTITY Then
' tipo de registro con estado
StdOut " EntityDef is a REQ entity def"
StdOut " StateDefs:"
names = edef.GetStateDefNames
If IsArray(names) Then
index = LBound(names)
limit = UBound(names) + 1
Do While index < limit
name = names(index)
StdOut " " & name
index = index + 1
Loop
End If
Else
' stateless record type
StdOut " EntityDef is an AUX entity def"
End If
StdOut ""
End Sub
REM Start of Global Script StdOut
sub StdOut(Msg)
msgbox Msg
end sub
REM End of Global Script StdOut
use strict;
use CQPerlExt;
my $sessionObj = CQSession::Build();
$sessionObj->UserLogon("admin", "", "SAMPL", "");
my $entityDefNames = $sessionObj->GetEntityDefNames();
#Iterate over the record types
foreach my $edef_name (@$entityDefNames) {
my $entityDefObj = $sessionObj->GetEntityDef($edef_name);
print_edef($entityDefObj);
}
sub print_edef {
my($edef)=@_;
# The parameter is an EntityDef object.
my($names, $name);
print "Dumping EntityDef ", $edef->GetName;
print "\nFieldDefs:";
$names = $edef->GetFieldDefNames;
foreach $name (@$names) {
print " " , $name , " type=" ,
$edef->GetFieldDefType($name);
}
print "\nActionDefs: ";
$names = $edef->GetActionDefNames;
foreach $name (@$names) {
print " " , $name , " type=" ,
$edef->GetActionDefType($name);
}
if ($edef->GetType == $CQPerlExt::CQ_REQ_ENTITY) {
# tipo de registro con estado
print "\nEntityDef is a REQ entity def";
print "\nStateDefs:";
$names = $edef->GetStateDefNames;
foreach $name (@$names) {
print " " , $name;
}
}
else {
# stateless record type
print "\nEntityDef is an AUX entity def";
}
print "\n\n";
}
CQSession::Unbuild($sessionObj);