
                   Notepad 5.0 Plug-Ins Information


Notepad 5.0 has a feature called Plug-Ins, that allows anyone to write
additional Plug In modules in Opl, to work with Notepad.


Writing compatible Plug-Ins

A Plug-In can enable Notepad users to do things with notes that aren't
designed into the program. All Plug-Ins will show up on the Notepad menu,
and this is what makes them unique. Once installed to the correct directory,
they show up on Notepad's directory just as if they were a part of the
program.

It is best when writing a Plug-In to start by creating your own window by
using something like this:

mywin%=gcreate(0,0,width,height,1)

        ... or if you don't want screen blink,

mywin%=gcreate(0,0,240,80,0)
REm Draw screen here
gvisible on

For simple plugins that don't need there own user interface, you can use
standard Psion dialogs.

        dinit"My module"
        dtext ""," "
        dialog

This way when your Plug-In closes, it closes this window and makes a clean
exit. Next item to note is the format of a notepad file.


PlUGIN PROCEDURE NAMES
The procedure to call must the same as the filename of the Plugin. So, if your
plugin is called "Setname", the main procedure must be called Proc Setname:


NOTEPAD FILE FORMAT

Notepad_Name,d,n$,dt$,tm$,un$,pdt$,pn$,prio$,exp$,app$,ahead$,stat$,alm$,emph$,f3$,title$,ss$

n$      Main text for Note (1st 255 bytes, if >255, f3$ holds second part)
dt$     Date for Alarm in days() format (string)
tm$     Time for Alarm in dtime format
un$     Unique number ID (long int) - Only used for due dates,alarms.
pdt$    Due Date (long int) days format
pn$     Starting Date (long int) days format
Prio$   Priority Number (1-20)
Exp$    Expansion Link - Drive Letter:Name (M:Notepad), \Note\Expand dir assumed
App$    Application Link. (B:\Wrd\Word.wrd)
ahead$  Header byte describing Application link type (W=Word,D=Date,S=Sheet)
stat$   Status of Note - 1=Active  2=done  3=reserved
alm$    Alarm information (email us if you really need this )
emph$   Holds the Emphasis for the note (Normal=0 Bold=1 Italic=2 Underline=4)
        Example: bold%=(val:(d.emph$) and 1)
f3$     Second half of note - if >255 bytes
title$  This is the title for a note - optional
ss$     Search clue for DataLink


Notepad Project File Format

"\Note\Projdata.dbf",c,note$,uniq&,date&,sd&,head$

,c,     Use Logical drive c
note$   First 255 bytes of note
uniq&   Unique number ID of note           (val(d.un$))
date&   Due Date in days() format          (val(d.pdt$))
sd&     Starting Date in days() format     (val(d.pn$))
head$   Header with ID+Notepad name        (parse$:(w$,10)) returns this format
        (m:Notepad) m=Top Level
        (p:Banker) p=expanded



1. Notes use logical drive d
                          (Example:)     last :next     REM clear fields
                                         d.n$="Note" :d.prio$="9" :d.stat$="1"
                                         d.emph$="0"
                                         append
                                         gclose mywin%
                                         c:             rem set new count
                                         sadd%=1        rem added a record
                                         return

2. The open notepad has two fields that hold the text of the note.

                        1. d.n$ - first 255 bytes
                        2. d.f3$ - second 255 bytes

                        Plug:
                        local d%,mydata$(255),list$(100)
                        list$="Hot,Warm,Luke Warm,Cool,Cold,Freezing"
                        dinit"Input new data"
                        dedit mydata$,"Edit:",20
                        dchoice d%,"Priority:",list$
                        if dialog
                         last :next     REM clear fields
                         d.n$=mydata$
                         d.prio$=fix$(d%,0,2)
                         d.emph$="0"    REM set font emphasis
                         d.stat$="1"    REM active note
                         append
                        c:        Rem routine to get new count
                        sres%=1   Rem request a redraw
                        endif
                        return
                        endp

In fact ,this example, simple as it is , is a legitimate Plug-In.
Try it out.


Messaging:    call( $83, $404, 0, 0, 0, 0 )

Messaging is enabled in Notepad, so if your Plugin needs to respond to IPC
messages, you don't need to initialize Notepad for messaging. You will get
an error if you try.



GLOBALS:

Current Window ID               win%
Variables for holding notes     n$(255),n2$(255)
Open file (full path)           w$
Font Size in Editor             fs%  (1=8, 2=11, 3=13, 4=16)

code$                           "\app\npad\"
data$                           "\note\"
pad$                            "\Note\Pad\"
expand$                         "\Note\Expand\"
pid%                            Our Process ID
ww%                             Window Width of main window
aband%                          1=prompt Abandon  2=No prompt (In text editor)
c                               Holds count.
keepos%                         keepos%=pos will keep the cursor on the same
                                        entry after a redraw.
w$                              Holds the current filename.



BUILT-IN ROUTINES YOU CAN CALL:

Compress data file:             Compress:(mode%)    REm if mode%=0 (busy message shows)
Force Sort                      NS:
Sort                            AS: - Only sorts if Auto Sort is ON.
Calculator                      UC:
Calendar                        Cal:
Set priority                    Priority:      (brings up the priority list)
                                               (and returns the number chosen)
Jump to any app                 Jump:("App Name")
Toshell:                        Jump to Shell
Set alarm on current note:      NA:
Reset alarm                     UK:
Remove an alarm                 NR:
Get Date in user format         date$:(fix$(days(day,month,year),0,16)
String to Number safely         Val:(str$)      returns zero on error
Uniq:                           Returns a uniq number (long int)
ff$:("\path\filename")          Returns drive letter of file your looking for
startalm:                       Launches Server
getAlmpd:                       Returns the PID of the Server
getime:                         Returns time in seconds (datetosecs)
b5:(p%)                         Beeps 5,p% if sound is on
Parslis$:(list$,n%)             Returns the n%'th string in a comma separated
                                  group of strings.
writgrey:(0,mess$)              Draw heading text ("Edit Note" in Editor)
                                        mess$ = text to draw
lpc$:                           Calls Bring Client. n$=first 255 bytes
                                        n2$=second 255 bytes
lps:(ptr%,tlen%)                Calls Bring Server
                                        - ptr%=address of text buffer -
                                        string  (ptr%=addr(buf$)+1)
                                        array   (ptr%=addr(buf%()))
                                        tlen%=len(buffer)

                                        In Notepad this would be highlighted text
                                        from within the editor.



Installing Plug-Ins:

To install a Plug-In all you need to do is copy the Plug-In, which must have
a .plg extension, to the \App\Npad\Plug directory and Notepad will see it there
and load it when you call up the Plug-Ins menu.



CALLING THE TEXT EDITOR:

Here's the New Note routine as an example:


Proc NE:
local c%,r%,pd&,dc%,p%,d%,sd&
onerr nerr
tit$=""                                 /* Clear Title */
if bring%=0                             /* if we're not in bring mode */
        n$="" :n2$="" :lent%=0          /* clear note variables   */
else                                    /* lent%=Length of note for editor */
        ebkey%=1                        /* Bring mode, set cursor to end in editor */
        fillnote:(0,0)                  /* copies the contents of n$+n2$ to buffer */
endif
pf%=1
Opset:(0)                               /* open settings file to get some info */
r%=b.arem%
Opset:(1)                               /* Close settings file */
if c
        pp%=val:(d.prio$)+1 :if pp%>20 :pp%=20 :endif
else pp%=1
endif
keepos%=pos                             /* Hold record pos      */
if bring%=0                             /* if not in bring mode, set title */
        dinit
        dtext"","Title for New Note",$302
        dedit tit$,"Title",15
        dialog
else tit$=""
endif
top::
if c=0
        Editor$:(n$,"Add a New Note for "+nam$)      /* Call text editor */
        if count=0 :nonotes: :endif
else
        Editor$:(n$,"Add a New Note")
endif
if n$=""
        return
endif
last :next
if nodat%=2 :sd%=0 :dc%=0 :goto s0 :endif
if ae%=1 :c%=pp% :sd%=0 :dc%=0 :goto s1 :endif
dinit
dtext"","Project Options",$302
pd&=days(day,month,year)
sd&=days(day,month,year)
dc%=swd%
if sd%=1
        ddate sd&,"Start Date",days(day,month,year-3),days(31,12,2049)
endif
dchoice dc%,"Save With Due Date","Yes,No"
ddate pd&,"Due Date",days(day,month,year-3),days(31,12,2049)
d%=dialog
s0::
        if ae%=1 :c%=pp% :sd%=0 :dc%=0 :goto s1 :endif
        c%=priority:
        if c%=0 :goto top:: :endif
s1::
        n$=eval$:(n$)
        d.n$=n$ :d.f3$=n2$ :d.title$=tit$       /* d.f3$ is second part of note */
        d.prio$=fix$(c%,0,3)                    /* If it's longer than 255 bytes */
        d.stat$="1"
        if sd%=1 :d.pn$=fix$(sd&,0,16) :endif
        if dc%=1 and d%<>0
                d.pdt$=fix$(pd&,0,16)
                if d.un$=""
                        d.un$=fix$(uniq:,0,16)
                endif
        endif
        append
        if dc%=1 and d%<>0
                wrproj:(1)      REM saves the project Due date
        endif
        if r%<>2 and ae%=0      REM ae%= autoentry (no questions asked)
                pos%=count
                na:
        endif
        as:                     REM sort if sorting is ON
        Pokeb peekw($1c)+7,0    REM bug fix for Findfield
        findfield(n$,1,1,1)
        sortpos%=pos
        sadd%=1
last
c:
pf%=0
return
nerr::
giprint err$(err)
ENDP




Don't hesitate to contact me if you have any problem.

                               Mark Esposito
                               Pelican Software Inc.
                               72662,3050  (Compuserve)
                               72662.3050@compuserve.com (Internet)
                               (713) 242-8928
                               (713) 242-9573 Fax
