PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Sunday, October 30, 2022

[FIXED] How to send EOF on Prolog swipl REPL on Windows to close the pseudo user file?

 October 30, 2022     eof, prolog, prolog-toplevel, swi-prolog     No comments   

Issue

I'm using the swipl.exe Prolog REPL on Windows and trying to use the user pseudo file opened with [user]. but I can't figure out the key shortcut to leave the pseudo file:

c:\code>swipl.exe
Welcome to SWI-Prolog (threaded, 64 bits, version 8.0.3)

1 ?- [user].
|: hello :- format('Hello world~n').
|: ^Z

.

ERROR: user://1:9:3: Syntax error: illegal_character
|:
Action (h for help) ? ^C
c:\code>

Starting at the ^Z I typed the keys

  • CTRL+Z
  • ENTER (I expected here should have sent the EOF)
  • ENTER
  • .
  • ENTER (this shows an error, and puts me back into the pseudo file)
  • CTRL+C (this kills only one of the two swipl processes, leaving the console in a broken state with some keystrokes going to swipl and some going to cmd(!))

I know that on a blank line pressing CTRL+Z then ENTER normally works to send EOF, like if in more.com I type A ENTER B ENTER CTRL+Z ENTER everything works on my terminal.


If I run the swipl-win.exe GUI following the same key steps, immediately when I press CTRL+Z it closes the pseudo file and returns me to the top-level query:


?- [user].
|: hello :- format('Hello world~n').
|: 
% user://1 compiled 0.00 sec, 1 clauses
true.

?- hello.
Hello world
true.

?- 

What do I press to get [user]. to work in swipl.exe?


Solution

As you noticed, when you type [user], you're consulting a pseudo source file, which is made of terms. Therefore, simply type the term end_of_file. For example:

?- [user].
|: a.
|: b.
|: end_of_file.

% user://1 compiled 0.00 sec, 2 clauses
true.


Answered By - Paulo Moura
Answer Checked By - Robin (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing