This is a discussion on Problem with calling string from object - PROLOG ; Hi I keep on coming up with this error “variable not completely bound” and “variable not used” and yet I have used it. I don’t understand why it comes about. I create a project, then I create a class student. ...
Hi
I keep on coming up with this error “variable not completely bound”
and “variable not used” and yet I have used it. I don’t understand
why it comes about. I create a project, then I create a class student.
I want to create an object, and then use it to save the sex of a student
as a string like ‘male’ and retrieve it using a form. I bind the input
using a form to the constructor to create the object, but I can’t get it
back in the retrieve form to show in the text box. Here is part of the
code ( or nearly all). I hope you understand it well enough to help me,
because it taking me a lot of days now and I haven’t got past it.
student.cl
class student : student
open core
predicates
classInfo : core::classInfo.
% @short Class information predicate.
% @detail This predicate represents information predicate of this class.
% @end
constructors
new: (string Sex).
end class student
student.i
interface student
open core
predicates
getSex: ()-> string Sex.
setSex: (string Sex).
end interface student
student.pro
implement student
open core
facts
sexh: string.
constants
className = "student/student".
classVersion = "".
clauses
classInfo(className, classVersion).
clauses
new(Sex):-
sexh:=Sex.
getSex()=sexh.
setSex(Sex):-
sexh:=Sex.
end implement student
% code for button to gt text from textbox
predicates
onPushButtonClick : button::clickResponder.
clauses
onPushButtonClick(_Source) = button::defaultAction:-
Sex=save_ctl:getText(),
SavedData=student::new(Sex),
_Captured= SavedData:setSex(Sex).
% code for button to retreive saved sex to the textbox
predicates
onPushButtonClick : button::clickResponder.
clauses
onPushButtonClick(_Source) = button::defaultAction:-
RetreiveCaptured=SavedData:getSex(),
retreive_ctl:setText(RetreiveCaptured).