home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 9 / 09.iso / l / l216 / 2.ddi / XSLIDES.PRO < prev    next >
Encoding:
Text File  |  1987-03-23  |  2.7 KB  |  95 lines

  1. /****************************************************************
  2.  
  3.      Turbo Prolog Toolbox
  4.      (C) Copyright 1987 Borland International.
  5.  
  6.         Demo of    savepic and loadpic
  7. ****************************************************************/
  8.  
  9. project "xslides"
  10.  
  11. include "tdoms.pro"
  12.  
  13. DATABASE
  14.   index(CHAR,INTEGER,INTEGER)
  15.   slide(INTEGER,STRING)
  16.  
  17. GLOBAL PREDICATES
  18.   loadPic(STRING,ROW,COL,ROW,COL,INTEGER,INTEGER) 
  19.     - (i,i,i,i,i,i,i) language c
  20.  
  21.  SavePic(String) - (i) language c
  22.  
  23. include "tpreds.pro"
  24. include    "menu.pro"
  25.         
  26. PREDICATES
  27.   mydisplay(ROW,COL,INTEGER)
  28.   findpicture(char,ROW,COL,ROW,COL,INTEGER,INTEGER)
  29.   getnewpositions(ROW,COL,ROW,COL)
  30.   decide(INTEGER)
  31.  
  32. GOAL
  33.     makewindow(11,7,0,"",0,0,25,80),
  34.     repeat,text,
  35.     menu(10,10,64,23,["Make some slides","See the slide show","Exit"],
  36.                    "Choose an option",1,Choice),
  37.     decide(Choice),text,
  38.     fail.
  39.         
  40. CLAUSES
  41.   decide(1):-
  42.     graphics(1,1,2),
  43.     attribute(2),
  44.     mydisplay(0,0,0).
  45.  
  46.   decide(2):-
  47.     slide(_,B),graphics(1,1,2),
  48.     loadpic(B,0,0, 0,0,200,320),
  49.     readchar(_),
  50.     clearwindow,
  51.     fail.                        
  52.  
  53.   decide(3):-exit.
  54.  
  55.   mydisplay(Row,Col,Slideno):-
  56.     readchar(X),X<>'\027',
  57.     findpicture(X,Row,Col,NewX,NewY,Slideno,NewSlideno),
  58.     mydisplay(NewX,NewY,NewSlideno).
  59.  
  60.   findpicture('\27',_,_,_,_,_,_):-!,fail.
  61.  
  62.   findpicture('#',_,_,0,0,Slideno,NewSlideno):-!,
  63.     str_int(SN,Slideno),
  64.     concat("Slide",SN,FSN),
  65.     assert(slide(Slideno,FSN)),
  66.     savepic(FSN),
  67.     graphics(1,1,2),
  68.     NewSlideno=Slideno+1. 
  69.  
  70.   findpicture(' ',CurrScrRow,CurrScrCol,NewScrRow,NewScrCol,S,S):-!,
  71.     getnewpositions(CurrScrRow,CurrScrCol,NewScrRow,NewScrCol).
  72.  
  73.   findpicture('\13',CurrScrRow,_,NewScrRow,0,S,S):-!,
  74.     NewScrRow=CurrScrRow+25.
  75.  
  76.   findpicture(X,CurrScrRow,CurrScrCol,NewScrRow,NewScrCol,S,S):-
  77.     index(X,Row1,Col1), Row=Row1, Col=Col1,
  78.     loadPic("test.pic",Row,Col,CurrScrRow,CurrScrCol,25,25),
  79.     getnewpositions(CurrScrRow,CurrScrCol,NewScrRow,NewScrCol).
  80.                                      
  81.   getnewpositions(X,Y,NewX,0):-Y+34>=300,NewX=X+25.                                                  
  82.   getnewpositions(X,_,0,0):-X+25>=200. 
  83.   getnewpositions(X,Y,X,NewY):-NewY=Y+34.
  84.  
  85.   index('a',28,64).    index('b',25,94).    index('c',28,128).
  86.   index('d',25,158).    index('e',28,188).    index('f',24,224).
  87.   index('g',26,252).    index('h',54,64).    index('i',52,94).
  88.   index('j',53,127).    index('k',56,158).    index('l',56,188).
  89.   index('m',56,224).    index('n',56,252).    index('o',84,64).
  90.   index('p',84,96).    index('q',84,126).    index('r',84,158).
  91.   index('s',84,192).    index('t',84,224).    index('u',84,256).
  92.   index('v',112,62).    index('w',112,94).    index('x',112,128).
  93.   index('y',112,160).    index('z',112,192).
  94.  
  95.