Please i need help on how i can fix the following error please.

Discussions related to Visual Prolog
fred malack
Active Member
Posts: 28
Joined: 9 Mar 2014 6:35

Please i need help on how i can fix the following error please.

Unread post by fred malack »

I question that concerned with
Output the diagnose diseases

Code: Select all

  Predicates       gradeDisease: (name Patient) nondeterm.     clauses       gradeDisease(Patient,Disease),       VpiCommonDialogs::note(Patient,tostring(Disease)).
The above code output the name of the patient and the disease..
I changed the clauses part so that when it doesnt diagnose
To give a note that couldnt diagnose..

Code: Select all

clauses   gradesDisease(Patient) :-      If  hypothesis(Patient, Disease) then             VpiCommonDialogs::note(Patient,tostring(Disease))        else              VPiCommonDialogs::note(Patient, "couldnt diagnose")   End if.
The problem i have i that it diagnose and give out only one disease please i need help.
fr@dlu
User avatar
Thomas Linder Puls
VIP Member
Posts: 1181
Joined: 28 Feb 2000 0:01

Unread post by Thomas Linder Puls »

I notice that you code snippets are very wrong when it comes to casing (notice the color of things).

Why don't you copy/paste the code from your program so that it is at least syntactically correct?

Anyways, there is no "simple and neat" solution to that problem. I will however suggest that you create a single message to write in the "note", for example like this:

Code: Select all

clauses     gradesDisease(Patient) :-         S = outputStream_string::new(),         S:writef("% may suffer from: ", Patient),         Found = varM::new(false),         foreach hypothesis(Patient, Disease) do             if true = Found:value then S:write(", ") end if,             Found:value := true,             S:writef(Disease)          end foreach,          if false = Found:value then S:write("(no matching diagnosis)") end if,          Msg = S:getString(),          vpiCommonDialogs::note(Patient, Msg).
An outputStream_string is an outputStream that collects the written stuff into a string. The varM (Found) is a mutable variable which is set to true when the first Disease is diagnosed.

The flag is both used to deside whether there should be a a comma in front of the disease, and to deside whether to write "(no matching diagnosis)".
Regards Thomas Linder Puls
PDC
fred malack
Active Member
Posts: 28
Joined: 9 Mar 2014 6:35

Thanx alot

Unread post by fred malack »

Thanx alot i will implement that and i will be copying and paste the whole code
Thank you alot...
fr@dlu
Post Reply