0

i recently installed B-prolog and tried CG graphics examples from here http://www.probp.com/

According to their manual, i've installed B prolog in C:/ drive and its compiling propoerly but not executing them.

This is cuba.pl

go:-
cuba(Os),
cgWindow(Win,"cuba"),
handleWindowClosing(Win),
cgSame(Os,window,Win),
cgPack(Os),
cgMove(Os,30,30),
cgShow(Os).


handleWindowClosing(Win),{windowClosing(Win)} => cgClose(Win).

cuba(Os):-    
  cgRectangle(Frame),Frame^fill #= 0,
  cgRectangle(Bg),Frame^size #= Bg^size,
  Bg^color #=blue,
  Bg^width #= 2*Bg^height,

  WhiteBox=[W1,W2],
  cgRectangle(WhiteBox),
  cgSame(WhiteBox,color,white),
  cgSame([Bg|WhiteBox],width),
  cgSame(WhiteBox,width),
  cgSame(WhiteBox,width),
  5*W1^height #= Bg^height,  
  W1^x #= Bg^x,
  W1^y #= Bg^y + Bg^height/5,
  W2^x #= Bg^x,
  W2^y #= Bg^y + 3*Bg^height/5,


  cgTriangle(Tri),
  Tri^color #=red,
  Tri^point1 #= Bg^leftTopPoint,
  Tri^point2 #= Bg^leftBottomPoint,
  Tri^x3 #= Bg^x + 3*Bg^width/7,
  Tri^y3 #= Bg^y + Bg^height/2,


  cgStar(Star),
  Star^n #=5,
  Star^color #= white,
  Star^centerX #= Bg^x + Bg^width/7,
  Star^centerY #= Bg^centerY,
  Star^diameter #= Bg^height/4,

  Os=[Bg,W1,W2,Tri,Star,Frame].

Whenever i try to run, i get this error?

Type 'help' for usage.
| ?- cl('cuba.pl').
Compiling::cuba.pl
compiled in 3 milliseconds
loading::cuba.out

yes
| ?- go
***  Undefined procedure: cgRectangle/1

What is the problem here?

false
  • 10,264
  • 13
  • 101
  • 209
Abhilash Muthuraj
  • 2,008
  • 9
  • 34
  • 48
  • I'll remove the swi-prolog and visual-prolog tags. They are misplaced in this Question. There haven't been a lot of BProlog specific questions, but if more get posted we should certainly start a tag for that. – hardmath Oct 06 '11 at 00:15

1 Answers1

2

You have to run the Java version of the prolog engine.

Try using bpp.bat to launch the interpreter instead of bp.bat.

You will need a 32bit Java VM

gusbro
  • 22,357
  • 35
  • 46
  • How can i know what java version of prolog engine? So do i need to install JDK java or jre? – Abhilash Muthuraj Oct 05 '11 at 13:48
  • You need to install a 32 bit JRE. You might also use a 32 bit JDK if you want. – gusbro Oct 05 '11 at 14:10
  • I unistalled java 64 bit and installed 32 bit java, even now i'm getting the same error. Have you tried running B prolog CGLIB in windows 7? | ?- consult('usa.pl'). consulting::usa.pl yes | ?- cl('usa.pl'). Compiling::usa.pl compiled in 4 milliseconds loading::usa.out yes | ?- go *** Undefined procedure: cgRectangle/1 | ?- – Abhilash Muthuraj Oct 07 '11 at 22:45
  • I am also running in Windows 7 and I successfully ran the Cuba.pl example. You have to ensure that you will be running a 32bit version of the Java VM. To check that, you can execute java -version. If it states 64 bit then you have to edit the file bpp.bat included with BProlog, and set the appropriate Java VM setting to point to "c:\Program Files (x86)\Java\jdkYYY\bin", where YYY is your current java VM version. Note: you have to run BProlog by executing BPP.bat – gusbro Oct 08 '11 at 00:08
  • Thanks gusbro, can you please output/paste the BPP.bat file here. I just needed to have a look. – Abhilash Muthuraj Oct 10 '11 at 15:25
  • Hey gusbro, thanks for the help. I tried what you said and now BProlog and graphics are working. Thanks again! – Abhilash Muthuraj Oct 10 '11 at 15:42