home *** CD-ROM | disk | FTP | other *** search
- :- module tracehlp. % what newtrace needs
-
-
- :- public
- hide_cursor / 0 : far, /* In module: ARITY5.ARI */
- restore_cursor / 0 : far, /* In module: ARITY5.ARI */
- getglobal / 2 : far, /* In module: LIBRARY.ARI */
- non_empty / 1 : far, /* In module: LIBRARY.ARI */
- addout / 2 : far, /* In module: filemod.ARI */
- rem_global_value / 1 : far, /* In module: LIBRARY.ARI */
- setglobal / 2 : far. /* In module: LIBRARY.ARI */
-
- :- public non_empty / 1 : far.
-
-
- restore_cursor :- !.
- hide_cursor :- !.
-
- /*************************************************************************/
- /***************** Source Code for Global Variable Predicates ************/
- /*************************************************************************/
-
-
-
- %%%%%%%%%%%%%%%% setglobal : set value of global variable %%%%%%%%%%
-
- setglobal( Var, Val ) :-
- recorded( Var, zzz_global_value( _ ), Ref),
- !,
- ( replace( Ref,
- zzz_global_value( Val )
- ),
- !
- ;
- remglobal( Var),
- setglobal( Var, Val)
- ).
-
- setglobal( Var, Val ) :-
- recorda( Var, zzz_global_value( Val ) , _).
-
-
- %%%%%%%%%%%%%%%% getglobal : get value of global variable %%%%%%%%%%
-
- getglobal( Var, Val) :-
- recorded( Var, zzz_global_value( Val ) , _).
-
- %%%%%%%%%%%%%%%% has_global_value : true if variable has global value %%%%%
-
- has_global_value( Var) :-
- recorded( Var, zzz_global_value( _ ) , _).
-
- %%%%%%%%%%%%%%%% rem_global_value : remove global value %%%%%%%%%%%%%%%%%%%
-
- remglobal( Var ) :-
- recorded( Var, zzz_global_value( _ ), Ref),
- !,
- hard_erase( Ref).
- remglobal( _).
-
- rem_global_value( Var ) :-
- remglobal( Var ) .
-
-
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- %%%%%%%%%%%% addout : add output to the end of a file %%%%%%%%%%%%%%%%%%%%%%%
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- /*
- PURPOSE : add output to the end of a file.
-
- CALL: addout( File , Term )
-
- INPUT ARGS:
-
- File = file to write the output from Term to. This output is put
- at the end of the file. If the file does not exist, one
- is created.
-
- Term = a term which is executed. Output from write, nl, etc.
- go to File instead of to the screen.
-
- SUCCESS CONDITIONS:
-
- Succeeds when Term succeeds, fails when Term fails.
-
- WHEN TO USE THIS:
-
- If you want to write some output to a file, you can write
- a goal to do it just like you would to the screen. If
- GOAL is the goal that produces the output and FILE is the
- file you want to write it to, call
-
- addout( FILE , GOAL )
-
- Each time 'addout' is called, it writes the output to the
- end of FILE, and then CLOSES the file. This guarantees that
- even if the program crashes, the output already produced
- is safe in the file.
-
- */
-
- :- mode addout( + , + ).
-
- addout( File , Term ) :-
- open_for_appending( Handle, File),
- tell_h( Handle ),
- (
- call( Term ),
- !,
- told,
- close( Handle )
- ;
- !,
- told,
- close( Handle ),
- fail
- ).
-
-
-
- /*
- #########################################################################
- open_for_appending
- #########################################################################
-
- Call:
-
- open_for_appending(Outhandle, Filename)
-
- Input args:
-
- Filename = name of file to be opened for appending
-
- Output args :
-
- Outhandle = handle for file of name Filename open for appending
-
- Effect: Opens file of name Filename for appending. Opens existing
- file if there is one. Creates new file if necessary.
-
- Success conditions:
-
- Succeeds whenever Filename can be opened for appending.
-
- */
- open_for_appending(Outhandle, Filename) :-
- file_exists(Filename),!,
- open(Outhandle, Filename , a).
-
- open_for_appending(Outhandle, Output_file ) :-
- create_new_file_for_appending(Outhandle,Output_file).
-
-
-
- /*
- #########################################################################
- File Exits
- #########################################################################
-
- */
-
- file_exists(Filename):-
- directory(Filename,_,_,_,_,_). /* look for Filename on disk */
- /* succeed if there */
-
-
- /*
- #########################################################################
- create_new_file_for_appending
- #########################################################################
-
- create_new_file_for_appending(Outhandle,Output_file)
-
- Opens an output file for appending stuff into the file.
-
- Arument Mode Function
- ------- ---- --------
- Outhandle out output file handle, file open for append
- Output_file in name of file to be opened for append
-
- */
-
- create_new_file_for_appending(Outhandle,Output_file):-
- create(H1,Output_file),
- close(H1),
- open(Outhandle,Output_file,a).
-
-
-
-
- /*************************************************************************/
- /********* non_empty : true for non-empty sets ***************************/
- /*************************************************************************/
-
- % mode revised by rk 9-28-89
- :- mode non_empty( + ).
-
- non_empty( [_ | _ ]).
-
-
-
-
- %%%%%%%%%%%%%%%%%%%% eof %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%