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

  1.  
  2.  /*******************************************************************
  3.  
  4.      Turbo Prolog Toolbox
  5.      (C) Copyright 1987 Borland International.
  6.  
  7.              HELPDEF                        
  8. *******************************************************************/
  9.  
  10. code=4000
  11.  
  12.  /*******************************************************************/
  13.  /*            Domains                        */
  14.  /*******************************************************************/
  15.  
  16. include "tdoms.pro"
  17.  
  18. DOMAINS
  19.   FNAME=SYMBOL
  20.   TYPE = int(); str(); real()
  21.   VALUE    = int(INTEGER); str(STRING); real(REAL)
  22.   HELPUNIT    = h(STRING)
  23.   FILEPOS    = REAL
  24.   FILE        = helpfile ; def
  25.   HELPDOM1    = helptext(STRING,ATTR,ATTR,STRING,ROW,COL,ROW,COL,FILEPOS)
  26.   HELPDOM2    = h(STRING)
  27.  
  28.  
  29.  /*******************************************************************/
  30.  /*            Database                    */
  31.  /*******************************************************************/
  32.  
  33. DATABASE
  34.   /* Database declarations used in scrhnd */
  35.   insmode            /* Global insertmode */
  36.   actfield(FNAME)        /* Actual field */
  37.   screen(SYMBOL,DBASEDOM)    /* Saving different screens */
  38.   value(FNAME,STRING)        /* value of a field */
  39.   field(FNAME,TYPE,ROW,COL,LEN) /* Screen definition */
  40.   txtfield(ROW,COL,LEN,STRING)
  41.   windowsize(ROW,COL).
  42.   notopline
  43.  
  44.   /* DATABASE PREDICATES USED BY VSCRHND */
  45.   windowstart(ROW,COL)
  46.   mycursord(ROW,COL)
  47.  
  48.   /* Database declarations used in lineinp */
  49.   lineinpstate(STRING,COL)
  50.   lineinpflag
  51.  
  52.   helptext(STRING,ATTR,ATTR,STRING,ROW,COL,ROW,COL)
  53.   helpstrings(STRING,STRING)
  54.   helpcontext(STRING)
  55.  
  56.  /*******************************************************************/
  57.  /*            Include tools                    */
  58.  /*******************************************************************/
  59.  
  60. include "tpreds.pro"
  61. include "longmenu.pro"
  62. include "status.pro"
  63. include "lineinp.pro"
  64. include "filename.pro"
  65. include "scrhnd.pro"
  66.  
  67.  /*******************************************************************/
  68.  /*            Intermediate predicates                */
  69.  /*******************************************************************/
  70.  
  71. PREDICATES
  72.   index(INTEGER,STRINGLIST,STRING)
  73.  
  74. CLAUSES
  75.   index(1,[H|_],H):-!.
  76.   index(N,[_|T],X):-N>1,N1=N-1,index(N1,T,X).
  77.  
  78. PREDICATES
  79.   change(DBASEDOM)
  80.  
  81. CLAUSES
  82.   change(value(X,_)):-retract(value(X,_)),fail.
  83.   change(helpcontext(_)):-retract(helpcontext(_)),fail.
  84.   change(X):-assert(X).
  85.  
  86. PREDICATES
  87.   get_helpcontext(STRING)
  88.   put_helpcontext
  89.   check_retract(STRING)
  90.   rdname(STRING)
  91.   wr(HELPDOM1)  wr(HELPDOM2)
  92.   makefile
  93.   readfile
  94.   nondeterm repfile(FILE)
  95.  
  96. CLAUSES
  97.   get_helpcontext(_):-
  98.     retract(value(name,_)),fail.
  99.   get_helpcontext(NAME):-
  100.     not(helptext(NAME,_,_,_,_,_,_,_)),!,
  101.     assert(value(name,NAME)),
  102.     not(helpstrings(NAME,"")),
  103.     assert(helpstrings(NAME,"")),
  104.     shiftwindow(OLD),
  105.     shiftwindow(5),
  106.     window_str(""),
  107.     shiftwindow(OLD).
  108.   get_helpcontext(_):-retract(value(_,_)),fail.
  109.   get_helpcontext(NAME):-
  110.     helptext(NAME,WATTR,FATTR,LABEL,SROW,SCOL,ROWS,COLS),!,
  111.     assert(value(name,NAME)),
  112.     assert(value(label,LABEL)),
  113.     str_int(S1,WATTR),assert(value(wattr,S1)),
  114.     str_int(S2,FATTR),assert(value(fattr,S2)),
  115.     str_int(S3,SROW),assert(value(srow,S3)),
  116.     str_int(S4,SCOL),assert(value(scol,S4)),
  117.     str_int(S5,ROWS),assert(value(rows,S5)),
  118.     str_int(S6,COLS),assert(value(cols,S6)),
  119.     helpstrings(NAME,STRING),!,
  120.     shiftwindow(OLD),
  121.     shiftwindow(5),
  122.     window_str(STRING),
  123.     shiftwindow(OLD).
  124.  
  125.   put_helpcontext:-
  126.     value(name,NAME),
  127.     check_retract(NAME),
  128.     field_value(label,LABEL),
  129.     value(wattr,S1),str_int(S1,WATTR),
  130.     value(fattr,S2),str_int(S2,FATTR),
  131.     value(srow,S3),str_int(S3,SROW),
  132.     value(scol,S4),str_int(S4,SCOL),
  133.     value(rows,S5),str_int(S5,ROWS),
  134.     value(cols,S6),str_int(S6,COLS),!,
  135.     assert(helptext(NAME,WATTR,FATTR,LABEL,SROW,SCOL,ROWS,COLS)).
  136.   put_helpcontext.
  137.  
  138.   check_retract(NAME):-
  139.     retract(helptext(NAME,_,_,_,_,_,_,_)),fail.
  140.   check_retract(_).
  141.  
  142.   rdname(NAME):-
  143.     cursor(ROW,COL),
  144.     lineinput(ROW,COL,40,7,7,"Name of help context: ","",NAME),
  145.     NAME><"",!.
  146.   rdname(NAME):-
  147.     findall(X,helptext(X,_,_,_,_,_,_,_),LIST),
  148.     cursor(ROW,COL),
  149.     longmenu(ROW,COL,15,7,7,LIST,"Choose helpcontext",0,CHOICE),
  150.     index(CHOICE,LIST,NAME).
  151.  
  152.  /*******************************************************************/
  153.  /*            Field action                    */
  154.  /*******************************************************************/
  155.  
  156.   field_action(name):-
  157.     put_helpcontext,
  158.     rdname(NAME),
  159.     get_helpcontext(NAME).
  160.  
  161.   field_action(remove):-
  162.     put_helpcontext,
  163.     rdname(NAME),
  164.     retract(helptext(NAME,_,_,_,_,_,_,_)),!,
  165.     value(name,NAME),!,
  166.     helptext(NAME1,_,_,_,_,_,_,_),!,
  167.     get_helpcontext(NAME1).
  168.  
  169.   field_action(edit):-
  170.     value(name,NAME),
  171.     helpstrings(NAME,STRING),!,
  172.     shiftwindow(OLD),
  173.     shiftwindow(5),
  174.     edit(STRING,STRING1),
  175.     window_str(STRING1),
  176.     shiftwindow(OLD),
  177.     retract(helpstrings(NAME,_)),!,
  178.     assert(helpstrings(NAME,STRING1)).
  179.  
  180.   field_action(edit):-
  181.     value(name,NAME),!,
  182.     shiftwindow(OLD),
  183.     shiftwindow(5),
  184.     edit("",STRING1),
  185.     window_str(STRING1),
  186.     shiftwindow(OLD),
  187.     assert(helpstrings(NAME,STRING1)).
  188.  
  189.   field_action(load):-
  190.     cursor(ROW,COL),
  191.     readfilename(ROW,COL,7,7,def,"",DFILE),
  192.     upper_lower(DFILE,DEFFILE),
  193.     concat(FILENAME,".def",DEFFILE),
  194.     concat(FILENAME,".hlp",HELPFILE),
  195.     openread(helpfile,HELPFILE),
  196.     openread(def,DEFFILE),
  197.     readfile,
  198.     closefile(def),
  199.     closefile(helpfile),
  200.     helptext(NAME1,_,_,_,_,_,_,_),!,
  201.     get_helpcontext(NAME1).
  202.  
  203.  
  204.   field_action(save):-
  205.     put_helpcontext,
  206.     cursor(ROW,COL),
  207.     readfilename(ROW,COL,7,7,def,"",DFILE),
  208.     upper_lower(DFILE,DEFFILE),
  209.     concat(FILENAME,".def",DEFFILE),
  210.     concat(FILENAME,".hlp",HELPFILE),
  211.     openwrite(helpfile,HELPFILE),
  212.     openwrite(def,DEFFILE),
  213.     makefile,
  214.     closefile(def),
  215.     closefile(helpfile).
  216.  
  217.   readfile:-retract(helptext(_,_,_,_,_,_,_,_)),fail.
  218.   readfile:-retract(helpstrings(_,_)),fail.
  219.   readfile:-
  220.     repfile(def),
  221.     readdevice(def),
  222.     readterm(HELPDOM1,helptext(NAME,WATTR,FATTR,LABEL,SROW,SCOL,ROWS,COLS,FILEPOS)),
  223.     readdevice(helpfile),
  224.     filepos(helpfile,FILEPOS,0),
  225.     readterm(HELPDOM2,h(STRING)),
  226.     assert(helptext(NAME,WATTR,FATTR,LABEL,SROW,SCOL,ROWS,COLS)),
  227.     assert(helpstrings(NAME,STRING)),
  228.     fail.
  229.   readfile.
  230.  
  231.   makefile:-
  232.     helptext(NAME,WATTR,FATTR,LABEL,SROW,SCOL,ROWS,COLS),
  233.     helpstrings(NAME,STRING),
  234.     filepos(helpfile,POS,0),
  235.     writedevice(helpfile),
  236.     wr(h(STRING)),
  237.     writedevice(def),
  238.     wr(helptext(NAME,WATTR,FATTR,LABEL,SROW,SCOL,ROWS,COLS,POS)),
  239.     fail.
  240.   makefile.
  241.  
  242.  
  243.   wr(X):-write(X),nl.
  244.  
  245.   repfile(_).
  246.   repfile(FILE):-not(eof(FILE)),repfile(FILE).
  247.  
  248.  /*******************************************************************/
  249.  /*             Field_value                    */
  250.  /*******************************************************************/
  251.  
  252.   field_value(load,_):-!,fail.
  253.   field_value(save,_):-!,fail.
  254.   field_value(edit,_):-!,fail.
  255.   field_value(remove,_):-!,fail.
  256.   field_value(FNAME,VAL):-value(FNAME,VAL),!.
  257.   field_value(_,"").
  258.  
  259.  
  260.  /*******************************************************************/
  261.  /*             noinput                    */
  262.  /*******************************************************************/
  263.  
  264.   noinput(edit).
  265.   noinput(remove).
  266.   noinput(name).
  267.   noinput(load).
  268.   noinput(save).
  269.  
  270.  /*******************************************************************/
  271.  /*             Screen handler call                     */
  272.  /*******************************************************************/
  273.  
  274. GOAL    makewindow(5,7,7,"Help text",15,0,9,80),
  275.     consult("help.scr"),    /* Consult the screen definition */
  276.     makewindow(11,7,7,"Definition of helpfiles",0,0,15,80),
  277.     scrhnd(off,_).        /* Call screen handler */
  278.