%trace
domains
file = input;output
predicates
start
readline
%comp(string)
search(integer)
repeat
end
goal
clearwindow,
makewindow(1,7,20,"My Window",0,0,25,80),
start,
end.
clauses
start:-
openread(input,"Q3I.TXT"),
readdevice(input),
readline,!,
write("\n\nEnter the no::"),
readdevice(keyboard),
readint(No),
readdevice(input),
filepos(input,0,0),
search(No).
readline:-
not(eof(input)),
readln(Line),
str_len(Line,Len),
nl,write(Line," ",Len),
readline.
readline.
repeat.
repeat:-
repeat.
search(No):-
repeat,
readln(Line),
str_len(Line,Len),
No=Len,
openwrite(output,"Q3O.TXT"),
writedevice(output),
write(Line,"\n"),
closefile(output).
end:-
write("\n\nplease check output in file Q3O.TXT").
Input file:
¦my name is hiral ¦
¦my brohter name is ravi
¦my sister name is hemina ¦
¦i love my family
Output
+-----------------------------------My Window----------------------------------+
¦ ¦
¦my name is hiral 16 ¦
¦my brohter name is ravi 23 ¦
¦my sister name is hemina 24 ¦
¦i love my family 16 ¦
¦ ¦
¦Enter the no::24 ¦
please check output in file Q3O.TXT
Output file:
my sister name is hemina