home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 3 / PDCD_3.iso / pocketbk / utilsm / np52 / PLUGINS.DOC < prev    next >
Text File  |  1995-06-15  |  7KB  |  213 lines

  1.  
  2.                    Notepad 5.0 Plug-Ins Information
  3.  
  4.  
  5. Notepad 5.0 has a feature called Plug-Ins, that allows anyone to write
  6. additional Plug In modules in Opl, to work with Notepad.
  7.  
  8.  
  9. Writing compatible Plug-Ins
  10.  
  11. A Plug-In can enable Notepad users to do things with notes that aren't
  12. designed into the program. All Plug-Ins will show up on the Notepad menu,
  13. and this is what makes them unique. Once installed to the correct directory,
  14. they show up on Notepad's directory just as if they were a part of the
  15. program.
  16.  
  17. It is best when writing a Plug-In to start by creating your own window by
  18. using something like this:
  19.  
  20. mywin%=gcreate(0,0,width,height,1)
  21.  
  22.         ... or if you don't want screen blink,
  23.  
  24. mywin%=gcreate(0,0,240,80,0)
  25. REm Draw screen here
  26. gvisible on
  27.  
  28. For simple plugins that don't need there own user interface, you can use
  29. standard Psion dialogs.
  30.  
  31.         dinit"My module"
  32.         dtext ""," "
  33.         dialog
  34.  
  35. This way when your Plug-In closes, it closes this window and makes a clean
  36. exit. Next item to note is the format of a notepad file.
  37.  
  38.  
  39. NOTEPAD FILE FORMAT
  40.  
  41. filenam$,d,n$,dt$,tm$,un$,pdt$,pn$,prio$,exp$,app$,ahead$,stat$,f1$,f2$,f3$,f4$,f5$
  42.  
  43. n$      Main text for Note
  44. dt$     Date for Alarm in days() format (string)
  45. tm$     Time for Alarm in dtime format
  46. un$     Unique number (long int)
  47. pdt$    Due Date (long int) days format
  48. pn$     Reserved
  49. Prio$   Priority Number (1-20)
  50. Exp$    Expansion Link (Name only, no extension) Assumed to be a .exp file
  51. App$    Application Link. (B:\Wrd\Word.wrd)
  52. ahead$  Header byte describing Application link type (W=Word,D=Date,S=Sheet)
  53. stat$   Status of Note - 1=Active  2=done  3=reserved
  54. alm$    Alarm information (call if you really need this )
  55. emph$   Holds the Emphasis for the note (Normal=0 Bold=1 Italic=2 Underline=4)
  56.         Example: bold%=(val:(d.emph$) and 1)
  57. f3$-f5$ Reserved
  58.  
  59.  
  60.  
  61. 1. Notes use logical drive d
  62.                           (Example:)     d.n$=Note :d.prio$="9" :d.stat$="1"
  63.                                          append
  64.                                          gclose mywin%
  65.                                          c:
  66.                                          sres%=1
  67.                                          return
  68.  
  69. 2. The open notepad has one field referred to as d.n$, which holds the note.
  70.  
  71.                         Plug:
  72.                         local d%,mydata$(255),list$(100)
  73.                         list$="Hot,Warm,Luke Warm,Cool,Cold,Freezing"
  74.                         dinit"Input new data"
  75.                         dedit mydata$,"Edit:",20
  76.                         dchoice d%,"Priority:",list$
  77.                         if dialog
  78.                          last :next
  79.                          d.n$=mydata$
  80.                          d.prio$=fix$(d%,0,2)
  81.                          d.stat$="1"    REM active note
  82.                          append
  83.                         c:        Rem routine to get new count
  84.                         sres%=1   Rem request a redraw
  85.                         endif
  86.                         return
  87.                         endp
  88.  
  89. In fact ,this example, simple as it is , is a legitimate Plug-In.
  90. Try it out.
  91.  
  92.  
  93.  
  94. GLOBALS:
  95.  
  96. Current Window ID               win%
  97. Variable for holding note       n$(255)
  98. Open file (full path)           w$
  99. Font Size in Editor             fs%  (1=8, 2=11, 3=13, 4=16)
  100.  
  101. code$                           "\app\npad\"
  102. data$                           "\note\"
  103. pad$                            "\Note\Pad\"
  104. expand$                         "\Note\Expand\"
  105. pid%                            Our Process ID
  106. ww%                             Window Width of main window
  107. aband%                          1=prompt Abandon  2=No prompt (In text editor)
  108. c                               Holds count.
  109.  
  110.  
  111.  
  112. BUILT-IN ROUTINES YOU CAN CALL:
  113.  
  114. Compress data file:             Compress:(mode%)    REm if mode%=0 (busy message shows)
  115. Force Sort                      NS:
  116. Sort                            AS: - Only sorts if Auto Sort is ON.
  117. Calculator                      UC:
  118. Calendar                        UK:
  119. Set priority                    Priority:      (brings up the priority list)
  120.                                                (and returns the number chosen)
  121. Jump to any app                 Jump:("App Name")
  122.  
  123. Set alarm on current note:      NA:
  124. Reset alarm                     NY:
  125. Remove an alarm                 NR:
  126. Get Date in user format         date$:(fix$(days(day,month,year),0,16)
  127. String to Number safely         Val:(str$)      returns zero on error
  128.  
  129.  
  130. Note: There is no longer a 12byte header in Notepad. All information is in
  131. separate fields. This should make life much simpler for writing plugins.
  132.  
  133.  
  134. Installing Plug-Ins:
  135.  
  136. To install a Plug-In all you need to do is copy the Plug-In, which must have
  137. a .plg extension, to the \App\Npad\Plug directory and Notepad will see it there
  138. and load it when you call up the Plug-Ins menu.
  139.  
  140.  
  141.  
  142. CALLING THE TEXT EDITOR:
  143.  
  144. Here's the New Note routine as an example:
  145.  
  146. Proc NE:
  147. local c%,r%,pd&,dc%,p%,d%
  148. onerr nerr
  149. pf%=1
  150. Opset:(0)               REM open the settings file to find out if we need
  151. r%=b.arem%              REM to prompt for an alarm. b.arem% tells me this.
  152. Opset:(1)               REM close settings file.
  153. if c                    REM if count
  154.         pp%=val:(d.prio$)+1    REM Increment the current priority number
  155. else pp%=1
  156. endif
  157. top::
  158. if c=0
  159.         n$=Editor$:(n$,"Add a New Note for "+nam$) REM start editor
  160.         if count=0 :nonotes: :endif        REM Add dummy record if count=0
  161. else
  162.         n$=Editor$:(n$,"Add a New Note")
  163. endif
  164. if n$=""                                   REM no note added
  165.         return
  166. endif
  167. dinit
  168. dtext"","Project Options",$302
  169. pd&=days(day,month,year)
  170. dc%=swd%                                   REm swd% setting = Save with date setting
  171. dchoice dc%,"Save With Date:","Yes,No"
  172. ddate pd&,"Due Date",days(day,month,year-3),days(31,12,2049)
  173. d%=dialog
  174.         c%=priority:                       REM set the priority
  175.         if c%=0 :goto top:: :endif
  176.         last :next
  177.         n$=eval$:(n$)                      REM evaluate any calculations
  178.         d.n$=n$                            REM Set note
  179.         d.prio$=fix$(c%,0,3)               REM set priority
  180.         d.stat$="1"                        REM set status active
  181.         if dc%=1 and d%<>0
  182.                 d.pdt$=fix$(pd&,0,16)      REM Set Due Date
  183.                 if d.un$=""                REm Add unique ID
  184.                         d.un$=fix$(uniq:,0,16)
  185.                 endif
  186.         endif
  187.         append
  188.         if dc%=1
  189.                 wrproj:(1)                 REM if Due Date, send to Project file
  190.         endif
  191.         if r%<>2
  192.                 pos%=count
  193.                 na:                        REM Set an alarm
  194.         endif
  195.         as:
  196.         sres%=1                            REM Set screen redraw
  197. first
  198. c:                                         REM Set new count
  199. pf%=0
  200. return
  201. nerr::
  202. giprint err$(err)
  203. ENDP
  204.  
  205.  
  206.  
  207. Don't hesitate to contact me if you have any problem.
  208.  
  209.                                 Mark Esposito
  210.                              Pelican Software Inc.
  211.                                  72662,3050
  212.                                (713) 242-8928
  213.