I am having trouble with file input/output in SWI-Prolog.
The basic idea is I need to ask the user to input a file that contains three fields (ID, Name, Grade). I need to input that text into a list. Here is my input implementation:
load_file :- seeing(Old), see(user), write('Enter name of file to load: '), read(File), see(File), repeat, read(Data), process(Data), seen, see(Old), !.
All of the information they provide in their text file should go into my "Roster" list. The add_student function I have implemented works well, do I need to parse that file and call my add_student function to add each list of information to my Roster list?
As for Output, I'm having slightly better luck. The only problem is the resulting text file I get has erroneous results. Here is my store_file implementation:
store_file :- telling(Old), tell(user), write('Enter name of file to save as: '), read(File), tell(File), write(Roster), write('.'), nl, told.
I was under the impression that write(Roster) would write out the entire List of lists (Roster) without me needing to iterate through every list of information (ID, Name, Grade). Any help would be much appreciated, thank you!