home *** CD-ROM | disk | FTP | other *** search
/ HomeWare 14 / HOMEWARE14.bin / netutils / pmail311.arj / RESOURCE.ZIP / FORMS.TXT < prev    next >
Text File  |  1993-08-23  |  26KB  |  534 lines

  1. ┌────────────────────────────────────────────────────────────────────┐
  2. │                   PMail v3.0 Programmable Forms                    │
  3. └────────────────────────────────────────────────────────────────────┘
  4.  
  5. To PMail v3.0, a form is simply a resource file containing certain
  6. required statements and an arbitrary number of control statements.  The
  7. format is quite complex, but I make no apology for this - the resulting
  8. forms architecture is extremely powerful and rewards the effort taken to
  9. create the form. It is possible to use the forms manager in PMail to
  10. recreate PMail's own standard editing window, as well as almost any
  11. single-screen data entry form imaginable. The forms manager provides
  12. access to all the most important PMail features, including address books,
  13. user lists, distribution lists and more.
  14.  
  15. Forms are prepared using a text editor such as Brief, DTE or (shudder)
  16. DOS EDIT, and are then compiled using the PMail resource compiler,
  17. ResCom. Forms are made available to users via the PM-MENU.RSC external
  18. interface mechanism in PMail v3.0 - examine the sample PM-MENU.R source
  19. file supplied with the PMail archive for more information on this 
  20. structure.  Resources in the file number from 0 and can take the form of
  21. several different data structures: a thorough understanding of the data
  22. types the forms manager uses is the essential key to being able to use
  23. the forms manager effectively.
  24.  
  25.  
  26. Resource file data structures
  27. -----------------------------
  28. The data structures used in forms fall into two general categories -
  29. built-in, and user-defined. The built-in data types are special hooks
  30. into internal mechanisms used by PMail's underlying user interface code
  31. and take a very strict, occasionally abstruse form. Some of the fields in
  32. the built-in data types will seem obscure, irrelevant or will simply
  33. never be used in the context of the forms manager, a hang-over from their
  34. use outside the realm for which they were originally intended. The
  35. built-in data types recognized by ResCom are:
  36.  
  37.   String, Text, Data, Menu, Block, Dstring, Window, Integer, Struct
  38.  
  39. The other class of data type is the user-defined group. The ResCom
  40. resource compiler supports a special type definition mechanism called a
  41. typedef which allows arbitrary data structures to be declared and used in
  42. resource files. Several user-defined data structures have been developed
  43. for use with the Forms manager - these are declared in the file FORMS.RH,
  44. which accordingly must be included in every form file's source code using
  45. the INCLUDE instruction before the first time any of the data structures
  46. are used. The major user-defined structures used in Forms management are:
  47.  
  48.    Formtable, popup_menu, line, box, editor, log
  49.  
  50.  
  51. The co-ordinate scheme
  52. ----------------------
  53. Many of the data structures used in forms design refer to a position on
  54. the screen: PMail's co-ordinate scheme runs from the top left of the
  55. window (at 1,1) to the bottom right.
  56.  
  57.  
  58. Data types and operators
  59. ------------------------
  60. Pegasus Mail is written in the C programming language, and the Resource
  61. compiler makes a number of assumptions based on this fact.  It also uses
  62. a certain number of terms and operators derived loosely from the C
  63. language (such as the struct data type, the typedef keyword and the
  64. bitwise operators). The resource compiler makes the following assumptions
  65. in particular:
  66.  
  67. * Integers are 16-bit signed entities in the range -32768 to 32767.
  68. * Strings are arbitrary arrays of ASCII characters terminated with a
  69.   single ASCII NUL (0) character.
  70.  
  71. The Resource compiler supports extremely simple integer arithmetic
  72. expressions evaluated strictly from left to right with no parenthesis
  73. operator. It is important to remember this if you use expressions, since
  74. what you are used to from C and Pascal will NOT hold true in a resource
  75. definition - to the resource compiler, 3 + 4 * 6 = 42. The following
  76. arithmetic operators are supported:
  77.  
  78.    + - * /  - Plus, Minus (binary and unary), Multiply, Divide
  79.    |        - Bitwise OR operator (7 | 7 = 7);
  80.    &        - Bitwise AND operator (128 & 127 = 0)
  81.    ^        - Bitwise XOR operator (8 ^ 15 = 7)
  82.  
  83. The very first resource in the file (resource 0) must be a STRING
  84. resource containing the title of the form.
  85.  
  86.  
  87. The built-in data structures
  88. ----------------------------
  89.  
  90. String
  91. ------
  92. The String data type declares an arbitrary string of ASCII characters of
  93. any length. Strings are usually used for single-line text resources such
  94. as window titles and default records. Strings can contain any ASCII value
  95. except the value zero which is used as a terminator (ResCom supplies the
  96. terminator automatically). Strings must be enclosed within quotes (") in
  97. the resource source file.
  98.  
  99. Text
  100. ----
  101. A text resource is essentially a scaled-up version of a string, intended
  102. to be multi-line. Text resources are used for large amounts of textual
  103. data such as help screens and formatting records for messages. Text
  104. resources can contain any ASCII character except zero, and ResCom will
  105. recognize certain "escapes" within strings:
  106.  
  107.    \r   -  replaced with a single carriage return character (13)
  108.    \n   -  replaced with a single newline character (10). A newline
  109.            is all that is required to indicate end of line for those
  110.            routines in the forms manager which display blocks of text
  111.            on the display
  112.    \e   -  Replaced with the Escape character (27)
  113.    \t   -  Replaced with the Tab character (9)
  114.    \"   -  Replaced with a single quote character
  115.    \\   -  Replaced with a single virgule ('\') character
  116.  
  117. Data
  118. ----
  119. A data resource defines a single data entry point on the screen into
  120. which the user can type information. The data record has the following
  121. structure:
  122.  
  123.    1: (Integer)  X (Horizontal) position of field on screen
  124.    2: (Integer)  Y (Vertical) position of field on screen
  125.    3: (Integer)  Maximum width ON SCREEN of the field
  126.    4: (Integer)  Maximum length of the variable (may be
  127.                  longer than the on-screen width)
  128.    5: (Integer)  Colour for an active field
  129.    6: (Integer)  Colour for a non-active field
  130.    7: (Integer)  Help, or arbitrary ID field for the entry
  131.    8: (Integer)  The data type of the field. Use the GT_*
  132.                  constants in defines.rh - eg, GT_INTEGER
  133.    9: (Integer)  Control flags for the entry: OR together the
  134.                  G* constants in defines.rh - eg GEND, GSECRET
  135.  
  136. Values 5, 6 and 9 are sensibly defaulted if 0. All other fields should
  137. have non-zero values, and have no defaults. The help value is always
  138. ignored by the forms manager and should be zero, since it is replaced by
  139. the help value defined in the formtabl record for the form.
  140.  
  141. Menu
  142. ----
  143. The menu data structure defines a menu with scrolling lightbar and
  144. keystroke selection. In terms of the forms manager a menu record is
  145. always used in association with the popup_menu user-defined data type
  146. and a menu cannot appear on its own. The menu type consists of a header
  147. followed by an array of menu records. The header has up to five integer
  148. values:
  149.  
  150.    1:  The total number of entries in the menu (must be < 24)
  151.    2:  The menu mode (any of the M* constants in defines.rh ORed)
  152.    3:  The offset of the default choice in the menu (starting from 0)
  153.    4:  The colour of a normal entry
  154.    5:  The colour of a selected entry
  155.  
  156. All the header values except 1 are sensibly defaulted
  157.  
  158. A menu record describes on entry in the menu: it is built as follows:
  159.  
  160.    1:  (Integer)  The X (horizontal) position of the item
  161.    2:  (Integer)  The Y (vertical) position of the item
  162.    3:  (Integer)  An optional help or ID value for the item       
  163.    4:  (Char)     The keystroke which selects this item
  164.    5:  (Integer)  The value to return if this item is selected
  165.    6:  (String)   The text to display for the choice
  166.       
  167. No item in a menu record is defaulted. Within the structure of the forms
  168. manager the Y and help values are always ignored.
  169.  
  170. Block
  171. -----
  172. A block is a set of strings displayed at the same X position on the
  173. screen, with the Y position incrementing with each string.  Block
  174. definitions are as follows:
  175.  
  176.    1: (Integer)  X (horizontal) position for block
  177.    2: (Integer)  Initial Y (vertical) position for block
  178.    3: (Integer)  Colour/mode word. OR together colours from
  179.                  defines.rh, and optionally OR position modifiers
  180.                  (such as wcentre, wadjacent).
  181.    4...n:        The strings to display.
  182.  
  183. To define a colour for a block you will usually combine a foreground
  184. colour and a background colour using the Resource compiler's OR operator
  185. ('|') - so for example, to create a block of text which is presented as
  186. white on blue you would use "WHITE | BBLUE". If you give only a
  187. foreground colour, the default background colour of the window will be
  188. used for the text.  Text can be centred within the window by combining
  189. the "wcentre" attribute with the colour integer using the OR operator.
  190. So, to display a block of text in Yellow on Light Grey centred in the
  191. current window, you would use the expression 
  192.    "YELLOW | BLIGHTGREY | wcentre".
  193.  
  194. American users: please notice the English spelling of "Grey" and "Centre"
  195. - you may wish to change these in DEFINES.RH if you are more comfortable
  196. with the US spelling.
  197.  
  198. Colour changes within strings: you can change between bright and normal
  199. video in mid-string by embedding Ctrl-A (ASCII 001) characters in the
  200. string. Each time a Ctrl-A is encountered the brightness mode is toggled.
  201. Embedding Ctrl-B characters toggles between normal and reverse video.
  202.  
  203. Dstring
  204. -------
  205. A dstring is a single-string version of a block. The X, Y and Attribute
  206. integers are identical but only one string may be provided.  Dstrings
  207. load and display faster than blocks.
  208.  
  209. Window
  210. ------
  211. The Window is the basic screen unit in PMail. Windows have local
  212. co-ordinate schemes starting at 1,1 for the top-left corner and preserve
  213. the screen beneath them, restoring it when they close. All forms in PMail
  214. must appear in a window: a form with no F_WINDOW resource is regarded by
  215. the forms manager as a template record for a standard editing screen. The
  216. Window data structure looks like this:
  217.  
  218.    1: (Integer)  X (Horizontal) position of window on screen
  219.    2: (Integer)  Y (Vertical) position of window on screen
  220.    3: (Integer)  Width of the window
  221.    4: (Integer)  Depth of the window
  222.    5: (Integer)  Colour and characteristics of window frame
  223.       - OR with colour and w* constants in defines.rh,
  224.       for example "wzip | BBLUE | WHITE".
  225.    6: (Integer)  Default text colour/attribute in window
  226.    7: (Integer)  Default fill character for window
  227.    8: (Integer)  Linestyle for window frame - use the B*
  228.       constants in defines.rh - eg, BSINGLE, BDOUBLE
  229.    9: (String)   Title for the window (maximum 40 characters)
  230.  
  231. Values 5, 6, 7 and 8 are sensibly defaulted if 0.
  232.  
  233. Integer
  234. -------
  235. Almost never used in forms, this data type declares a single integer
  236. value expressed in decimal form.
  237.  
  238. Struct
  239. ------
  240. Almost never used in forms, this data type allows you to agglomerate
  241. completely arbitrary data with no predefined format. Its use is not
  242. described in this document.
  243.  
  244.  
  245. The user-defined data types
  246. ---------------------------
  247.  
  248. The forms manager uses the following data types defined in FORMS.RH to
  249. create the data structures necessary to present a form.
  250.  
  251. Formtable
  252. ---------
  253. The most important single data type in a form, the formtable defines
  254. the order of data entry in the form and gives the forms manager the
  255. means to associate individual resources in the form with the various
  256. components of the message the form generates. The formtable resource
  257. must ALWAYS be the very last resource in the resource file, and is an
  258. array of an arbitrary number of structures consisting of six integers
  259. arranged as follows:
  260.  
  261.    1:  Resource number of the entry associated with this item. Since
  262.        the resource compiler expects resources to be named, you can
  263.        use the name you gave the resource in this field. It is
  264.        possible to use a resource ID of 0, usually when you want to
  265.        initialize a field in the message without any associated user
  266.        intervention.
  267.    2:  Correlation (see below)
  268.    3:  Resource number of the help for this entry; must be text type.
  269.    4:  Validation: for future use - not used in this release.
  270.    5:  Text resource containing the item's status line text (0 for none)
  271.    6:  Default: for booleans, 1/0; for ints/strings; resource ID
  272.  
  273. The correlation value is used to tell the forms manager what the item
  274. represents in e-mail terms, and must be selected from the following list:
  275.  
  276.    F_TO              Message's To: field
  277.    F_SUBJECT         Message's Subject: field
  278.    F_CC              Message's CC: field
  279.    F_BCC             Message's BCC: field
  280.    F_REPLY_TO        Message's Reply-to: field
  281.    F_READING         Message's Reading confirmation flag
  282.    F_DELIVER         Message's delivery confirmation flag
  283.    F_NOSIG           Message's "omit signature" flag
  284.    F_ENCRYPT         Message's encrypt flag
  285.    F_KEY             Message's encryption key
  286.    F_COPYSELF        Message's copy-self flag
  287.    F_MESSAGE         Message's text (usually an editor data type)
  288.    F_ATTACH          Message's attachment list
  289.    F_URGENT          Message's "urgent" flag
  290.    F_STRING          User-defined string field (max length 200 chars)
  291.    F_INTEGER         User-defined integer field
  292.    F_BOOLEAN         User-defined boolean (Y/N) field
  293.    F_SMTP_TEMPLATE   Formatting template to produce the output message
  294.    F_WINDOW          The window for the form
  295.    F_LOG             A logging resource
  296.    F_SERIAL          Serial number resource
  297.    F_STATUS          A status area (always a Box data type)
  298.  
  299. A correlation value of 0 is only legal for inert screen drawing elements
  300. such as lines, boxes and dstrings; defining a correlation of zero for any
  301. other form element will almost certainly result in PMail crashing when
  302. you attempt to run the form.
  303.  
  304. The help field in the formtable represents the resource ID of the
  305. resource which should be invoked in response to a request for
  306. context-sensitive help while this field is active.
  307.  
  308. The validation field will in future versions of PMail allow you to define
  309. a set of validation rules which should be applied to the data the user
  310. enters. In this release it is unimplemented and should be set to zero.
  311.  
  312. The status field refers to the resource ID of a block data type which
  313. should be displayed in the status area of the form when this field is
  314. active. Any user-interaction item can have status text, which is
  315. enabled by created a resource of type Box in the file and correlating
  316. it in the formtable to the F_STATUS correlation value. The Box type
  317. defines the bounding area of the status text area. For an example of
  318. defining and using status text, see the sample telephone message form
  319. provided with PMail 3.0, tphone.r.
  320.  
  321. The default field is the ID of a resource which should be loaded as a
  322. default value for the field. For fields where the data type is a Boolean
  323. value (yes or no) the default field is either 0 or 1 depending on the yes
  324. or no value of the field. For Integer and String data types the field
  325. refers to a resource which must be of string type. While it may seem odd
  326. to have a string as a default for an Integer field, this allows
  327. environment values such as the date or time to be used as defaults for
  328. Integer fields using form substitution (see below).
  329.  
  330. The order in which entries appear in the formtable defines the "tab
  331. order" of the form, or the order in which the Forms Manager will process
  332. the form's fields. The Forms Manager paints inert screen drawing elements
  333. such as lines and boxes in the order they appear in the formtable, which
  334. allows you to overlay text and graphic elements by ordering them
  335. carefully. Data entry elements such as data fields and popup menus are
  336. also processed in the order in which they appear in the formtable.
  337.  
  338. Popup_Menu
  339. ----------
  340. The Popup_Menu data type is used to create a popup menu in the form.
  341. When the user enters a popup menu field, an arrow will blink next to
  342. the field indicating that a menu is available by pressing <Enter>.
  343. If the user presses <Enter>, the menu will popup and the user will be
  344. able to choose from it. The "return value" of the menu, or the value
  345. which can be substituted into the message, is the text selected from
  346. the menu itself. The Popup_Menu data structure is defined as seven
  347. integers arranged as follows:
  348.  
  349.    1:  Resource ID of menu (use the name you gave the menu)
  350.    2:  X-coord. on the screen of the top left of the popup window
  351.    3:  Y-coord. on the screen of the top left of the popup window
  352.    4:  X-coord. on the screen where the menu result should display
  353.    5:  Y-coord. on the screen where the menu result should display
  354.    6:  Attribute word for the popup menu (colours etc)
  355.    7:  Attribute word for the menu result display text
  356.  
  357. Line
  358. ----
  359. A line resource simply allows you to draw a line on the screen. It
  360. consists of five integers and a character arranged as follows:
  361.  
  362.    1:  X position of start of line
  363.    2:  Y position of start of line
  364.    3:  If non-zero, the width of the line (horizontal)
  365.    4:  If non-zero, the height of the line (vertical)
  366.    5:  The colour attributes of the line
  367.    6:  The character to use to draw the line.
  368.  
  369. The line can be drawn with IBM extended ASCII characters; the ASCII
  370. values 196 and 205 draw single and double horizontal lines
  371. respectively, while the ASCII values 179 and 186 draw single and
  372. double vertical lines respectively. You can, of course, use any
  373. character you wish to draw a line except an ASCII NUL (0).
  374.  
  375. Box
  376. ---
  377. The Box resource draws an unfilled box on the screen using one of
  378. several line styles. The resource consists of six integer values
  379. organized as follows:
  380.  
  381.    1:  X position of top left corner of box
  382.    2:  Y position of top left corner of box
  383.    3:  Width (across the screen) of the box in characters
  384.    4:  Height (down the screen) of the box in characters
  385.    5:  Line style - select one of the following values
  386.        BSINGLE - single lines all around
  387.        BDOUBLE - double lines all around
  388.        BMIXED  - single vertical and double horizontal lines
  389.        BSOLID  - thick lines all around
  390.        BDOTS   - dotted lines all around
  391.    6:  Attribute word - colours etc.
  392.  
  393.  
  394. Editor
  395. ------
  396. The editor data type allows you to create a rectangular text editor
  397. in the form, usually for editing the text of the message. The editor
  398. type is defined as eight integers laid out as follows:
  399.  
  400.    1:  X co-ordinate of top left corner of editor rectangle
  401.    2:  Y co-ordinate of top left corner of editor rectangle
  402.    3:  Width of editor rectangle on screen
  403.    4:  Depth of editor rectangle on screen
  404.    5:  Maximum line length in editor (may be wider than width (3)
  405.    6:  Maximum number of lines of text the editor can accept
  406.    7:  Maximum number of characters the editor will accept
  407.    8:  Colour attributes for editor area.
  408.  
  409. Note that the line length may be wider than the width of the editor
  410. on screen - if it is, the editor will scroll horizontally when it
  411. reaches the right hand edge of the screen rectangle. The maximum size
  412. of the text an editor record can accept is 32000 bytes. An editor is
  413. almost always associated with the F_MESSAGE correlation in the form
  414. table since this is the only correlation which allows more than 200
  415. characters of data.
  416.  
  417. Logfile
  418. -------
  419. A log record is a special optional resource which can appear in the
  420. form to allow the message to be logged. After the message has been
  421. successfully sent, the last thing the Forms Manager does before
  422. tidying up and returning control to PMail is to scan the formtable
  423. for entries with the correlation set to F_LOG. For each F_LOG entry
  424. it finds it expects to find a logfile resource laid out as follows:
  425.  
  426.    1: (string, max 64 characters) the name of the log file
  427.    2: (integer) Resource ID of the text logging resource.
  428.  
  429. The filename is the name of the file to which the log information
  430. should be appended. If it does not exist, the Forms Manager will
  431. create it. In order for this facility to be useful, the logfile must
  432. clearly be in a location where the user has write access.
  433.  
  434. The resource ID must refer to a Text resource in the resource file
  435. which should be used to format the logging record added to the log
  436. file. The same substitution mechanisms used to format the outgoing
  437. message (see below) can be used to substitute values from the form
  438. into the logging record.
  439.  
  440.  
  441. Formatting the message for transmission
  442. ---------------------------------------
  443.  
  444. Getting the data from the user is only half the work of the Forms
  445. Manager - the other half is creating the outgoing message based on
  446. that data.
  447.  
  448. When the user has accepted the data in the form by pressing
  449. Ctrl-Enter or by "dropping through the bottom" of the form, the Forms
  450. Manager scans the formtable for an entry where the correlation is set
  451. to F_SMTP_TEMPLATE (the name is an anachronism - the same template is
  452. used for all message transports). If it does not find one, the entry
  453. in the table with the F_MESSAGE correlation is sent unaltered as the
  454. body of the message. If an F_SMTP_TEMPLATE correlation is found,
  455. however, the Forms Manager expects it to be a text resource which
  456. contains the format of the outgoing message body.
  457.  
  458. The formatting template consists of lines of text ending in the \n
  459. text escape; embedded in the text lines there will usually be special
  460. substitution strings which are replaced by fields from the form or
  461. which perform special formatting functions. Anything in the text
  462. resource which is not a substitution string is printed literally to
  463. the message. Substitution strings are always enclosed in curly
  464. brackets ('{' and '}') in the formatting record - so in the line
  465.  
  466.    "This is a sample string printed on {rfc-date}\n"
  467.  
  468. there is a stream of regular text which will be printed to the
  469. message unaltered, and a single substitution called "rfc-date" which
  470. will be replaced by the current date and time in RFC-822 format.
  471. Substitution strings are considered to be zero characters wide for
  472. formatting purposes, so a formatting string which results in an empty
  473. string will introduce no text into the message at all.
  474.  
  475. The following substitution strings can be used in templates, both for
  476. logging and for messages:
  477.  
  478. {to}           The message's TO: address field
  479. {subject}      The message's SUBJECT: field
  480. {cc}           The message's CC: field
  481. {bcc}          The message's BCC: field
  482. {reply-to}     The message's REPLY-TO: field
  483. {reading}      The message's reading confirmation flag (Y or N)
  484. {delivery}     The message's delivery confirmation flag (Y or N)
  485. {no-signature} The message's no-signature flag (Y or N)
  486. {encrypt}      The message's encryption flag (Y or N)
  487. {key}          The encryption key for the message
  488. {copyself}     The message's copy-to-self flag (Y or N)
  489. {message}      The message's text (the F_MESSAGE correlation)
  490. {urgent}       The message's urgent flag (Y or N)
  491. {field x}      The value of item number X in the formtable
  492. {rfc-date}     The time and date in full RFC-822 format
  493. {day}          The name of the current day
  494. {nday}         The number in the month of the current day
  495. {month}        The name of the current month
  496. {nmonth}       The number of the current month
  497. {year_2}       The current year expressed in two digits
  498. {year_4}       The current year expressing as a full four digits
  499. {username}     The name of the current user
  500. {servername}   The name of the server into which the user is logged.
  501. {tab x}        Pad with spaces to column X across the message
  502. {hour}         The hour component of the current time
  503. {minute}       The minute component of the current time
  504. {serial file}  Serial number resource - see below
  505. {domain}       The server's Internet name, defined in PCONFIG
  506.  
  507. The {message} substitution is column-sensitive: if it appears at a
  508. position indented from the left-hand edge of the template, the entire
  509. message text will print starting at that column. This allows you to
  510. set a kind of "indented left margin" for the message.
  511.  
  512. The {Serial} substitution allows you to define an automatically
  513. incrementing number stored in a writable file on the network. The
  514. file parameter to the substitution consists simply of a fully-
  515. qualified path in DOS or NetWare format to the file containing the
  516. serial number value. The file should contain the serial number as a
  517. simple ASCII string on a single line ending with a CR-LF pair - you
  518. can create this file using any standard text editor. Note that to be
  519. useful the file must be writable by anyone able to use the form; as
  520. well, the serial number is read and incremented the moment the Forms
  521. Manager encounters the {Serial} substitution, so take care if you use
  522. it to initialize a string in the form. There is no provision for
  523. "winding back" a serial number if the user aborts the form or if
  524. delivery fails.
  525.  
  526. Substitution widths: all substitutions can be given a width in the
  527. message by ending them with ":x", where X is the width of the field
  528. in which the substituted text should appear. As an example, if you
  529. want the current value of item 7 in the formtable to be printed in a
  530. field 50 wide, you would use the substitution "{field 7:50}". Items
  531. are always left-justified in fields.
  532.  
  533.  
  534.