home *** CD-ROM | disk | FTP | other *** search
- /* $Revision Header built automatically *************** (do not edit) ************
- **
- ** © Copyright by Dirk Federlein
- **
- ** File : insert_adrletter.ced
- ** Created on : Monday, 04.04.94 17:50:55
- ** Created by : Dirk Federlein
- ** Current revision : V2.1
- **
- **
- ** Purpose
- ** -------
- **
- ** Inserts an address into an already done letter head.
- **
- ** You may use the following fill-ins, when creating your
- ** letter head template:
- ** - <Date>
- ** - <Salutation>
- ** - <First>
- ** - <Name>
- ** - <Street>
- ** - <ZIP>
- ** - <City>
- ** - <Country>
- **
- ** You may write the part of the desired address anywhere to the
- ** letter head template. It is deleted by the script, before the
- ** parts of the address are inserted!
- **
- ** -------------------------------------------------------------------
- **
- ** rewritten by Kai Stuke @ 2:240/605.3 (22.05.93)
- **
- ** Now you can use every template as often as you want. Kai Stuke
- ** found another way to do multiple replaces (CED Multiple replace
- ** is buggy) which is much better than my solution has been.
- **
- ** Thanks Kai!
- **
- ** -------------------------------------------------------------------
- **
- ** Lookup part taken from:
- **
- ** LookUp.ced Copyright (c) 1989, Peter Cherna
- **
- ** ARexx program for CygnusEd Professional that looks up the word under
- ** the cursor.
- **
- ** Version 1.30: August 20, 1989 Release 1.2: August 29, 1989
- **
- ** -------------------------------------------------------------------
- **
- ** Revision V2.1
- ** --------------
- ** created on Monday, 04.04.94 17:56:43 by Dirk Federlein. LogMessage :
- ** - The replace command of CED did only replace the first
- ** WORD of the string. Fixed.
- **
- ** Revision V2.0
- ** --------------
- ** created on Monday, 04.04.94 17:50:55 by Dirk Federlein. LogMessage :
- ** --- Initial release ---
- **
- *********************************************************************************/
-
- options results
-
- address 'rexx_ced'
-
- tabchar = '09'X
- cr = '0A'X
- quote = '22'X
-
-
- /* Get contents of current line: */
- status 55
- line = result
-
- /* Get tab size: */
- status 8
- tabadjust = result - 1
-
- /* Get cursor x position (relative to beginning of line = 1): */
- status 46
- cur = result + 1
-
- i = index(line,tabchar)
- DO while i > 0 & i <= cur - tabadjust
- cur = cur - tabadjust
- i = index(line,tabchar,i+1)
- END
-
- /* If the current character is non-alphabetic, then start one character
- over to the left. This allows the cursor to be immediately after
- the key word (say on a space or bracket.) */
-
- char = substr(line,cur,1)
- if (~(datatype(char,'A') | char = '_') & cur > 1) then
- cur = cur - 1
-
- /* Find leftmost and rightmost alphabetic character adjacent to current: */
-
- right = cur - 1
- left = cur + 1
- char = 'A'
- DO while (datatype(char,'A') | char = '_') & (left > 0)
- left = left - 1
- if left > 0 then
- char = substr(line,left,1)
- END
- char = 'A'
- DO while (datatype(char,'A') | (char = '_'))
- right = right + 1
- char = substr(line,right,1)
- END
-
- if right-left <= 1 then
- DO
- getstring
- target = result
- if (target = 'RESULT') then
- exit
- END
- else
- DO
- target = substr(line,left+1,right-left-1)
- newtarget = '#?'target'#?'
- END
-
-
- DO
- say 'Searching for address' newtarget '...'
-
- if ~show(ports, DFA) then
- do
- 'okay1' 'You should have DFA running, if you' cr 'want to get an
- address
- from it!' exit 0
- end
-
-
- address 'DFA' "SEARCH" newtarget "IGNORECASE ALL STEM ADR."
-
- if rc=0 then
- do
- /* initalization of replacement strings */
- rep.0.old = "<Salutation>" /* string to search for */
- rep.0.new = adr.address.0 /* what it should be replaced with */
-
- rep.1.old = "<First>"
- rep.1.new = adr.address.1
-
- rep.2.old = "<Name>"
- rep.2.new = adr.address.2
-
- rep.3.old = "<Street>"
- rep.3.new = adr.address.4
-
- rep.4.old = "<ZIP>"
- rep.4.new = adr.address.5
-
- rep.5.old = "<City>"
- rep.5.new = adr.address.6
-
- rep.6.old = "<Country>"
- rep.6.new = adr.address.7
-
- rep.7.old = "<Date>"
- rep.7.new = date('e')
-
- repitems = 7
-
- "Prev WORD"
- "Mark BLOCK"
- "NEXT WORD"
- "CUT BLOCK"
-
- do i=0 to repitems
- "Beg of File"
-
- do until xpos1 = xpos2 & ypos1 = ypos2
- 'status' 44
- xpos1 = result
- 'status' 45
- ypos1 = result
- "Replace" rep.i.old quote||rep.i.new||quote
- 'status' 44
- xpos2 = result
- 'status' 45
- ypos2 = result
- end
- end
- end
- else
- 'okay1' 'Could not find address of' newtarget '! ' END
-
- exit
-