- Procedure CloneElement(updateSet, originalElement, cloneName, cloneElement, includeDefinedSubsets)
CloneElement
The procedure CloneElement copies the data associated with a
particular element to another element.
CloneElement(
updateSet, ! (input, output) a set identifier
originalElement, ! (input) an element in the set
cloneName, ! (input) a string that is the name of the clone
cloneElement, ! (output) an element parameter
includeDefinedSubsets ) ! (optional) an integer, default 0.
The procedure CloneElement performs the following actions:
It creates or finds an element with name
cloneName:cloneElement. The elementcloneElementis inserted intoupdateSetif it is not already there. This insertion is only permitted ifupdateSetdoes not have a definition.For each domain set of
updateSet, sayinsertDomainSet, the elementcloneElementis inserted intoinsertDomainSetif it is not already there. Such an insertion is only permitted ifinsertDomainSetdoes not have a definition.For each subset of
updateSet, sayinsertSubsetin whichoriginalElementis an element,cloneElementis also inserted intoinsertSubset. IfincludeDefinedSubsetsis 0, theninsertSubsetis skipped if it is a defined subset.The domain sets of steps 1 and 2, and the sets modified in step 3 form a set, say
modifiedSets.Identifiers declared over a set in
modifiedSetsthat meet one of the following criteria, are selected:It is a non-local multi-dimensional set without a definition.
It is a non-local parameter without a definition.
It is a variable.
It is a constraint.
These identifiers form the set
modifiedIdentifiers.For each identifier in the set
modifiedIdentifiers, and all suffixes of this identifier, the data associated with elementoriginalElementis copied tocloneElement.
Arguments
- updateSet
A one-dimensional set.
- originalElement
An element valued expression that should result in an element in
updateSet.- cloneName
A string expression that should result in a name that is in the set
updateSetor can be added to that set.- cloneElement
An element parameter, in which the resulting element is stored.
- includeDefinedSubsets
When non-zero, defined subsets are included in the
modifiedSetsas well. When these defined subsets are evaluated thereafter again, this may result in the creation of inactive data. Inactive data can be removed by aCLEANUPorCLEANDEPENDENTSstatement, see Data Control of the Language Reference. Defined subsets that are defined as an enumeration are never included.
Return Value
The procedure returns 1 if successful and 0 otherwise. Possible reasons for returning 0 are:
originalElementis not inupdateSet.
cloneNameequals name oforiginalElement.There are no identifiers modified.
Note
If you want to make sure that the string cloneName is not yet an
element in updateSet, use a statement like:
if ( not ( cloneName in updateSet ) ) then
CloneElement( ... );
endif ;
Example
With the following declarations (and initial data):
Set S { Index : i, j; Parameter : ep; InitialData : data { a }; } Parameter P { IndexDomain : i; InitialData : data { a : 1 }; } Parameter Q { IndexDomain : (i,j); InitialData : data { ( a, a ) : 1 }; }the statement
CloneElement( S, 'a', "b", ep );results in
S,P,Qandephaving the following data:S := data { a, b } ; P := data { a : 1, b : 1 } ; Q := data { ( a, a ) : 1, ( a, b ) : 1, ( b, a ) : 1, ( b, b ) : 1 } ; ep := 'b' ;
See also
The function
StringToElement, the procedureFindUsedElementsand the procedureRestoreInactiveElements.