0

Hi I have program ("expert program") in which user choose few button options and this program search in predicates cars with this checked options. After this I wish to display this one or more predicates in window. This is few line of program. Predicates format:

auto(audi,a4,bialy,sedan,120).

auto(audi,a6,czerwony,sedan,160).

And fragment in which I wish display:

 X=auto(Marka,_,Kolor,Nadwozie,Km),
send(Cars,append(text(X))),

I am trying to assign the entire predicate to a variable, and I probably can not. How can I view this data in a different way?

EDIT:

I found class "findall()" which help a lot:

findall(Model,auto(Marka,Model,Kolor,Nadwozie,Km),X),
send(Cars,append(char_array(X))),

Now is ok, in console work, but not in XPCE, Prolog catch error in console:

ERROR: [Thread pce] char_array ->initialise: Argument 1 (text): char_array' expected, found[a2,a3]'

And what now? I think error is in "char_array(X)" but why this not work?

didi
  • 21
  • 3
  • What do you mean by "display a predicate" or to "assign an entire predicate to a variable". A single predicate clause might be, for example, `foo(A, B) :- bar(A), gah(B).` and that could be assigned to a variable as `X = :-(foo(A,B), (bar(A), gah(B))).` You could then assert that predicate later via `assertz(X)`. But I suspect that's not what you really mean. – lurker Mar 11 '18 at 18:44
  • Did you mean "expert system" in place of "expert program"? – false Mar 12 '18 at 10:29
  • Yes false I mean expert system. lurker yes, you guessed my intentions, but I need show this variable as a result in new window – didi Mar 14 '18 at 15:49

1 Answers1

0

Maybe you can try

...
with_output_to(atom(X), write(auto(Marka,_,Kolor,Nadwozie,Km))),
send(Cars,append(text(X))),
...
CapelliC
  • 59,646
  • 5
  • 47
  • 90
  • this is correct in 50%, works but as result i have values which I choose in radio buttons, not this from matching predicates – didi Mar 14 '18 at 15:40
  • it's show: Auto choose for you: auto(audi,_50,white,sedan,80-150) but I wish this form for example: Auto choose for you: audi,a3,white,sedan,80 – didi Mar 14 '18 at 16:05