| |||||||||||||||||||||||||||||||||||||||||
Reading and writing records and lists Description This set of examples shows how to work with advanced data structures when accessing data in spreadsheets and databases:
Further explanation of this example: Xpress Whitepaper 'Using ODBC and other database interfaces with Mosel', Section Examples - Working with lists - Working with records.
Source Files By clicking on a file name, a preview is opened at the bottom of this page. Data Files
listinout1.mos (!****************************************************** Mosel Example Problems ====================== file listinout1.mos ``````````````````` Reading/writing lists from/to text files. (c) 2008 Fair Isaac Corporation author: S. Heipcke, Nov. 2007 *******************************************************!) model "List handling (Text file)" declarations R: range LI: list of integer LS,LS2: array(R) of list of string ! With text data files we can use ! compositions of structured types end-declarations initializations from "listdata.dat" LI as "List1" LS as "List2" end-initializations ! Display the lists writeln("LI: ", LI) writeln("LS: ", LS) ! Reverse the list LI reverse(LI) ! Append some text to every entry of LS forall(i in R) LS2(i):= sum(l in LS(i)) [l+" year"+i] ! Display the modified lists writeln("LI: ", LI) writeln("LS2: ", LS2) initializations to "listout.dat" LI as "List1Out" LS2 as "List2Out" end-initializations end-model | |||||||||||||||||||||||||||||||||||||||||
© Copyright 2024 Fair Isaac Corporation. |