Re: Newbie problem
- From: Jan Wielemaker <jan@xxxxxxxxxxxxxxxxxxx>
- Date: 20 May 2007 08:10:54 GMT
On 2007-05-19, angelraposo@xxxxxxxxx <angelraposo@xxxxxxxxx> wrote:
On 19 mai, 21:10, Jan Wielemaker <j...@xxxxxxxxxxxxxxxxxxx> wrote:
<snip>
On 2007-05-19, angelrap...@xxxxxxxxx <angelrap...@xxxxxxxxx> wrote:
It probably executes it already, but the user_output stream is
line-buffered, so it doesn't write anything as long as there is
no newline or explicit flush. When reading from the console a
flush of the output is implied. When reading from the GUI this
no longer works and you'll have to call flush_output/1 explicitely.
--- Jan
Oh, I don�t think that's the problem becuase I also tried to append a
text to my editor to check if it was executing. It�s a problem with
the "string" received from the user. According to my rules, when I�m
using the prolog console, it recognized that I wrote the how command
and the variable Objective takes the rest of the text as its value
Adding the execute(_) catch all or using ?- spy(execute/1). would have
saved time for all of us ...
execute(how(Objetive)):-
write('I�m working`),
how(Objetive),
!.
I've also tried the next:
execute('how(Objetive)'):-
write('I�m working`),
how(Objetive),
!.
In this case if the user writes literaly 'how(Objective)' the message
it�s printed. However in the normal case if the user writes
'how(bird('mybird'))' it doesn�t recognize that the user is writing a
how command (and obviosuly it doesn't give the variable Objective the
right value). It just goes to the failure message "command not
recognized" which is the last order.
execute(_):-
write('Command not recognized....`),
!.
Is there anyway in prolog to define a rule like execute(something
begining with 'how') and later take out the part of text I need?
* Define a syntax to use and write a DCG (Grammar rules) for
it.
* When using Prolog syntax, use atom_to_term/3.
* Use hacky tests such as sub_atom/5.
* Use one of the zillion other possibilities ...
Consider an A-Z scan of the predicate summary in the documentation. It
gives you an impression what is there and which terms are used in the
documentation, so you can use the search page at
http://gollem.science.uva.nl/SWI-Prolog/pldoc/
--- Jan
.
- References:
- Newbie problem
- From: angelraposo
- Re: Newbie problem
- From: Jan Wielemaker
- Re: Newbie problem
- From: angelraposo
- Newbie problem
- Prev by Date: Re: Newbie problem
- Next by Date: Re: Prolog and AION
- Previous by thread: Re: Newbie problem
- Next by thread: XPCE: text_item maximum allowed length
- Index(es):
Relevant Pages
|