(!******************************************************
Mosel User Guide Example Problems
=================================
file recorddef.mos
``````````````````
Defining and initializing records.
(c) 2008 Fair Isaac Corporation
author: S. Heipcke, Nov. 2006, rev. Sep. 2018
*******************************************************!)
model "Defining records"
public declarations
R = 1..10
D: public record
name: string
values: array(R) of real
end-record
end-declarations
public declarations
mydata = public record ! Define a named record
name: string
values: array(R) of real
end-record
M: mydata
A: dynamic array(T:range) of mydata
end-declarations
D.name:= "D"
forall(i in R) D.values(i):= i
writeln("Values of ", D.name, ": ", D.values)
initializations from "recorddef.dat"
A
end-initializations
writeln("An entry of A: ", A(1))
writeln("'name' of an entry of A: ", A(4).name)
writeln("'values' of an entry of A: ", A(3).values)
writeln("First entry of 'values' of 'A4': ", A(4).values(1))
forall(i in T | exists(A(i))) writeln(A(i).name)
end-model
|
(!******************************************************
Mosel User Guide Example Problems
=================================
file recorddef2.mos
```````````````````
Defining and initializing records.
- Records within records,
selection of fields in initializations -
(c) 2008 Fair Isaac Corporation
author: S. Heipcke, Sep. 2007, rev. Sep. 2018
*******************************************************!)
model "Defining records"
public declarations
R = 1..10
mydata = public record ! Define a named record
name: string
values: array(R) of real
end-record
B: dynamic array(T:range) of public record ! Define an unnamed record
val: real
rd: mydata ! Record field containing a record
end-record
end-declarations
initializations from "recorddef2.dat"
B(rd) as "B"
B(val) as "C"
B(rd(name)) as "D"
B(rd(values)) as "E"
B(rd(values)) as "F"
end-initializations
writeln(B)
end-model
|