Search found 47 matches

by George
19 Mar 2014 16:05
Forum: Visual Prolog
Topic: How to initialize single fact in a class that do not create object?
Replies: 2
Views: 2197

It is said that a single fact should be initialized in constructor. But if I have a class that do not create object, then it have no constructor,how to initialize my single fact? Code: class facts myFact : (string, string) single. clauses myFact("Test", "Cool"). %Fetch a value T...
by George
19 Mar 2014 6:55
Forum: Visual Prolog
Topic: unexpected end of file erro when read from external file
Replies: 4
Views: 3072

Code fix

The following code will works good for you, Use the same and let me know for any further support %Write data to another file only when it is not the end of stream class predicates copyLine : (inputStream I, outputStream O). clauses copyLine(I, O) :- if not(I:endOfStream()) then Line = I:readLine(), ...
by George
10 Mar 2014 12:15
Forum: Visual Prolog
Topic: Discontiguous facts
Replies: 6
Views: 3140

I have a project in which I am dynamically saving facts (functors) . The facts so saved are not contiguous. Because of this when another part of the project uses these facts it is unable to process the newly added facts. How can I have prolog pick all the facts. I know there is a discontiguous dire...
by George
7 Mar 2014 14:53
Forum: Visual Prolog
Topic: Advanced List handling
Replies: 19
Views: 9087

Dear Harrison Pratt, My intention is to make use of 7.4 version built in predicate - And try to minimize the code as much as possible... Ex : class predicates testForAllLoop : (). clauses testForAllLoop():- MyList = ["A", "B", "C", "D", "E", "F&...
by George
4 Mar 2014 10:14
Forum: Visual Prolog
Topic: Advanced List handling
Replies: 19
Views: 9087

Why use a predicate against its obvious intention? I agree with your point, Mr. Thomas Linder Puls.. I felt like code minimization - Instead of using too many predicates for doing small Job.. I could use "forAll/.." predicate to loop through.. When we have a option to break through - fore...
by George
4 Mar 2014 5:54
Forum: Visual Prolog
Topic: Advanced List handling
Replies: 19
Views: 9087

Is there any way we can terminate the forAll loop in middle of the processing ? Ex : class predicates testForAllLoop : (). clauses testForAllLoop():- MyList = ["A", "B", "C", "D", "E", "F", "G"], list::forAll(MyList, {(Head):- if ...
by George
3 Mar 2014 10:19
Forum: Visual Prolog
Topic: stackoverFlow Error for some Shortest Path
Replies: 7
Views: 4232

You have to do something like below after you found the shortest path, connected(Window,_Source,_Target):- if shortestPath <> [] then %finalized path should be in the list shortestPath = [Source|Targets], %get the source TempSource = varM{string}::new(Source), list::forAll(Targets, {(HTarget):- %loo...
by George
3 Mar 2014 9:49
Forum: Visual Prolog
Topic: stackoverFlow Error for some Shortest Path
Replies: 7
Views: 4232

connected(Window,X,Z):- edge(X,Z,L),L>"0", nVal:=nVal+toterm(L), stdio::write(X, " to ",Z," by weight ", L," all ",nVal,"\n"),!. connected(Window,X,Z):- edge(X,Y,L),L>"0", connected(Window,Y,Z), %Leads to infinite loop nVal:=nVal+toterm(L)...
by George
28 Feb 2014 19:46
Forum: Visual Prolog
Topic: depth first search problem
Replies: 1
Views: 2040

#1 : it is not the latest prolog version
#2 : try to avoid if -else statement for old prolog version..
#3 : instead, use backtracking - this will avoid this kind of issue..
#4 : for any personal support, send a email to : Georgeananth.prolog@gmail
by George
27 Feb 2014 15:18
Forum: Visual Prolog
Topic: error c504
Replies: 2
Views: 2237

predicates findPath : (string Start, string End) -> string* Path determ. clauses findPath(Start, End) = list::reverse(findPath2(Start, End, [Start])). %Input to this predicate is string list - so you must return string list from the findPath2/.. predicate predicates findPath2 : (string Start, strin...
by George
27 Jan 2014 9:34
Forum: Visual Prolog
Topic: Read from an external file.
Replies: 17
Views: 8192

If your requirement is just about the reading a data from external file, you could find the below code, predicates onPushButtonClick : button::clickResponder. clauses onPushButtonClick(_Source) = button::defaultAction:- MyStream = inputStream_file::openFile8(@"D:\TestMe.txt"), %External fi...
by George
17 Jan 2014 10:26
Forum: Visual Prolog
Topic: How can we define a user defined exception for the error code ?
Replies: 2
Views: 2002

I think, we can do it in the following way, class predicates testException : (integer ) . clauses testException(Var):- try if Var <> 1 then succeed() else exception::raise_user("App Error") end if catch TraceID do vpiCommonDialogs::note(exceptionDump::dumpToString(TraceID)) end try, !.
by George
17 Jan 2014 10:10
Forum: Visual Prolog
Topic: How can we define a user defined exception for the error code ?
Replies: 2
Views: 2002

How can we define a user defined exception for the error code ?

I see that, errorExit(1000) is used to raise the exception - What does the Error code(1000) means ? How can I get the error message ? Is there any way user can define our own exception to the error code ? class predicates testException : (integer ) . clauses testException(Var):- try if Var <> 1 then...
by George
16 Jan 2014 14:38
Forum: Visual Prolog
Topic: define clause with value from edit control
Replies: 6
Views: 3508

Look for fact variable & properties too
:idea:
by George
16 Jan 2014 11:55
Forum: Visual Prolog
Topic: define clause with value from edit control
Replies: 6
Views: 3508

Please go through the following URL to get a detail knowledge on assert and retract, Assert: http://wiki.visual-prolog.com/index.php?title=Language_Reference/Built-in_entities/Predicates#assert Retract: http://wiki.visual-prolog.com/index.php?title=Language_Reference/Built-in_entities/Predicates#ret...