##- # Author: Brian Tiffin # Dedicated to the public domain # # Date: November 2016 # Modified: 2016-11-22/16:40-0500 ##+ # # record-operations.icn, demonstrate records # link ximage # record initializers are in the global name space record sample(field1, field2, field3) procedure main() # records are created by the initializer R1 := sample("value1", "value2", 3) # record field access uses the dot operator write("R1.field1: ", R1.field1) write("R1.field2: ", R1.field2) write("R1.field3: ", R1.field3) # Unicon also allows runtime creation of record constructors Rcon := constructor("runtime", "f1", "f2", "f3") # The new "runtime" initializer is now available as Rcon R2 := Rcon("v1", "v2", R1) write("\nR2.f1: ", R2.f1) write("R2.f2: ", R2.f2) # like all Unicon structures, fields can be arbitrarily nested write("R2.f3.field1: ", R2.f3.field1) write("type of R2: ", type(R2)) write("type of R2.f3: ", type(R2.f3)) end