home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 3 / PDCD_3.iso / pocketbk / utilsm / notepad / np50 / PLUGINS.DOC < prev    next >
Text File  |  1995-03-04  |  7KB  |  217 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. f1$-f5$ Reserved
  55.  
  56.  
  57.  
  58. 1. Notes use logical drive d
  59.                           (Example:)     d.n$=Note :d.prio$="9" :d.stat$="1"
  60.                                          append
  61.                                          gclose mywin%
  62.                                          c:
  63.                                          sres%=1
  64.                                          return
  65.  
  66. 2. The open notepad has one field referred to as d.n$, which holds the note.
  67.  
  68.                         Plug:
  69.                         local d%,mydata$(255),list$(100)
  70.                         list$="Hot,Warm,Luke Warm,Cool,Cold,Freezing"
  71.                         dinit"Input new data"
  72.                         dedit mydata$,"Edit:",20
  73.                         dchoice d%,"Priority:",list$
  74.                         if dialog
  75.                          last :next
  76.                          d.n$=mydata$
  77.                          d.prio$=fix$(d%,0,2)
  78.                          d.stat$="1"    REM active note
  79.                          append
  80.                         c:        Rem routine to get new count
  81.                         sres%=1   Rem request a redraw
  82.                         endif
  83.                         return
  84.                         endp
  85.  
  86. In fact ,this example, simple as it is , is a legitimate Plug-In.
  87. Try it out.
  88.  
  89.  
  90. Here are some of the built in routines that you can use:
  91.  
  92. GLOBALS:
  93.  
  94. Current Window ID               win%
  95. Variable for holding note       n$(255)
  96. Open file (full path)           w$
  97. Font Size in Editor             fs%  (1=8, 2=11, 3=13, 4=16)
  98.  
  99. code$                           "\app\npad\"
  100. data$                           "\note\"
  101. pad$                            "\Note\Pad\"
  102. expand$                         "\Note\Expand\"
  103. pid%                            Our Process ID
  104. ww%                             Window Width of main window
  105. aband%                          1=prompt Abandon  2=No prompt (In text editor)
  106. c                               Holds count.
  107.  
  108.  
  109.  
  110. BUILT-IN ROUTINES YOU CAN CALL:
  111.  
  112. Compress data file:             Compress:(mode%)    REm if mode%=0 (busy message shows)
  113. Force Sort                      NS:
  114. Sort                            AS: - Only sorts if Auto Sort is ON.
  115. Calculator                      UC:
  116. Calendar                        UK:
  117. Set priority                    Priority:      (brings up the priority list)
  118.                                                (and returns the number chosen)
  119. Jump to any app                 Jump:("App Name")
  120.  
  121. Set alarm on current note:      NA:
  122. Reset alarm                     NY:
  123. Remove an alarm                 NR:
  124. Get Date in user format         date$:(fix$(days(day,month,year),0,16)
  125. String to Number safely         Val:(str$)      returns zero on error
  126.  
  127.  
  128. Note: There is no longer a 12byte header in Notepad. All information is in
  129. separate fields. This should make life much simpler for writing plugins.
  130.  
  131.  
  132. Installing Plug-Ins:
  133.  
  134. To install a Plug-In all you need to do is copy the Plug-In, which must have
  135. a .plg extension, to the \App\Npad\Plug directory and Notepad will see it there
  136. and load it when you call up the Plug-Ins menu.
  137.  
  138.  
  139.  
  140. CALLING THE TEXT EDITOR:
  141.  
  142. Here's the New Note routine as an example:
  143.  
  144. Proc NE:
  145. local c%,r%,pd&,dc%,p%,d%
  146. onerr nerr
  147. pf%=1
  148. Opset:(0)               REM open the settings file to find out if we need
  149. r%=b.arem%              REM to prompt for an alarm. b.arem% tells me this.
  150. Opset:(1)               REM close settings file.
  151. if c                    REM if count
  152.         pp%=val:(d.prio$)+1    REM Get the current priority number
  153. else pp%=1
  154. endif
  155. top::
  156. if c=0
  157.         n$=Editor$:(n$,"Add a New Note for "+nam$) REM start editor
  158.         if count=0 :nonotes: :endif        REM Add dummy record if count=0
  159. else
  160.         n$=Editor$:(n$,"Add a New Note")
  161. endif
  162. if n$=""                                   REM no note added
  163.         return
  164. endif
  165. dinit
  166. dtext"","Project Options",$302
  167. pd&=days(day,month,year)
  168. dc%=swd%                                   REm swd% setting = Save with date setting
  169. dchoice dc%,"Save With Date:","Yes,No"
  170. ddate pd&,"Due Date",days(day,month,year-3),days(31,12,2049)
  171. d%=dialog
  172.         c%=priority:                       REM set the priority
  173.         if c%=0 :goto top:: :endif
  174.         last :next
  175.         n$=eval$:(n$)                      REM evaluate any calculations
  176.         d.n$=n$                            REM Set note
  177.         d.prio$=fix$(c%,0,3)               REM set priority
  178.         d.stat$="1"                        REM set status active
  179.         if dc%=1 and d%<>0
  180.                 d.pdt$=fix$(pd&,0,16)      REM Set Due Date
  181.                 if d.un$=""                REm Add unique ID
  182.                         d.un$=fix$(uniq:,0,16)
  183.                 endif
  184.         endif
  185.         append
  186.         if dc%=1
  187.                 wrproj:(1)                 REM if Due Date, send to Project file
  188.         endif
  189.         if r%<>2
  190.                 pos%=count
  191.                 na:                        REM Set an alarm
  192.         endif
  193.         as:
  194.         sres%=1                            REM Set screen redraw
  195. first
  196. c:                                         REM Set new count
  197. pf%=0
  198. return
  199. nerr::
  200. giprint err$(err)
  201. ENDP
  202.  
  203.  
  204.  
  205.  
  206.  
  207.  
  208.  
  209.  
  210.  
  211. Don't hesitate to contact me if you have any problem.
  212.  
  213.                                 Mark Esposito
  214.                              Pelican Software Inc.
  215.                                  72662,3050
  216.                                (713) 242-8928
  217.