Geoff Sutcliffe wrote: > > Program file seebug > ------------ > go:- > seeing(Original), %----Save original input > see(data1), %----Look at data1 > readvar(input,Term1,_), %----Read first term from data1 > write('Outer read '),write(Term1),nl, %----Echo for the people > seeing(Current), %----Record where we're reading from > see(data2), %----Look at data2 > readvar(input,Term2,_), %----Read first term from data2 > write('Inner read '),write(Term2),nl, %----Echo for the people > seen, %----Look away from data2 > see(Current), %----Back to data1 > readvar(input,Term3,_), %----Read second term from data1 > write('Outer read '),write(Term3),nl, %----Echo for the people > seen, %----Look away from data1 > see(Original). %----Back to original input > > Data file data1 > --------- > data1(1). > data1(2). > > Data file data2 > --------- > data2(1). > data2(2). > > Execution > --------- > ECLiPSe Constraint Logic Programming System [kernel] > Copyright Imperial College London and ICL > Certain libraries copyright Parc Technologies Ltd > GMP library copyright Free Software Foundation > Version 5.0.0, Fri Jun 23 01:09 2000 > [eclipse 1]: use_module(library(quintus)). > cio.pl compiled traceable 2128 bytes in 0.01 seconds > foreign.pl compiled traceable 27012 bytes in 0.02 seconds > scattered.pl compiled traceable 6544 bytes in 0.01 seconds > cprolog.pl compiled traceable 3200 bytes in 0.02 seconds > quintus.pl compiled traceable 21792 bytes in 0.12 seconds > > yes. > [eclipse 2]: [seebug]. > seebug compiled traceable 940 bytes in 0.00 seconds > > yes. > [eclipse 3]: go. > Outer read data1(1) > Inner read data2(1) > Outer read data1(1) > > yes. > > The Error > --------- > Reads the first term from data1 twice (OK after that, btw). > > Cheers, > > Geoff > > Geoff Sutcliffe http://www.cs.jcu.edu.au/~geoff > School of Information Technology Email : geoff@cs.jcu.edu.au > James Cook University Phone : +61 7 47815085/47814622 > Townsville, Australia, 4811. FAX : +61 7 47814029 Hi Geoff, thanks for the report, this was apparently broken by some change in 5.0. We'll look into it.. In the meantime, you can use one of the following methods. The first one is the cleanest because it doesn't switch the input-stream globally (but requires you to pass the correct stream id to the read-primitives). The second one uses the Eclipse-specific set_stream/2 get_stream/2 primitives to switch the input-stream. The third one uses library(fromonto). %-------------------------- go:- open(data1, read, S1), readvar(S1,Term1,_), %----Read first term from data1 write('Outer read '),write(Term1),nl, %----Echo for the people open(data2, read, S2), readvar(S2,Term2,_), %----Read first term from data2 write('Inner read '),write(Term2),nl, %----Echo for the people close(S2), readvar(S1,Term3,_), %----Read second term from data1 write('Outer read '),write(Term3),nl, %----Echo for the people close(S1). %-------------------------- go:- get_stream(input, Original), open(data1, read, input), readvar(input,Term1,_), %----Read first term from data1 write('Outer read '),write(Term1),nl, %----Echo for the people get_stream(input, Current), open(data2, read, input), readvar(input,Term2,_), %----Read first term from data2 write('Inner read '),write(Term2),nl, %----Echo for the people close(input), set_stream(input, Current), readvar(input,Term3,_), %----Read second term from data1 write('Outer read '),write(Term3),nl, %----Echo for the people close(input), set_stream(input, Original). %-------------------------- :- lib(fromonto). go :- ( readvar(input,Term1,_), %----Read first term from data1 write('Outer read '),write(Term1),nl, %----Echo for the people ( readvar(input,Term2,_), %----Read first term from data2 write('Inner read '),write(Term2),nl %----Echo for the people ) from_file data2, readvar(input,Term3,_), %----Read second term from data1 write('Outer read '),write(Term3),nl %----Echo for the people ) from_file data1. -- Joachim Schimpf / phone: +44 20 7594 8187 IC-Parc, Imperial College / mailto:J.Schimpf@ic.ac.uk London SW7 2AZ, UK / http://www.icparc.ic.ac.uk/eclipseReceived on Mon Jan 08 11:22:03 2001
This archive was generated by hypermail 2.1.8 : Wed 16 Nov 2005 06:08:02 PM GMT GMT