Struct.fields Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Returns the number of items in the struct.
public:
virtual int fields();
public virtual int fields ();
abstract member fields : unit -> int
override this.fields : unit -> int
Public Overridable Function fields () As Integer
Returns
The number of items in the struct.
Remarks
To find the position of an item in a struct, use the Struct.index method.
The following example creates a struct from a container and then uses the fields method to iterate through the contents of the container.
boolean unpack(container packed)
{
Struct unpackedProperties;
container structCon;
Counter i;
[#currentList,structCon] = packed;
unpackedProperties = Struct::create(structCon);
for (i=1;i<=unpackedProperties.fields();i++)
{
switch (unpackedProperties.fieldName(i))
{
case #closedOk:
break;
case #PropertyCaption:
if (! dialogForm
|| dialogForm
&& ! dialogForm.form().design().caption())
this.caption(unpackedProperties.valueIndex(i));
break;
case #dialogFormname:
// Do nothing
break;
case #PropertyAlwaysOnTop:
this.alwaysOnTop(unpackedProperties.valueIndex(i));
break;
case #PropertyWindowType:
this.windowType(unpackedProperties.valueIndex(i));
break;
case #defaultButton:
this.defaultButton(unpackedProperties.valueIndex(i));
break;
default:
throw error(strfmt(
"@SYS67326",unpackedProperties.fieldName(i),
classId2Name(classidget(this))));
}
}
return true;
}