Search found 340 matches

by Harrison Pratt
8 Jul 2021 12:48
Forum: Visual Prolog
Topic: Unifying domains?
Replies: 4
Views: 574

Re: Unifying domains?

If you want to avoid using or then this construct works.

Code: Select all

class predicates     findModelName2 : (mydomain M, string N [out]) determ. clauses     findModelName2(model, N) :-         modelFact(_, N),         !.     findModelName2(M, N) :-         modelFact(M, N),         !.
by Harrison Pratt
23 Jun 2021 11:59
Forum: Visual Prolog
Topic: Cannot use Windows Explorer to ZIP a VIP project using "Object Expressions"
Replies: 4
Views: 609

Re: Cannot use Windows Explorer to ZIP a VIP project using "Object Expressions"

It seems that ZIP files are more restrictive than NTFS with respect to permissible filename characters:

https://stackoverflow.com/questions/205 ... a-zip-file
by Harrison Pratt
17 Jun 2021 21:29
Forum: Visual Prolog
Topic: Importing a list
Replies: 2
Views: 491

Re: Importing a list

Here is a very simple way with no error checking or special processing. The code below assumes a file named WordsAcross.txt with the this sample text in it, Note the embedded carriage return between five and six: one,two,three,four,five, six,seven,eight,nine class predicates fileToList : (string Fil...
by Harrison Pratt
28 May 2021 15:11
Forum: Visual Prolog
Topic: Call dialog from predicate?
Replies: 2
Views: 707

Re: Call dialog from predicate?

The 'continueDialog' project referenced in the Dialogs and Forms: Modeless dialogs example
( http://discuss.visual-prolog.com/viewtopic.php?t=8218 ) uses an older VP syntax and could pose some challenges to people new to VP. I have attached a tweaked version that compiles smoothly with Vip9x.
by Harrison Pratt
3 May 2021 11:30
Forum: Visual Prolog
Topic: Predicate declaration for using recursion on lists of objects with custom type
Replies: 3
Views: 814

Re: Predicate declaration for using recursion on lists of objects with custom type

Look at your 3rd clause. H2 must be a string in the clause head, but in the last line it is a string_list. You need to create the output list you tried to represent as [H2|T2] within the clause.

Code: Select all

inw_str([H1|T1], [H2|T2]):-         inw_str(T1,T2),         inw_str(H1,H2).
by Harrison Pratt
5 Apr 2021 22:07
Forum: Visual Prolog
Topic: subset between sets
Replies: 2
Views: 854

Re: subset between sets

Classical way, easy to understand: class predicates isSubSet : (T* CheckTerms, T* Terms) determ. clauses isSubset([H], Terms) :- list::isMember(H, Terms), !. isSubset([H | TT], Terms) :- list::isMember(H, Terms), isSubSet(TT, Terms). Another way using VIP list class predicates. Put your cursor on &q...
by Harrison Pratt
5 Apr 2021 10:29
Forum: Visual Prolog
Topic: How to check existence of an object
Replies: 5
Views: 1116

Re: How to check existence of an object

nothing(...) does nothing. It's a way of making the IDE capture an unused variable so you can see it when running the debugger. Unused variables do not consistently display in the Variables window when debugging without making them appear as being used to the compiler. It has no place in production...
by Harrison Pratt
4 Apr 2021 15:28
Forum: Visual Prolog
Topic: How to check existence of an object
Replies: 5
Views: 1116

Re: How to check existence of an object

One way would be to create a class database in your base class and store the object identifier information you need in that database when you create each object, something like that below. You will need to manage removing personObj/2 facts when objects are destroyed and you also should remember that...
by Harrison Pratt
3 Apr 2021 11:36
Forum: Visual Prolog
Topic: How to approach fuzzy match
Replies: 3
Views: 978

Re: How to approach fuzzy match

domains myDomain = good; bad; ok. myDomainList = myDomain*. class facts myFactDB : (myDomain VarA, myDomain VarB, myDomain VarC, myDomain VarD). class predicates getMatchN_nd : (integer Count, myDomainList TestList) -> myDomainList MatchingValues nondeterm. clauses getMatchN_nd(N, TestList) = FactV...
by Harrison Pratt
27 Mar 2021 21:07
Forum: Visual Prolog
Topic: writef not printing to Message Window
Replies: 6
Views: 1320

Re: writef not printing to Message Window

You can use vpi::processEvents() to force immediate output to the Messages window.

Code: Select all

... % do some processing someProcessingPredicate(), stdio::write("\nSomething happens here!"), _=vpi::processEvents(), % more processing ...
This may slow down processing so use it judiciously.
by Harrison Pratt
27 Mar 2021 17:17
Forum: Visual Prolog
Topic: Predicate called from menu must be a procedure (?)?
Replies: 3
Views: 936

Re: Predicate called from menu must be a procedure (?)?

One way is the catch any failure of startExperiment() so it does not fail, although that may not be what you want to do: clauses runExperiment() :- startExperiment(), ! or succeed. or you can catch failure in runExperiment() , although that may not be what you want to do either: clauses runExperimen...
by Harrison Pratt
25 Mar 2021 12:00
Forum: Visual Prolog
Topic: From string to integer
Replies: 8
Views: 1544

Re: From string to integer

This would be a good time to learn how to use the debugger and walk through the code as it executes. Put your cursor on the line with culc(In) in your run clause and press F9 to set a breakpoint. Then press F5 (or click the single green triangle on the toolbar) to run the code in the debugger. Press...
by Harrison Pratt
24 Mar 2021 12:03
Forum: Visual Prolog
Topic: writef not printing to Message Window
Replies: 6
Views: 1320

Re: writef not printing to Message Window

Can you post some of the relevant code? Remember that you should format code in this forum using the [</>] button in the forums editor. It is a better practice to put the bulk of your code in a class other than main.pro or taskwindow.pro and invoke those class predicates from taskwindow.pro , but I ...
by Harrison Pratt
21 Mar 2021 15:30
Forum: Visual Prolog
Topic: Beginner question - declare class facts across packages
Replies: 2
Views: 858

Re: Beginner question - declare class facts across packages

Facts can be declared only in a class's implementation ( .pro file) so you cannot make the facts themselves visible outside that class. However, you can easily put predicate definitions to manipulate those facts in the class's .cl file or .i file(s) to make them accessible from other classes as in t...
by Harrison Pratt
17 Jan 2021 4:00
Forum: Visual Prolog
Topic: What does [out] mean?
Replies: 3
Views: 1210

Re: What does [out] mean?

The default specification for predicate definitions is [in], so you don't need to specify that a parameter is an input. You may be surprised to see that the IDE will change a valid definition like this: demoPred : (integer Input , string Output) (i,o). to this preferred form: demoPred : (integer Inp...