The following describes how to bring Charm character map into your own OPL programs. You can use Charm in your own programs free of charge even if those programs are shareware or commercial (in which case they should be considerably bigger than Charm itself). I only ask for two things -- credit me in your README file and let me know. Thanks.
The subroutine displays the character map the same way it appears in Charm. However, the Font and Code fields, 4 characters of different sizes, and all the menu options are missing. As before, user can use arrow keys to move around and select a desired character. When Enter is pressed, the code of the selected character is returned.
USAGE:
CHARM%:( code%, font%, x%, y% )
PARAMETERS:
code% - ASCII code of the character to be initially selected
font% - font to use: 1 = S3 normal
2 = S3 digits
3 = Mono
4 = Roman
5 = Swiss
x% - X position of the main window (width = 450)
y% - Y position of the main window (height = 114)
RETURN VALUE:
0-255 - ascii code for the selected character when Enter was pressed
<0 - error code
-114 - Esc was pressed
$404 - While the character map was active, your program has received an Exit message.
NOTES:
- When positioning the main window keep in mind that the character box may be out of its bounds by 5 pixels in all directions.
- CHARM%:() creates 2 windows so make sure you have 6 or less windows/bitmaps before calling it.
- You can use LOCK ON/OFF before and after calling CHARM%:() if you don't want the System to send an Exit message.
- VER$: procedure returns current version of Charm, eg, "1.2"
- CHARM%:() doesn't appear to contain any bugs, but no programmer can guarantee it.
EXAMPLE:
--------------------8<---------------------
PROC test:
local k%, oldk%, fname$(15)
fname$ = "\app\charm.opa"
oldk% = %A
trap cache 2000, 2000
print "Press Tab to select from character map"
print "Press Psion-Esc to quit"
loadm fname$
print "Charm version "; ver$:
unloadm fname$
while 1
k% = get
if k% = 9
rem LOCK ON could go here
loadm fname$
k% = charm%:( oldk%, 5, 15, 30 )
unloadm fname$
rem LOCK OFF could go here
if k% = $404
rem ----- Exit message
print "Should save changes and exit here"
elseif k% < 0
rem ----- k% is error code *or* if k%=-114 Esc was pressed