home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / desenvel.zip / LetterPrompts (.txt) < prev    next >
DeScribe Document  |  1994-12-28  |  47KB  |  383 lines

  1. DeScribe  Copyright DeScribe, Inc., 1988, 1989
  2. Info 1
  3. Info 2
  4. Info 3
  5. Info 4
  6. Macro
  7. Courier
  8. !   This macro constructs a multi-field dialog by looking through
  9. !   a document for fields of the form <<Field name>>
  10. var descrip
  11. var field
  12. var field1
  13. var field2
  14. var field3
  15. var field4
  16. var field5
  17. var field6
  18. var static
  19. var static1
  20. var s
  21. tatic2
  22. var s
  23. tatic3
  24. var s
  25. tatic4
  26. var static5
  27. var static6
  28. var varNum
  29. var savedFrame
  30. var savedPos
  31. var nextPos
  32. var beginPos
  33. var endPos
  34. var replaced
  35. var found
  36. var done
  37. var selected
  38. var duplicate
  39. var justLooking
  40. procedure CompareStatics
  41.     if varNum > 1 then
  42.         if static = static1 then
  43.             set duplicate to TRUE
  44.             return
  45.         end if
  46.     end if
  47.     if varNum > 2 then
  48.         if static = static2 then
  49.             set duplicate to TRUE
  50.             return
  51.         end if
  52.     end if
  53.     if varNum > 3 then
  54.         if static = static3 then
  55.             set duplicate to TRUE
  56.             return
  57.         end if
  58.     end if
  59.     if varNum > 4 then
  60.         if static = static4 then
  61.             set duplicate to TRUE
  62.             return
  63.         end if
  64.     end if
  65.     if varNum > 5 then
  66.         if static = static5 then
  67.             set duplicate to TRUE
  68.             return
  69.         end if
  70.     end if
  71. end procedure
  72. procedure CheckDuplicate
  73.     set duplicate to FALSE
  74.     call CompareStatics
  75. end procedure
  76. procedure SetPrompt
  77.     call CheckDuplicate
  78.     if duplicate then
  79.         return
  80.     end if
  81.     if varNum = 1 then 
  82.         set static1 to static
  83.         MSET static tostring field1
  84.         return
  85.     end if
  86.     if v
  87. arNum = 2 then
  88.         set static2 to static
  89.         MSET static tostring field2
  90.         return
  91.     end if
  92.     if v
  93. arNum = 3 then
  94.         set static3 to static
  95.         MSET static tostring field3
  96.         return
  97.     end if
  98.     if v
  99. arNum = 4 then
  100.         set static4 to static
  101.         MSET static tostring field4
  102.         return
  103.     end if
  104.     if v
  105. arNum = 5 then
  106.         set static5 to static
  107.         MSET static tostring field5
  108.         return
  109.     end if
  110.     if varNum = 6 then
  111.         set static6 to static
  112.         MSET static tostring field6
  113.         return
  114.     end if
  115. end procedure
  116. procedure GetField
  117.     if replaced = 1 then
  118.         set field to field1
  119.         set static to static1
  120.         return
  121.     end if
  122.     if replaced = 2 then
  123.         set field to field2
  124.         set static to static2
  125.         return
  126.     end if
  127.     if replaced = 3 then
  128.         set field to field3
  129.         set static to static3
  130.         return
  131.     end if
  132.     if replaced = 4 then
  133.         set field to field4
  134.         set static to static4
  135.         return
  136.     end if
  137.     if replaced = 5 then
  138.         set field to field5
  139.         set static to static5
  140.         return
  141.     end if
  142.     if replaced = 6 then
  143.         set field to field6
  144.         set static to static6
  145.         return
  146.     end if
  147. end procedure
  148. procedure SetStatic
  149.     set FirstDefinedPosition to beginPos
  150.     set LastDefinedPosition to endPos
  151.     CopyToClipboard
  152.     set static to PastedClipboard
  153. end procedure
  154. procedure doReplace
  155.     Call GetField
  156.     if field = 
  157.  then
  158.          return
  159.     end if
  160.     set static to 
  161.  + static
  162.     set static to static + 
  163.     SearchClear
  164.     SET SearchSearch1 to static
  165.     if field = 
  166.  then
  167.         SET SearchDeleteOnFound1 to TRUE
  168.     else
  169.         SET SearchReplace1 to field
  170.     end if
  171.     SET SearchConfirm1 to FALSE
  172.     SearchForward
  173.     if field = 
  174.  then
  175.     end if
  176. end procedure
  177. procedure removeOpenEvent
  178.     set DocEventOpenMacro to 
  179. end procedure
  180. procedure FindField
  181.     set found to FALSE
  182.     set done to FALSE
  183.     set CursorPosition to nextPos
  184.     SearchForward
  185.     if not DefinedBlock then
  186.         set done to TRUE
  187.         return
  188.     end if
  189.     CancelDefinedBlock
  190.     if CursorCharacter = 
  191.  then
  192.         CursorRight
  193.         if CursorCharacter = 
  194.  then
  195.             set beginPos to CursorPosition + 1
  196.             SearchForward
  197.             if not DefinedBlock then
  198.                 set done to TRUE
  199.                 return
  200.             end if
  201.             CancelDefinedBlock
  202.             if CursorCharacter = 
  203.  then
  204.                 CursorRight
  205.                 if CursorCharacter = 
  206.  then
  207.                     set nextPos to CursorPosition + 1
  208.                     set endPos to CursorPosition - 2
  209.                     set selected to endPos - beginPos
  210.                     if selected < 256 then
  211.                         set found to TRUE
  212.                         if not justLooking then
  213.                             Call SetStatic
  214.                         end if
  215.                         return
  216.                     end if
  217.                 end if
  218.             end if
  219.         end if
  220.     end if
  221.     set nextPos to CursorPosition + 1
  222. end procedure
  223. procedure SearchFrames
  224.     SearchClear
  225.     set SearchSearch1 to "<<"
  226.     set SearchSearch2 to ">>"
  227.     set savedFrame to SelectedFrame
  228.     repeat
  229.         NextFrame
  230.         if not IsFrameTypePicture then
  231.             set savedPos to CursorPosition
  232.             CursorHome
  233.             set nextPos to CursorPosition
  234.             repeat
  235.                 call FindField
  236.                 exit when done
  237.                 if found then
  238.                     if not justLooking then
  239.                         Call SetPrompt
  240.                     end if
  241.                     if not duplicate then
  242.                         set v
  243. arNum to v
  244. arNum + 1
  245.                         if justLooking then
  246.                             return
  247.                         end if
  248.                     end if
  249.                     if varNum > 7 then
  250.                         msg 
  251. More than 6 fields in document. Field Prompter could not substitute all fields.
  252.                         exit
  253.                     end if
  254.                 end if
  255.             end repeat
  256.             Set CursorPosition to savedPos
  257.         end if
  258.         exit when savedFrame = SelectedFrame
  259.     end repeat
  260. end procedure
  261. Procedure EnvelopCreate
  262.     NewDocumentFile "G:\DeScribe\Layouts\Sobre - Paz"
  263.     SET SelectedFrame TO "Address"
  264.     SET CursorPosition TO 0    
  265.     set varNum to 1
  266.     set justLooking to FALSE
  267.     Call SearchFrames
  268.     if varNum = 1 then
  269.         set SelectedFrame to savedFrame
  270.         set CursorPosition to savedPos
  271.         quit
  272.     end if
  273.     set SelectedFrame to savedFrame
  274.     set replaced to 1
  275.     set savedFrame to SelectedFrame
  276.     repeat
  277.         NextFrame             
  278.                 if not IsFrameTypePicture then
  279.             set replaced to 1
  280.             repeat
  281.                 Call doReplace
  282.                 set replaced to replaced + 1
  283.                 exit when replaced = varNum
  284.             end repeat
  285.             Set CursorPosition to savedPos
  286.         end if
  287.         exit when savedFrame = SelectedFrame
  288.     end repeat
  289.     set varNum to 1
  290.     set justLooking to TRUE
  291.     Call SearchFrames
  292.     if varNum = 1 then
  293.         Call removeOpenEvent
  294.     end if
  295.     set SelectedFrame to savedFrame
  296.     set CursorPosition to savedPos
  297. end procedure
  298.                       
  299. Procedure GetDescriptn
  300.     set MacroDialogTitle to 
  301. Field Prompter
  302.     set descrip to 
  303. Fill in the prompts to replace text in brackets. 
  304.     set descrip to descrip + 
  305. Type an asterisk 
  306.  to leave the corresponding text and brackets unchanged. 
  307.     set descrip to descrip + 
  308. Blank fields will be deleted. Press Cancel to leave document as is.
  309.     mget descrip
  310. end procedure
  311. MACRO FieldPrompt
  312.     set varNum to 1
  313.     set justLooking to FALSE
  314.     Call SearchFrames
  315.     if varNum = 1 then
  316.         set SelectedFrame to savedFrame
  317.         set CursorPosition to savedPos
  318.         quit
  319.     end if
  320.     set SelectedFrame to savedFrame
  321. !    set MacroDialogTitle to 
  322. Field Prompter
  323. !    set descrip to 
  324. Fill in the prompts to replace text in brackets. 
  325. !    set descrip to descrip + 
  326. Type an asterisk 
  327.  to leave the c
  328. ng text and brackets unchanged. 
  329. !    set descrip to descrip + 
  330. Blank fields will be deleted. Press Cancel to leave document as is.
  331. !    mget descrip
  332.      Call GetDescriptn     
  333.     set replaced to 1
  334.     set savedFrame to SelectedFrame
  335.     repeat
  336.         NextFrame
  337.         if not IsFrameTypePicture then
  338.             set replaced to 1
  339.             CursorHome
  340.             repeat
  341.                 Call doReplace
  342.                 set replaced to replaced + 1
  343.                 exit when replaced = varNum
  344.             end repeat
  345.             Set CursorPosition to savedPos
  346.         end if
  347.         exit when savedFrame = SelectedFrame
  348.     end repeat
  349.     set v
  350. arNum to 1
  351.     set justLooking to TRUE
  352.     Call SearchFrames
  353.     if varNum = 1 then
  354.         Call removeOpenEvent
  355.     end if
  356.     set SelectedFrame to savedFrame
  357.     set CursorPosition to savedPos
  358. Call EnvelopCreate
  359. END MACRO
  360. DeScribe Glossary
  361. Create date
  362. Create time
  363. Document name
  364. File name
  365. Pages
  366. Pages (Alphabetic lower case)
  367. Pages (Alphabetic upper case)
  368. Pages (Roman lower case)
  369. Pages (Roman upper case)
  370. Print date
  371. Print time
  372. Revisions
  373. Save date
  374. Save time
  375. 4 August 1994
  376. 12:50 P.M.
  377. LetterPrompts
  378. G:\DeScribe\Macros\LetterPrompts
  379. 28 December 1994
  380. 4:39 P.M.
  381. 28 December 1994
  382. 5:42 P.M.
  383.