-- seq_io_demo.adb demonstrate sequential IO on a type Real_Matrix with Text_io ; with Sequential_IO ; with Real_Matrix_Arithmetic; use Real_Matrix_Arithmetic; with Real_IO; procedure SEQ_IO_DEMO is package My_SIO is new Sequential_IO ( Real_Matrix ) ; -- package My_Stuff is new Sequential_IO ( My_Record ) ; -- any data type Output : My_SIO.File_Type ; -- must follow instantiation to get File_Type def Input : My_SIO.File_Type ; MAT_1 : Real_Matrix ( - 1 .. 1 , - 1 .. 2 ) := -- initialization (( 1.1 , 1.2 , 1.3 , 1.4 ) , -- Note that the structure ( 2.1 , 2.2 , 2.3 , 2.4 ) , -- of the object must be ( 3.1 , 3.2 , 3.3 , 3.4 )) ; -- used to initialize data. MAT_1A : Real_Matrix ( 0 .. 2 , 0 .. 3 ) ; -- same structure as MAT_1 MAT_2 : Real_Matrix ( 1 .. 4 , 0 .. 1 ) := ( ( 1.0 , 1.1 ) , ( 2.0 , 2.1 ) , ( 3.0 , 3.1 ) , ( 4.0 , 4.1 ) ) ; MAT_2A: Real_Matrix ( - 3 .. 0 , 5 .. 6 ) ; -- same structure as MAT_2 begin Text_IO.Put_Line ( "create a file and write matrices on it" ); My_SIO.Create ( Output , My_SIO.Out_File , "CREATE.TST" ) ; My_SIO.Write ( Output, MAT_1 ) ; My_SIO.Write ( Output, MAT_1 ) ; My_SIO.Write ( Output, MAT_2 ) ; My_SIO.Write ( Output, MAT_1 ) ; My_SIO.Write ( Output, MAT_2 ) ; My_SIO.Close ( Output ) ; Text_IO.Put_Line ( "Now close, open, and read the file" ); My_SIO.Open ( Input , My_SIO.In_File , "CREATE.TST" ) ; My_SIO.Read ( Input , MAT_1A ) ; My_SIO.Read ( Input , MAT_1A ) ; My_SIO.Read ( Input , MAT_2A ) ; My_SIO.Read ( Input , MAT_1A ) ; Text_IO.Put_Line ( "Third MAT_1A" ) ; Put ( MAT_1A ) ; My_SIO.Read ( INPUT , MAT_2A ) ; Text_IO.Put_Line ( "Last MAT_2A" ) ; Put ( MAT_2A ) ; Text_IO.New_Line; end SEQ_IO_DEMO ;