ruman29
03-12-2007, 12:03 PM
sure.
Here is the code from the main program, reading from one file and writing to another :
write('Can i have your first name only please.'),nl,
write('> '),
read_in(Input1),
[H|T] = Input1,
open(H, 'write', K),
open('patterns.pl', 'read', P),
read(P,Term),
write(K,Term),write(K,'.'), nl(K),
read(P,Term1),
write(K,Term1),write(K,'.'),nl(K),
read(P,Term2),
write(K,Term2),write(K,'.'),nl(K),
read(P,Term3),
write(K,Term3),write(K,'.'),nl(K),
read(P,Term4),
write(K,Term4),write(K,'.'),nl(K),
read(P,Term5),
write(K,Term5),write(K,'.'),nl(K),
read(P,Term6),
write(K,Term6),write(K,'.'),nl(K),
read(P,Term7),
write(K,Term7),write(K,'.'),nl(K),
close(K),
close(P),
Here is the file being READ:
:- dynamic(pattern/1).
pattern([1,my,name,is,2], ['I',already,know,your,name,its,on,your,file,.,'Now ',please,tell,me,about,yourself,.]).
pattern([1,dream,2], [X]) :- dream(X).
pattern([what,can,you,1], ['Is',it,important,if,1,?]).
pattern([1,X,2], [Y]) :- sadfeelings(X,Y).
pattern([1,X,2], ['Please',dont,use,that,kind,of,language,.,'Its',ve ry,crude]) :- swearwords(X).
pattern([1,tomorrow,2], [X]) :- tomorrow(X).
pattern([1,X,2], ['It',is,a,beautiful,game,.,'Do',you,play,much,X,?]) :- sport(X).
And here is the problem where the variables are not binding correctly in the file being WRITTEN to.
:-dynamic pattern/1.
pattern([1, my, name, is, 2], [I, already, know, your, name, its, on, your, file, ., Now, please, tell, me, about, yourself, .]).
pattern([1, dream, 2], [_G385]):-dream(_G385).
pattern([what, can, you, 1], [Is, it, important, if, 1, ?]).
pattern([1, _G432, 2], [_G438]):-sadfeelings(_G432, _G438).
pattern([1, _G453, 2], [Please, dont, use, that, kind, of, language, ., Its, very, crude]):-swearwords(_G453).
pattern([1, tomorrow, 2], [_G509]):-tomorrow(_G509).
pattern([1, _G523, 2], [It, is, a, beautiful, game, ., Do, you, play, much, _G523, ?]):-sport(_G523).
Can you shed any light on it? Thanks
Trap D
03-14-2007, 06:07 AM
If you just want to copy files without any change you can do this :
write('Can i have your first name only please.'),nl,
write('> '),
read_in(Input1),
[H|_] = Input1,
open(H, 'write', K),
open('patterns.pl', 'read', P),
copy_stream_data(P, K),
close(K),
close(P).
vBulletin, Copyright ©2000-2010, Jelsoft Enterprises Ltd.