Page 1 of 1

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

Posted: 3 Jun 2014 13:15
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.

Posted: 3 Jun 2014 15:17
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)".

Thanx alot

Posted: 3 Jun 2014 15:29
by fred malack
Thanx alot i will implement that and i will be copying and paste the whole code
Thank you alot...