home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Datafile PD-CD 3
/
PDCD_3.iso
/
pocketbk
/
utilsm
/
np52
/
PLUGINS.DOC
< prev
next >
Wrap
Text File
|
1995-06-15
|
7KB
|
213 lines
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.
NOTEPAD FILE FORMAT
filenam$,d,n$,dt$,tm$,un$,pdt$,pn$,prio$,exp$,app$,ahead$,stat$,f1$,f2$,f3$,f4$,f5$
n$ Main text for Note
dt$ Date for Alarm in days() format (string)
tm$ Time for Alarm in dtime format
un$ Unique number (long int)
pdt$ Due Date (long int) days format
pn$ Reserved
Prio$ Priority Number (1-20)
Exp$ Expansion Link (Name only, no extension) Assumed to be a .exp file
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 (call 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$-f5$ Reserved
1. Notes use logical drive d
(Example:) d.n$=Note :d.prio$="9" :d.stat$="1"
append
gclose mywin%
c:
sres%=1
return
2. The open notepad has one field referred to as d.n$, which holds the note.
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
d.n$=mydata$
d.prio$=fix$(d%,0,2)
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.
GLOBALS:
Current Window ID win%
Variable for holding note n$(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.
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 UK:
Set priority Priority: (brings up the priority list)
(and returns the number chosen)
Jump to any app Jump:("App Name")
Set alarm on current note: NA:
Reset alarm NY:
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
Note: There is no longer a 12byte header in Notepad. All information is in
separate fields. This should make life much simpler for writing plugins.
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%
onerr nerr
pf%=1
Opset:(0) REM open the settings file to find out if we need
r%=b.arem% REM to prompt for an alarm. b.arem% tells me this.
Opset:(1) REM close settings file.
if c REM if count
pp%=val:(d.prio$)+1 REM Increment the current priority number
else pp%=1
endif
top::
if c=0
n$=Editor$:(n$,"Add a New Note for "+nam$) REM start editor
if count=0 :nonotes: :endif REM Add dummy record if count=0
else
n$=Editor$:(n$,"Add a New Note")
endif
if n$="" REM no note added
return
endif
dinit
dtext"","Project Options",$302
pd&=days(day,month,year)
dc%=swd% REm swd% setting = Save with date setting
dchoice dc%,"Save With Date:","Yes,No"
ddate pd&,"Due Date",days(day,month,year-3),days(31,12,2049)
d%=dialog
c%=priority: REM set the priority
if c%=0 :goto top:: :endif
last :next
n$=eval$:(n$) REM evaluate any calculations
d.n$=n$ REM Set note
d.prio$=fix$(c%,0,3) REM set priority
d.stat$="1" REM set status active
if dc%=1 and d%<>0
d.pdt$=fix$(pd&,0,16) REM Set Due Date
if d.un$="" REm Add unique ID
d.un$=fix$(uniq:,0,16)
endif
endif
append
if dc%=1
wrproj:(1) REM if Due Date, send to Project file
endif
if r%<>2
pos%=count
na: REM Set an alarm
endif
as:
sres%=1 REM Set screen redraw
first
c: REM Set new count
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
(713) 242-8928