Skip to main content

Posts

Showing posts with the label car brand

Struct

Struct A struct can be viewed upon as a class with no method, only attributes. It can store several values of different data types, but one struct can only hold one set of values. static void Collection_Struct(Args _args) { // Create a struct with two fields struct myCar = new struct ("int ModelYear; str Carbrand"); int i; ; // Set values to the fields myCar.value("ModelYear", 2000); myCar.value("Carbrand", "BMW"); // Add a new field and give it a value myCar.add("Model", "316"); // Loop through the fields of the struct for (i=1; i<=myCar.fields(); i++) { info(strfmt("FieldType: %1, FieldName: %2, Value: %3", myCar.fieldType(i), myCar.fieldName(i), myCar.value(myCar.fieldName(i)))); } }