home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1993 #2 / Image.iso / graphics / ripsc154.zip / TEMPLATE.DOC < prev   
Text File  |  1993-07-18  |  48KB  |  1,137 lines

  1.  
  2.  
  3. WHAT IS A TEMPLATE?
  4. -------------------
  5. A template is a special variety of a host command that is used to
  6. construct other host commands.  They are only used with the
  7. RIP_BUTTON command, not with RIP_MOUSE or RIP_QUERY.  Their use is
  8. solely dedicated to the Button command.  In fact, their usefulness is
  9. predominantly designed for Radio Buttons and Check Box Buttons but
  10. this doesn't mean that you cannot use them for other purposes.
  11.  
  12. A template, like a normal "raw" Host Command, is stored in the Host
  13. Command field of the RIP_BUTTON command.  Unlike Raw Host Commands
  14. that get sent to the Host immediately, templates do not transmit
  15. immediately.  In fact, it's possible for a Template to never get
  16. transmitted to the BBS at all.  Templates are not normally sent
  17. directly to the BBS - they are almost always used in conjunction with
  18. some other button's host command.
  19.  
  20.  
  21.  
  22. HOST COMMANDS - ADDING ANOTHER WRINKLE
  23. --------------------------------------
  24. As you know with normal Mouse Host Commands, you can send any piece
  25. of text you want when the user clicks on that button.  You could send
  26. the word "HELLO" to the BBS for example if they click on a certain
  27. mouse button.  This is an example of a "Direct Host Command".
  28.  
  29. There are three types of Host Commands.  There are:
  30.  
  31.      1) DIRECT HOST COMMANDS - Send a string of text to the host
  32.         immediately after the associated button is clicked.
  33.  
  34.      2) TEMPLATE DEFINITIONS - Defines a template to be used by
  35.         other buttons (if ever).  See below for further details
  36.         about how to define templates.
  37.  
  38.      3) TEMPLATE EXECUTION - This allows you to plug a piece of
  39.         string data into one or more templates (defined previously).
  40.         The resulting string is then acted upon like a Direct Host
  41.         Command and transmitted to the BBS immediately.
  42.  
  43. The RIP_BUTTON command "segments" its Text Parameter Block into three
  44. portions - the Icon File, Text Label followed by the Host Command
  45. block.  Each of these segments is separated by the two character
  46. delimiter "<>" like this:
  47.  
  48.           ICONFILE.ICN<>Button Label<>HOST COMMAND.
  49.  
  50. With the Button command, the Host Command segment can be sub-divided
  51. into numerous smaller sub-segments, or Command Blocks.  This is done
  52. with another two character delimiter "[]".  So, technically, you could
  53. do this:
  54.  
  55.      ICONFILE.ICN<>Button Label<>HELLO^m[]WORLD^m
  56.  
  57. This command would show an Icon Button using the file ICONFILE.ICN as
  58. its Icon Image, labeling it with the phrase "Button Label", and
  59. defining an extended Host Command block with two segments.  If the user
  60. clicks on this button, the following will be sent to the BBS:
  61.  
  62.      HELLO<cr>
  63.      WORLD<cr>
  64.  
  65. Notice how the "[]" is not transmitted.  This is because it is simply
  66. a delimiter separating two Command Blocks from each other.  Now each
  67. of these two command blocks are DIRECT HOST COMMANDS, but they don't
  68. have to be.  One of them could have been a Direct Host Command, and
  69. another could just as easily have been a template definition.
  70.  
  71.  
  72.  
  73. TIPTOE THROUGH THE TEMPLATES
  74. ----------------------------
  75. There can be up to 36 different templates defined simultaneously. 
  76. Each template number corresponds directly to a Button Group Number.
  77. Templates are identified by a single meganum 0-9 and A-Z, leaving 36
  78. distinctly separate groups.  To define a template, you use a
  79. variation of the Command Block delimiter "[]" with the template
  80. identifier followed by a colon like this:
  81.  
  82.      [5:]This is template #6's definition
  83.      [G:]This is template #16's definition
  84.  
  85. Defining a template is simple.  Activating a template however, is
  86. another story.  What if three buttons in the same group all define
  87. their own templates for the same group/template like this:
  88.  
  89.      Button #1:   [5:]This is button #1's template
  90.      Button #2:   [5:]This is button #2's template
  91.      Button #3:   [5:]This is button #3's template
  92.  
  93. Now, when these three buttons are received by the terminal, it 
  94. [the terminal] knows the Host Commands for each button (it memorized
  95. each of them).  Now, which of these three templates is the currently
  96. active one?  None of them!  A template definition doesn't become the
  97. active template until that button containing its definition is
  98. clicked (selected).  What this means is, you can have a bunch of
  99. buttons all belonging to the same Button Group with their own
  100. respective template definitions, but only the template relating to
  101. the most recently clicked button will be the currently active
  102. template for that group.  Whew, that was a mouthful!
  103.  
  104. There are two ways of activating a template:
  105.  
  106.      1) Draw a button as "pre-selected" - in other words, the
  107.         button is drawn pre-clicked immediately when it is
  108.         received by the terminal.  When this happens, the
  109.         Host Command for that button is processed immediately
  110.         and if a template definition exists in that host command,
  111.         it is acted upon immediately thus making that template
  112.         the currently active template for that Group.
  113.  
  114.      2) The user clicks on a button containing a template
  115.         definition.  If a template is already active in that
  116.         group, it is overwritten by the newly activated template.
  117.  
  118. In either case when templates are defined, nothing is actually
  119. transmitted to the BBS unless the Command Block contains some Direct
  120. Host Command sub-block(s) like this:
  121.  
  122.      [5:]Template definition[]hello world^m
  123.  
  124. If this button were clicked, then Group number 5 would have the
  125. template activated with the template text "Template definition". 
  126. Then the Direct Host Command "hello world^m" would be transmitted to
  127. the BBS.  In this example, we see how a single host command can do
  128. multiple things - in this case, it defined a template in group #5 AND
  129. transmitted something to the BBS!
  130.  
  131.  
  132.  
  133. TEMPLATES, RADIO BUTTONS AND CHECK-BOX BUTTONS
  134. ----------------------------------------------
  135. We have seen how templates are defined and activated.  Before we go
  136. any further, let's explain how they are used for Radio Buttons and
  137. Check-Box buttons.
  138.  
  139. Radio Buttons are a "type" of button group.  Only one button in that
  140. group can be active (clicked) at any one time.  If a button that is
  141. not active is clicked, any other buttons in that group that ARE
  142. clicked are de-selected and the one that is being clicked is
  143. selected.  If that newly clicked button has a Host Command, it is
  144. processed.  If it has a template definition, it too is processed,
  145. overwriting the currently defined template for the specified group.
  146. Since Radio Buttons can only have one currently active button in a
  147. single given Radio Group, similarly you can only have one template
  148. active for that group at any given moment.
  149.  
  150. Check Box Buttons are another "type" of button group.  Unlike Radio
  151. Buttons, Check Box buttons can have zero or more buttons active
  152. (clicked) at any one time.  If a check box button group has ten
  153. buttons defined in it, zero, five or all ten of those buttons can be
  154. active simultaneously.  What about each of their respective Host
  155. Commands?  They too are all processed when the buttons are
  156. individually clicked.  Now what about templates?  Since you can only
  157. have one template defined in a group at any given moment, how do
  158. check box buttons accomplish this multiple-template concept? 
  159. Whenever a check box button is clicked (or unclicked), the template
  160. for that group is re-calculated.  Any buttons in that group that have
  161. template definitions are scanned, and any check box buttons in that
  162. group that are selected, have their template definitions concatenated
  163. together (strung together) end on end.  The result is one large
  164. template which is built up from the template definitions of each
  165. selected check box button.
  166.  
  167. Let's take a couple simple examples step-by-step to see how templates
  168. are maintained internally.  In the first example, we will explore the
  169. Radio Buttons and the way templates relate to them.  In the second
  170. example, we'll examine check box buttons and templates.
  171.  
  172.  
  173.  
  174. EXAMPLE 1 - RADIO BUTTON TEMPLATES
  175. ----------------------------------
  176. Let's say you have four buttons in Button Group #3, and that button
  177. group is defined as a Radio Button group.  Here are the host command
  178. definitions for each of those buttons in this example:
  179.  
  180.      Button #1:   [3:]ABCD
  181.      Button #2:   [3:]EFGH
  182.      Button #3:   [3:]IJKL
  183.      Button #4:   [3:]MNOP
  184.  
  185. Now, if none of the buttons are clicked, then template group #3 is
  186. blank.  If button #1 is clicked, the template for group #3 would be
  187. defined as "ABCD".  Now, if button #4 is clicked, what would the
  188. template definition for group #3 be?  That's right, "MNOP".  Notice
  189. how only one of the given templates is active at any given moment.
  190.  
  191.  
  192.  
  193. EXAMPLE 2 - CHECK BOX TEMPLATES
  194. -------------------------------
  195. Now let's explore the slightly more complex world of check box
  196. templates.  As stated previously, check box templates can be strung
  197. along together to make a larger template - template construction of
  198. sorts.  Let's say you have a Button Group #2 defined as a check box
  199. group with 7 buttons defined in it.  Each of the buttons are
  200. initially drawn as "unselected", or unclicked (inactive).  Here are
  201. the button host command definitions for each of the 7 buttons:
  202.  
  203.      Button #1:   [2:]Apples^m
  204.      Button #2:   [2:]Oranges^m
  205.      Button #3:   [2:]Cherries^m
  206.      Button #4:   [2:]Grapes^m
  207.      Button #5:   [2:]Pears^m
  208.      Button #6:   [2:]Banannas^m
  209.      Button #7:   [2:]Lemons^m
  210.  
  211. Now, if all 7 buttons are not clicked, then template group #2 would
  212. be blank.  Let's click on some buttons and see what the template will
  213. become as we change which buttons are clicked and which aren't:
  214.  
  215.      Button #3 clicked (ON) .... Template:  Cherries^m
  216.      Button #5 clicked (ON) .... Template:  Cherries^mPears^m
  217.      Button #3 clicked (OFF) ... Template:  Pears^m
  218.      Button #5 clicked (OFF) ... Template:  <blank>
  219.      Button #2 clicked (ON) .... Template:  Oranges^m
  220.      Button #1 clicked (ON) .... Template:  Apples^mOranges^m
  221.      Button #4 clicked (ON) .... Template:  Apples^mOranges^mGrapes^m
  222.  
  223. As you can see, the active template for a check box group is actually
  224. a combination of all selected buttons' templates, in ORDER OF
  225. DEFINITION, not in the order that they were clicked.  Pay close
  226. attention to the end of the example where buttons were clicked in the
  227. order of 2, 1 then 4.  If you notice the active template though, they
  228. are in 1, 2 then 4 order!  They are in the order that the buttons
  229. were originally defined.
  230.  
  231.  
  232.  
  233. TAKING ADVANTAGE OF TEMPLATES
  234. -----------------------------
  235. We've already gone through and shown you how to define templates and
  236. how to activate them.  Now you need to know how to put them to use -
  237. how to take a template and make it do something.  If you've been
  238. confused up to this point, don't worry - we're going to put it all
  239. together in a few minutes into one big picture.
  240.  
  241. There are two ways of using templates.  One is called Template
  242. Chaining, and another is called Template Embedding.  Each of these
  243. two methods are quite different, but give you quite a bit of
  244. flexibility.  Let's take each of these methods step-by-step by
  245. describing each in detail separately.
  246.  
  247.  
  248.  
  249. TEMPLATE EMBEDDING
  250. ------------------
  251. Template embedding is a way of "inserting" a template inside another
  252. host command.  What this means is that you can insert the contents of
  253. an active template inside of a button's Direct Host Command.  The
  254. direct host command is "expanded" around the inserted template and
  255. the contents of the specified template are made part of the direct
  256. host command.
  257.  
  258. Let's illustrate this with an example.  Taking the check box example
  259. above which had a list of fruits as check box buttons, we can expand
  260. on this example to show how template embedding can be a useful tool. 
  261. In this example, we will build a menu to take someone's order for
  262. fruit.  Here is what the simple menu screen will look like:
  263.  
  264.       +----------------------------------------+
  265.       |     What would you like to order?      |
  266.       |                                        |
  267.       | +-----------+                          |
  268.       | |X  Apples  |                          |
  269.       | |   Oranges |         +------------+   |
  270.       | |X  Cherries|         |Submit order|   |
  271.       | |   Grapes  |         +------------+   |
  272.       | |X  Pears   |                          |
  273.       | |   Banannas|                          |
  274.       | |X  Lemons  |                          |
  275.       | +-----------+                          |
  276.       +----------------------------------------+
  277.  
  278. As you can see, we have a set of 7 check box buttons on the left of
  279. the menu with the choices of the fruits for sale.  On the right is a
  280. button to submit your order.  To implement this example, we will use
  281. two separate button groups.  Group #0 will contain one button, the
  282. "Submit Order" button.  Button Group #2 will be a check box button
  283. group containing our seven choices of fruits as in the preceding
  284. example.  Here are the Host Command definitions for each of the eight
  285. buttons:
  286.  
  287.      Group #0 (normal button - not a radio or check-box button)
  288.      ----------------------------------------------------------
  289.           SUBMIT ORDER:   I wish to order $?2$ right now^m
  290.  
  291.      Group #2 (check box button group)
  292.      ---------------------------------
  293.           APPLES:    [2:]APPLES^m
  294.           ORANGES:   [2:]ORANGES^m 
  295.           CHERRIES:  [2:]CHERRIES^m
  296.           GRAPES:    [2:]GRAPES^m  
  297.           PEARS:     [2:]PEARS^m   
  298.           BANANNAS:  [2:]BANANNAS^m
  299.           LEMONS:    [2:]LEMONS^m
  300.   
  301. Notice in the "Submit Order" button that there is a special code in
  302. the Direct Host Command "$?2$".  This is a special variation of a text
  303. variable.  This form of text variable is used only in Template
  304. Embedding.  What it does is instructs the terminal to "insert template
  305. #2 here".  The format of the template embedding code is:
  306.  
  307.           $?x$
  308.  
  309. ...where "x" is the template identifier (0-Z) that is to be inserted.
  310. Now back to the example, if the user clicked on "APPLES", "CHERRIES",
  311. "PEARS" and "LEMONS" as in the menu shown above, then clicks on
  312. "Submit Order", what would the Host Command look like when it gets
  313. transmitted to the BBS?  Well, for starters, the Submit Order
  314. button's host command reads:
  315.  
  316.      I wish to order $?2$ right now^m
  317.  
  318. After template #2 is inserted where the embedding code is, the host
  319. command would look like this:
  320.  
  321.      I wish to order APPLES^mCHERRIES^mPEARS^mLEMONS^m right now^m
  322.  
  323. And after the ^m's are converted to carriage returns the final host
  324. command would be like this:
  325.  
  326.      I wish to order APPLES
  327.      CHERRIES
  328.      PEARS
  329.      LEMONS
  330.      right now
  331.  
  332. What if the user didn't click on any of the fruits, but did click on
  333. the Submit Order button?  Well, since template #2 belongs to a group
  334. that is a Check Box group, which can have zero or more items selected
  335. simultaneously, the $?2$ code would be expanded to a null string, or
  336. nothing, so the final host command would be:
  337.  
  338.      I wish to order  right now
  339.  
  340. If template #2 was associated with a Radio group which has to have
  341. one button clicked at all times, and none of the buttons were active,
  342. then the terminal would hilight all the radio buttons in group #2 and
  343. instruct the user to choose one first.  This is done automatically by
  344. the terminal, you don't need to worry about Radio Buttons.
  345.  
  346. Just remember, Check Box buttons can legitimately have a blank
  347. template, but Radio Buttons cannot due to the very nature of the
  348. buttons.
  349.  
  350. The final host command after template embedding is limited to 4096
  351. bytes of data.  If a host command would grow beyond 4096 bytes due to
  352. embedding, it is truncated to exactly 4096 bytes.
  353.  
  354.  
  355.  
  356. TEMPLATE CHAINING
  357. -----------------
  358. Now, on to the second form of using templates, Template Chaining. 
  359. Template Chaining is another method of using templates.  Unlike
  360. Template Embedding though, template chaining is quite different. 
  361. Rather than inserting the contents of a template into a host command,
  362. like in embedding, template chaining feeds data into a template and
  363. then takes the result and transmits that to the BBS.  In other words,
  364. Template Embedding inserts a template into a Host Command.  In
  365. Template Chaining, a Host Command is inserted into a template (the
  366. exact opposite).
  367.  
  368. If you recall from the Template Embedding discussion earlier, there
  369. was a code for inserting a template into a host command.  The command
  370. was $?x$ where "x" was the template number.  Template Chaining uses a
  371. similar insertion code but with a subtle different - there is no
  372. template identifier.  The code is:
  373.  
  374.      $?$
  375.  
  376. This is a "generic insertion code".  It is used in the template
  377. definition itself, not in the Direct Host Command like the template
  378. embedding code was used.  The actual data that replaces the $?$
  379. depends on the Direct Host Command that is "feeding" the template.
  380.  
  381. Before template chaining becomes crystal clear, we need to muddy the
  382. waters some more by introducing one more thing - the Chaining
  383. command.  A template chaining operation is performed almost exactly
  384. like defining a template with a subtle difference, the colon (:) is
  385. omitted from the template definition like this:
  386.  
  387.      [5]This is template chaining
  388.      [5:]This is template definition
  389.  
  390. What's the difference?  In the case of the [5:], a template for group
  391. #5 is defined.  In the [5] example, the template chaining instruction
  392. is invoked on Template #5.  The phrase "This is template chaining"
  393. will be fed into template number 5.  If template number 5 has a
  394. generic insertion code $?$ in it, then it will be replaced with the
  395. phrase "This is template chaining".  The final result after the
  396. replacement will be a direct host command that will be transmitted to
  397. the BBS.  Since template #5 doesn't have an insertion code, the
  398. phrase "This is template chaining" will be lost in the chaining
  399. process and the final host command would be "This is template
  400. definition".
  401.  
  402. Here are a couple examples of template chaining illustrating several
  403. ways that it may be used (we'll only show "active" template
  404. definitions):
  405.  
  406.      [3:]This is a plain old template
  407.      [4:]This template inserts $?$ here!
  408.      [5:]This has two insertion codes $?$ and $?$
  409.  
  410.      [3]This text is lost in the chaining process
  411.      [4]SOMETHING
  412.      [5]HERE
  413.  
  414. This would be the result of the three chaining operations:
  415.  
  416.      3 ... This is a plain old template
  417.      4 ... This template inserts SOMETHING here!
  418.      5 ... This has two insertion codes HERE and HERE
  419.  
  420. We skipped over the "user clicked on this button" operations and went
  421. directly to the end results to make the example as clear as possible. 
  422. There are three distinctly different situations in this example.  The
  423. first shows a regular template without an insertion code being used
  424. in a chaining operation.  As you can see, the data that was fed into
  425. template #3 was lost because template #3 didn't have an insertion
  426. code.  In the second example, a single insertion code is used and the
  427. word "SOMETHING" is inserted in place of the insertion code.  The
  428. third example shows that an insertion code can be used more than once
  429. in a given template.
  430.  
  431. What if you tried to chain to a template that hasn't been activated
  432. yet (ie, a blank template)?  If the template in question belongs to a
  433. radio group, then the terminal would instruct the user to click on
  434. one of the radio buttons to activate the template (he doesn't know
  435. that templates are invovled of course).  If it was a check box
  436. template, then the final host command would be nothing and in effect,
  437. nothing would be transmitted to the host.  If the template in
  438. question belonged to a generic button group, then also nothing would
  439. get transmitted to the BBS.
  440.  
  441. In the preceding Template Chaining examples, only one template was
  442. used (chained-to).  In reality, you can chain to multiple templates
  443. with ease.  The format of multiple Template Chaining is simple, just
  444. add the template identifiers for the templates you want to chain to
  445. in the order you wish to chain to like this:
  446.  
  447.      [1E3]This is a three-level chaining operation
  448.  
  449. Notice how the Template Chain command has three template identifiers
  450. in it, 1, E and 3.  The Host Command would be fed into template #1
  451. first.  After any replacements, the final result of the template #1
  452. chaining would be finished and that string of text would be fed into
  453. template #E.  After any replacements/insertions are performed on
  454. template #E, then the final result is fed into template #3 and the
  455. final result of that chaining operation is sent to the BBS.
  456.  
  457. Here is an example of multiple template chaining calls:
  458.  
  459.      [1:]red green $?$ blue
  460.      [E:]LOUD QUIET $?$ YELL
  461.      [3:]soft $?$ hard smooth gritty
  462.  
  463.      [1E3](host command)
  464.  
  465. In this example, the phrase (host command) is fed into template #1,
  466. then the result into template #E then that result into template #3
  467. then finally transmitted to the BBS.  We can break this down
  468. conceptually into three separate chaining operations to illustrate
  469. what happens step-by-step:
  470.  
  471.      [1E3](host command)
  472.  
  473. Results in:
  474.  
  475.      [E3]red green (host command) blue
  476.  
  477. Resulting in:
  478.  
  479.      [3]LOUD QUIET red green (host command) blue YELL
  480.  
  481. And then finally:
  482.  
  483.      soft LOUD QUIET red green (host command) blue YELL hard smooth gritty
  484.  
  485. This last phrase is then sent to the BBS verbatim.  As you can see,
  486. things can get pretty complex when multiple template chains are used,
  487. however some dramatic things can be achieved with a little bit of
  488. effort and some well thought out planning of your template
  489. definitions.  Template chaining is useful for controlling HOW
  490. particular data is transmitted to the BBS, while template embedding
  491. is useful for controlling WHAT data is transmitted to the BBS.
  492.  
  493. You can think of template chaining as a method of defining "commands"
  494. that will be sent to the BBS where the commands can be different
  495. depending on which buttons are clicked in that group.  Template
  496. embedding on the other hand is often used for controlling the data
  497. parameters that are used with particular commands.
  498.  
  499. You are allowed up to 36 separate template chaining levels in one
  500. template chaining operation.  After all chaining is completed, the
  501. final host command cannot exceed 4096 bytes.  If a chaining operation
  502. would exceed that amount, it is truncated to exactly 4096 bytes.
  503.  
  504.  
  505.  
  506. GETTING FANCY WITH TEMPLATES
  507. ----------------------------
  508. You've already learned about Template Embedding and Template
  509. Chaining.  These two methods of using templates do not need to be
  510. separate methods.  You can combine these methods if you wish.  This
  511. means that you can have embedded templates inside of template chains. 
  512. This provides for utter flexibility in doing whatever you want.
  513.  
  514. Here are a couple of examples of combinations:
  515.  
  516.    EXAMPLE 1
  517.    ---------
  518.  
  519.           [5:]EMBEDDED VALUE
  520.  
  521.           [3:]Here is a $?$ and an $?5$
  522.  
  523.           [3]CHAINED HOST COMMAND
  524.  
  525.      This would result in:
  526.  
  527.           Here is a CHAINED HOST COMMAND and an EMBEDDED VALUE
  528.  
  529.  
  530.    EXAMPLE 2
  531.    ---------
  532.  
  533.           [5:]EMBEDDED VALUE
  534.  
  535.           [3:]Here is a $?$ and an $?5$
  536.           [4:]print("$?$")
  537.  
  538.           [34]CHAINED HOST COMMAND
  539.  
  540.      This would result in:
  541.  
  542.           print("Here is a CHAINED HOST COMMAND and an EMBEDDED VALUE")
  543.  
  544.  
  545.    EXAMPLE 3
  546.    ---------
  547.  
  548.           [4:](hello)
  549.           [5:]ANOTHER $?5$ EMBEDDED $?4$ VALUE
  550.      
  551.           [3:]Here is a $?$ and $?5$
  552.  
  553.           [3]CHAINED COMMAND
  554.  
  555.      This would result in:
  556.  
  557.           Here is a CHAINED COMMAND and ANOTHER ANOTHER $?5$ EMBEDDED $?4$
  558.           VALUE EMBEDDED (hello) VALUE
  559.  
  560.      Taking this one step-by-step:
  561.  
  562.           Step #1:   Here is a CHAINED COMMAND and $?5$
  563.  
  564.           Step #2:   Here is a CHAINED COMMAND and ANOTHER $?5$
  565.                      EMBEDDED $?4$ VALUE
  566.  
  567.           Step #3:   Here is a CHAINED COMMAND and ANOTHER ANOTHER 
  568.                      $?5$ EMBEDDED $?4$ VALUE EMBEDDED (hello) VALUE
  569.  
  570.                <end of processing>
  571.  
  572.  
  573.    EXAMPLE 4
  574.    ---------
  575.  
  576.           [5:]HELLO
  577.  
  578.           [3:]$?5$ $?$ WORLD
  579.  
  580.           [4:]print("$?$")^m
  581.  
  582.           [344](silly)
  583.  
  584.      This would result in:
  585.  
  586.           print("print("HELLO (silly) WORLD")^m")^m
  587.  
  588.  
  589. Example #1 shows a situation with a single chaining operation and a
  590. single embedding operation done at the same time.  You can see how
  591. the final host command is in relation to the data fed into the
  592. templates at different points.
  593.  
  594. Example #2 shows a more complex situation where multiple levels of
  595. template chaining are going on while embedding is also being used.
  596.  
  597. Example #3 is somewhat different though.  Why weren't the embedded
  598. template codes expanded at the lowest level of template #5?  If you
  599. look closely at template #5, it has an insertion code instructing the
  600. system to insert template #5 (itself) in the middle of the template. 
  601. This is legal, but only because an embedded template inside an
  602. embedded template cannot have any more embedding performed on it.  In
  603. other words, you are allowed up to two levels of embedded templates,
  604. but the lowest level (2nd) cannot have any insertion codes, text
  605. variables, control characters or pick-list definitions in it - if it
  606. does, they will be treated as "raw" text instead of host command
  607. directives.
  608.  
  609. Example #4 shows a more involved Template Chaining operation in which
  610. the same template is chained to more than once in a given operation. 
  611. This is allowable for extra flexibility, although in the real world
  612. will probably not be used much.
  613.  
  614.  
  615.  
  616.  
  617. TEMPLATES, TEXT VARIABLES, PICK LISTS AND CONTROL CHARACTERS
  618. ------------------------------------------------------------
  619. Now that we have thouroughly discussed templates, we come upon
  620. another subject - that of text variables, pop-up pick lists, and
  621. control characters.  In any template definition or host command, you
  622. can have text variables, pick lists or control characters anywhere.
  623. This gives you the ability to do a great many things.
  624.  
  625. You can freely use text variables, control characters or pick lists
  626. anywhere in a Direct Host Command, in a template chains and embedded
  627. templates.  There is nothing unusual about text variables, pop-up
  628. pick lists or control characters when they're used in template chains
  629. or Direct Host Commands.  They do get a bit odd though in how they
  630. interact with Embedded Templates - but only if you have an embedded
  631. template within an embedded template.
  632.  
  633. Recall from a previous discussion about embedded templates within
  634. embedded templates.  At the lowest level of the embedding, there is
  635. no processing done on the string of text.  This is to prevent endless
  636. loops and combinatorial explosion of data and CPU time.  Text
  637. Variables, pick lists and control characters WILL be processed at the
  638. first level of an embedded template, but not at the second level.
  639.  
  640. Here are some examples that better illustrate text variables:
  641.  
  642.  
  643.      EXAMPLE 1
  644.      ---------
  645.  
  646.           [3:]The date is $DATE$ ... $?$
  647.  
  648.           [3]HELLO
  649.  
  650.        Results in:
  651.  
  652.           The date is 07/18/93 ... HELLO
  653.  
  654.  
  655.  
  656.      EXAMPLE 2
  657.      ---------
  658.  
  659.           [3:]The date is $DATE$
  660.  
  661.           HELLO THERE, $?3$
  662.  
  663.        Results in:
  664.  
  665.           HELLO THERE, The date is 07/18/93
  666.  
  667.  
  668.  
  669.      EXAMPLE 3
  670.      ---------
  671.  
  672.           [2:]The time is $TIME$^m
  673.           [3:]The date is $DATE$^m
  674.  
  675.           HELLO THERE^m$?3$$?4$
  676.  
  677.        Results in:
  678.  
  679.           HELLO THERE
  680.           The date is 07/18/93
  681.           The time is 03:43:32
  682.  
  683.  
  684.  
  685.      EXAMPLE 4
  686.      ---------
  687.  
  688.           [1:]The day is $DOW$^m
  689.  
  690.           [2:]The time is $TIME$^m
  691.           [3:]The date is $DATE$^m$?1$^m
  692.  
  693.           HELLO THERE^m($?3$)($?4$)($?1$)
  694.  
  695.        Results in:
  696.  
  697.           HELLO THERE
  698.           (The date is 07/18/93)
  699.           The day is $DOW$^m
  700.           (The time is 03:43:32)
  701.           (The day is Sunday)
  702.  
  703.        Notice how the $?1$ embedded template used in template #3 does
  704.        not get processed - it is just inserted raw.
  705.  
  706.  
  707.  
  708. PROCESSING OF TEMPLATES
  709. -----------------------
  710. As stated previously, template definitions may contain text 
  711. variables, pick lists, control characters, and template insertion
  712. codes.  When do these special "directives" get processed?  The answer
  713. is when the template gets USED, not when it becomes ACTIVE!  To
  714. better illustrate this, let's look at a simple example.
  715.  
  716. Let's say you have three radio buttons (group #2) on the screen and
  717. another button (group #0) which uses the template for the radio
  718. button group 3.  Here's the host command definitions for each of
  719. these four buttons:
  720.  
  721.  
  722.      Group #2 - Radio Button Group
  723.      -----------------------------
  724.  
  725.           Button #1:  [2:]It's a pretty day at $TIME$
  726.           Button #2:  [2:]It's a rainy day at $TIME$
  727.           Button #3:  [2:]It's a hazy day at $TIME$
  728.  
  729.      Group #0 - Ordinary button group
  730.      --------------------------------
  731.  
  732.           Button #4:  Today's forecast:^m$?2$
  733.  
  734.  
  735. Now, let's say that none of the radio buttons are drawn as "selected"
  736. for starters.  At 11:45:03 in the morning, the user clicks on button
  737. #2 indicating it's a rainy day.  The active template for group #2
  738. would be defined as:
  739.  
  740.           It's a rainy day at $TIME$
  741.  
  742. At 11:46:37 he clicks on the Forecast button.  What would be the host
  743. command sent to the BBS in this example?  It would be:
  744.  
  745.           Today's forecast:
  746.           It's a rainy day at 11:46:37
  747.  
  748. Notice that the time that is inserted in place of $TIME$ is the time
  749. that the user clicked on the Forecast button, NOT the time he clicked
  750. on the "rainy day" button which activated the proper template.  This
  751. illustrates that text variables, pick lists, and control characters
  752. are not "processed" until they are referenced (used) by some other
  753. button or template in an active Host Command situation.
  754.  
  755.  
  756.  
  757. COMMAND BLOCKS - SEGMENTING A HOST COMMAND 
  758. ------------------------------------------
  759. Near the beginning of our discussion of templates we spoke about
  760. Direct Host Commands, Template Definitions and Template Execution.
  761. You have seen how to define templates with a template definition
  762. command like [3:]HELLO, and how to execute templates by either
  763. Chaining (eg, "[3]WORLD"), or by using Embedded Templates 
  764. (eg, "$?3$ WORLD").
  765.  
  766. Now, remember that we spoke about how a single Host Command can be
  767. segmented into multiple "Command Blocks" by separating them with the
  768. delimiter "[]".  An example of this might be:
  769.  
  770.      HELLO^m[]WORLD^m
  771.  
  772. This would transmit the following to the BBS:
  773.  
  774.      HELLO<cr>
  775.      WORLD<cr>
  776.  
  777. Realistically, you wouldn't use such an overly simple example like
  778. this, but would use the following instead:
  779.  
  780.      HELLO^mWORLD^m
  781.  
  782. This would produce the same result.  But it doesn't illustrate the
  783. purpose of Command Blocks.  Here's a real-world example of a host
  784. command broken down into several command blocks:
  785.  
  786.   [3:]Template Definition[4]Template chaining[]BBS TEXT
  787.  
  788. If you look carefully at the above host command, three distinct
  789. things are happening.  First, template #3 is defined with the text
  790. "Template Definition".  Secondly, the phrase "Template chaining"
  791. is chained (fed) into template #4 (whatever that one is) and the
  792. final result of the chaining operation is sent to the BBS.  Finally,
  793. the last command block is processed which happens to be a Direct Host
  794. Command, so the text "BBS TEXT" will be transmitted to the Host as
  795. well.
  796.  
  797. If a host command doesn't have one of the command block delimiters
  798. like a template definition (eg, "[3:]"), or a template chain
  799. directive (eg, "[3]"), or a Direct Host Command Directive (eg, "[]"),
  800. then the Host Command is, by default, considered to be a Direct Host
  801. Command.  The following are all considered Direct Host Commands and
  802. they all do the exact same thing:
  803.  
  804.      HELLO^mWORLD^m
  805.      HELLO^m[]WORLD^m
  806.      []HELLO^mWORLD^m
  807.      []HELLO^m[]WORLD^m
  808.  
  809. Here are some more examples of Command Blocks using the previous
  810. example as a foundation, but this time we throw in another command
  811. block.  Again, all four of these examples do the exact same things:
  812.  
  813.      HELLO^mWORLD^m[3:]Template Definition
  814.      HELLO^m[]WORLD^m[3:]Template Definition
  815.      []HELLO^mWORLD^m[3:]Template Definition
  816.      []HELLO^m[]WORLD^m[3:]Template Definition
  817.  
  818.  
  819.  
  820. COMMAND BLOCKS, RADIO BUTTONS AND CHECK BOX BUTTONS
  821. ---------------------------------------------------
  822. If you recall from our earlier discussions about Radio Buttons and
  823. Check Box Buttons, the templates definitions are activated based upon
  824. a Button being activated.  If you think about Command Blocks though,
  825. you might be inclined to think that figuring out which template
  826. definition block of a command block to activate might get insane.  It
  827. could!  Look at the following set of three Radio Button definitions:
  828.  
  829.      Button #1:  [3:]Hello world[3:]This is Pluto
  830.      Button #2:  [3:]Hello world[3:]This is Saturn
  831.      Button #3:  [3:]Hello world[3:]This is Jupiter
  832.  
  833. What happens if button #2 is clicked, thus activating that template? 
  834. What template command block is used to create the final, active
  835. template?  The answer is the last one!  The text that becomes the
  836. actual active template for template #3 would be this:
  837.  
  838.      This is Saturn
  839.  
  840. If a Host Command references this template as in the following
  841. example, you will see that the secondary template definition is
  842. the one that is actually in use:
  843.  
  844.      I'm a martian singing in the rain^m$?3$
  845.  
  846. Resulting in:
  847.  
  848.      I'm a martian singing in the rain
  849.      This is Saturn
  850.  
  851. In short, Command Blocks are processed in all situations, and if a
  852. discrepency exists where two or more template definitions in the same
  853. Host String correspond to the same template group, the last
  854. definition is the one that becomes active.  This applies even if you
  855. are dealing with Check Box buttons.  In the above example of the
  856. martian, if Buttons #1, 2 and 3 were Check Box Buttons instead, the
  857. "Hello World" template definitions would still be lost and would NOT
  858. get concatenated together to create the final Host Command.  If
  859. buttons #1 and #3 are clicked, then template #3 would be:
  860.  
  861.      This is PlutoThis is Jupiter
  862.  
  863. It would NOT be:
  864.  
  865.      Hello worldThis is PlutoHello worldThis is Jupiter
  866.  
  867.  
  868.  
  869. CONTROL CHARACTERS
  870. ------------------
  871. Not all BBS'es will allow you to use control characters on their
  872. Service.  Regardless of that, the capability to send any Control
  873. Character exists for your Host Commands.  The most commonly used
  874. Control Characters are:
  875.  
  876.    INDIVIDUAL CONTROL CHARACTERS         SPECIAL KEYSTROKES
  877.    ===========================================================
  878.    ^@ ... Null (ASCII 0)                 ^[[A ... Up Arrow
  879.    ^G ... Beep                           ^[[B ... Down Arrow
  880.    ^L ... Clear Screen (Top of Form)     ^[[C ... Right Arrow
  881.    ^M ... Carriage Return                ^[[D ... Left Arrow
  882.    ^C ... Break (sometimes)              ^[[H ... Home Key
  883.    ^H ... Backspace                      ^[[K ... End Key
  884.    ^[ ... Escape character               ^[[L ... Control Home
  885.    ^S ... Pause data transmission        
  886.    ^Q ... Resume data transmission
  887.  
  888. Some hosts use the ^ (caret) for their own purposes.  In these
  889. cases, you can use the ` (backquote) character instead of the
  890. caret.  Some systems allow you to specify the caret symbol as
  891. two carets (^^).  Consult your Host Software documentation to
  892. determine the best method for your needs.
  893.  
  894. NOTE:  RIPterm uses ^ or ` and a character to represent a control
  895.        character.  IT IS NOT A CONTROL CHARACTER BY ITSELF, IT
  896.        IS TRANSLATED BY RIPterm.  In other words, ^M does not send
  897.        a ^ and then an M, it sends a carriage return (ASCII 13).
  898.        Likewise, RIPscrip commands like Query do not use an ^[, an
  899.        actual escape character (ASCII 27) is used.
  900.  
  901.  
  902.  
  903. TEXT VARIABLES
  904. --------------
  905. A special feature of RIPterm allows it to understand what a Text
  906. Variable is.  A text variable is a piece of text that both RIPaint
  907. and RIPterm know something about.  For example, the Text Variable
  908. $DATE$ is known to represent the current Date on your PC.  The host
  909. may ask your system what the values of one or more of these variables
  910. are, and if your terminal knows these particular Text Variables, it
  911. will tell the host.
  912.  
  913. There are three types of Text Variables.
  914.  
  915. -- Built-In Text Variables that RIPscrip products will ALWAYS
  916.    know about.  These include Text Variables like date and time
  917.    that return a value
  918.  
  919. -- Another type of built-in Text Variable are Active Text
  920.    Variables, which perform an action, but return nothing to
  921.    the host.  These include turning the status bar on/off,
  922.    clearing the graphics screen, and playing some simple
  923.    sounds, and many more.
  924.  
  925. -- Then there are also User Text Variables that can contain
  926.    a variety of information depending on what the user
  927.    entered at the time the variable was created.  For
  928.    example, the host might ask you what the contents of the
  929.    $FULL_NAME$ variable is, and if RIPterm doesn't know, it
  930.    could pop-up a field on the screen and ask you about it.
  931.    From then on, RIPterm will remember that piece of
  932.    information for the next time it is needed by a host.
  933.  
  934. You may use either the pre-defined Text Variables, or the User Text
  935. Variables at any place that allows Text Variables.
  936.  
  937.  
  938.  
  939. LOCAL RIPscrip FILE PLAYBACK
  940. ----------------------------
  941. You can re-play a .RIP file that you have locally on your hard disk
  942. from anyplace that allows text variables.  The format of the variable
  943. is somewhat different than user variables, or pre-defined text
  944. variables.  After the initial dollar sign ($), enter the greater-than
  945. symbol (>) followed by the filename (with or without the .RIP
  946. extension), then ending in another dollar sign ($).  Several examples
  947. of this are as follows:
  948.  
  949.          $>MYFILE.RIP$
  950.          $>FILE1$
  951.          $>FILE1.RIP$$>FILE2.RIP$$>FILE3$
  952.  
  953. Note in the last example, a file extension other than .RIP was used.
  954. You are not limited to playing back local .RIP files.  In fact, you
  955. can play-back any file you want.  You could load any simple text
  956. file, ANSI picture image, or other such thing.  When loaded, the data
  957. is not sent to the host; it is strictly echoed on your local screen.
  958. If the file is a .RIP file, it will replay any graphics that were in
  959. the file and if any Mouse Regions are defined, it will create those
  960. fields for you as well, thus allowing you to pop-up dialog screens or
  961. other such things that are not built-in to RIPterm normally.
  962.  
  963. Each "local RIP playback" variable you enter will search for the .RIP
  964. file in the current host's icon directory.  If it cannot find the
  965. file in that directory, it will check the ICONS\ directory.
  966.  
  967. When Local RIPscrip File Playback is chosen, the file is not played
  968. back immediately.  Whatever operation is being processed (like a host
  969. command being sent to the BBS, etc) will be completed.  After the
  970. completion of the command in question, the RIPscrip file is played
  971. back locally.  An internal Queue of files is stored in memory in
  972. RIPterm.  Each time it gets a Local RIP file playback command, it
  973. adds the filename to the queue.  When the current operation is
  974. completed, the queue is flushed by playing back all of the files in
  975. the queue in the order that they were received.
  976.  
  977.  
  978.  
  979. POP-UP PICK LISTS
  980. -----------------
  981. Any place that you can use a Text Variable (Queries, Button and Mouse
  982. Field return strings, and Keystroke Macros), you can take advantage of
  983. a unique feature of RIPscrip - Pop-Up Pick Lists.  A Pop-Up Pick List
  984. is simply a list that pops up allowing you to choose from one of
  985. several available values.  Whichever entry in the list you choose
  986. will insert it's associated command in the Host Command returned back
  987. to your host.
  988.  
  989. A list is created by putting the special list instructions inside two
  990. sets of parenthesis like this: (( and )).  The list consists of an
  991. optional question followed by two colons (::), followed by one or
  992. more list entries.  For example, ((Send Email
  993. to?::Sysop,Cosysop,Joe)) says to pop-up a list asking you "Send Email
  994. to?", giving you the choices of "Sysop", "Cosysop", and "Joe".
  995.  
  996. By default, if you press ESC instead of picking an entry in the list,
  997. then nothing will be inserted into the text of your Command. You can
  998. indicate that the user must pick an entry by putting an asterisk (*)
  999. at the beginning of the question.  For example, ((*Send Mail
  1000. to?::Sysop,Joe)).  This would make it so that the user must choose
  1001. either Sysop or Joe.
  1002.  
  1003. In the previous examples, Sysop and Joe are the text responses that
  1004. are inserted into your Host Command.  These commands are also the
  1005. same things that are displayed in the listing.  If you want to use
  1006. something else in the listing instead of the return text, you can.
  1007. When you make the list entry, add an @description to the end of it.
  1008. For example:
  1009.  
  1010.      ((Send Mail To?::Sysop@Head Honcho,Cosysop,Joe))
  1011.  
  1012. ...would display a pop-up pick list of Head Honcho, Cosysop, and Joe.
  1013.  
  1014. One final feature of Pop-Up Pick Lists allows you to specify a hotkey
  1015. for each entry in the list.  For example, if you wanted the first
  1016. character of each entry to be highlighted (thus allowing you to
  1017. select that character to activate the entry), simply put a tilde (~)
  1018. or an underline (_) before and after the keystroke.  For example
  1019. "_S_ysop" would highlight the "S" in "Sysop" appearing like this:
  1020.  
  1021.                        Sysop
  1022.  
  1023. You can highlight more than one character, but only the first one will
  1024. be the active hotkey.  If you omit the second tilde or underline,
  1025. then the remainder of the description will be highlighted.
  1026.  
  1027. NOTE:  If you use a tilde or an underline in the Text Response (not
  1028.        the description), then those characters are inserted into
  1029.        your Host Command when it is transmitted to the host.  You
  1030.        probably don't want to do this.  Recommendation: only use
  1031.        hotkey features on list entries where you specify a
  1032.        description!
  1033.  
  1034. If you do not specify a question, then the list default to the
  1035. question:
  1036.  
  1037.                Choose one of the following:
  1038.  
  1039. You may specify up to twenty entries for any one list.  In RIPterm 
  1040. version 1.52 and earlier, the total length of a pick list was 256  
  1041. bytes.  In version 1.53 and later, this limit has been increased to
  1042. 1024 bytes.                                                        
  1043.  
  1044. Some characters have special significance in the RIPscrip language.
  1045. These characters are ! (exclamation mark, or for you Unix-heads,
  1046. bang), \ (backslash), and | (vertical bar).  To use these characters
  1047. in a Text Response, they must be preceded by a backslash (! becomes
  1048. \!, \ becomes \\, and | becomes \|).  RIPaint automatically adds
  1049. these when creating Text Responses.  You need to be aware of this
  1050. only if you are editing RIPscrip files with a text editor.  The _
  1051. (underline) and ~ (tilde) characters used to indicate the hotkey in a
  1052. Text Response are not able to be preceded by a backslash to be used
  1053. by themselves.  They will be returned to the host if they exist in a
  1054. Text Response (not in the description), however everything after the
  1055. underline or tilde will be underlined, and the first character will
  1056. be considered the hotkey.
  1057.  
  1058.   Examples:
  1059.  
  1060.      ((Send E-Mail to?::Sysop,Joe,Mike))
  1061.      ((*Send E-Mail to?::Sysop@The Head Honcho,Joe,Mike@My Brother))
  1062.      ((::Sysop@_T_he Head Honcho,Joe,Mike@My _B_rother))
  1063.  
  1064.  
  1065.  
  1066. WHAT CAN GO WHERE?
  1067. ------------------
  1068. With all this talk about Templates, Text Variables, Local RIP file
  1069. playback, pop-up pick lists and control characters, you might be
  1070. interested in knowing what can be used where in the RIPscrip
  1071. language.  It has already been stated that Templates can be used only
  1072. in Button Host Commands.  Text Variables, Local RIP file playback,
  1073. pop-up lists and control characters can be used in several places
  1074. though.  The places that these commands can be used and not used are
  1075. listed in the following chart:
  1076.  
  1077.                     +-----------------------------------+
  1078.                     |  T  | D V |   T |  P  |  C  |  L  |
  1079.                     |  E  | A A | A E |  I  |  T  |  O  |
  1080.                     |  M  | T R | C X |  C  |  R  |  C  |
  1081.                     |  P  | A I | T T |  K  |  L  |  A  |
  1082.                     |  L  |   A | I   |     |     |  L  |
  1083.                     |  A  | T B | V V |  L  |  C  |     |
  1084.                     |  T  | E L | E A |  I  |  H  |  R  |
  1085.                     |  E  | X E |   R |  S  |  A  |  I  |
  1086.                     |  S  | T S |   S |  T  |  R  |  P  |
  1087.                     |-----------------------------------|
  1088.                     |     |     |     |     |     |     |
  1089. Button Host Commands|  Y  |  Y  |  Y  |  Y  |  Y  |  Y  | 
  1090.                     |     |     |     |     |     |     | Host
  1091. Simple Mouse Fields |  N  |  Y  |  Y  |  Y  |  Y  |  Y  | Related
  1092.                     |     |     |     |     |     |     | Commands
  1093. Query Command       |  N  |  Y  |  Y  |  Y  |  Y  |  Y  |
  1094.                     |     |     |     |     |     |     |
  1095.                     |-----------------------------------|
  1096.                     |     |     |     |     |     |     |
  1097. Button Labels       |  N  |  Y  |  N  |  N  |  N  |  N  |
  1098.                     |     |     |     |     |     |     | Text Output
  1099. RIP_TEXT_XY         |  N  |  Y  |  N  |  N  |  N  |  N  | Related
  1100.                     |     |     |     |     |     |     | Commands
  1101. RIP_TEXT            |  N  |  Y  |  N  |  N  |  N  |  N  |
  1102.                     |     |     |     |     |     |     |
  1103.                     +-----------------------------------+
  1104.  
  1105.  
  1106.  
  1107. THINGS TO TAKE SPECIAL CARE WITH
  1108. --------------------------------
  1109. Special care must be taken when executing Host Commands or Query
  1110. commands that contain local RIP file playback or that contain active
  1111. text variables.  Either of these operations could instruct RIPterm to
  1112. destroy all Mouse Fields by either performing a RIP_RESET_WINDOWS
  1113. command ($RESET$), a RIP_KILL_MOUSE_FIELDS command ($MKILL$), a
  1114. restore mouse fields text variable ($RMF$) or other such things.
  1115.  
  1116. If a situation like this happens, care should be taken to preserve
  1117. currently processed Host Buffer.  If it is a mouse field's host
  1118. command that is being processed, you wouldn't want your application
  1119. destroying the very buffer that you're processing before you're done
  1120. processing it, would you?  In the case of RIPterm, we do a sub-string
  1121. search on the Host buffer before any processing is done.  We search
  1122. for the following strings:
  1123.  
  1124.      $RMF$    ... Restore Mouse Fields
  1125.      $>       ... Beginning segment of a Local RIP playback command
  1126.      $APP     ... Instruction to execute an external application
  1127.      $RESET$  ... Performs a RIP_RESET_WINDOWS command
  1128.      $MKILL$  ... Destroys the contents of the internal mouse table
  1129.  
  1130. If any one of the above strings are found, RIPterm will physically
  1131. back-up the Host buffer into another location - one that won't be
  1132. destroyed by the execution of the above commands.  The processing of
  1133. the Host buffer is then done on the new buffer, not the actual
  1134. buffer.  In this way, the application can destroy the mouse table to
  1135. its heart's content but the processing of the buffer will not be
  1136. affected.
  1137.