Using "character" in TeX-Edit
Using "character" in TeX-Edit
- Subject: Using "character" in TeX-Edit
- From: TERRY HILL <email@hidden>
- Date: Mon, 21 Nov 2005 08:34:42 -0800 (PST)
Could use some help from a kind soul.
Below is the first half of a AppleScript subroutine -
written 5 or so years ago - that receives some text
w/a beginning & closing tag.
I guess I should say that it did work at one time
under OS 9, but now in OS X, not working so well.
The first part of the routine, initiallized the two
variables, then calculates the "bounding parameters";
e.g. ix1 & ix2.
ix1 seems to work fine & is set to zero. ix2, where
the error is said to be, no longer generates a
numerical value for the last position in the file.
I must admit that back then I was not smart enough to
figure out how to do this, and still don't completely
understand how the script worked (see below), but it
worked in OS 9.
Any help will be most welcome!
Thanks in advance,
Terry
-- This routine formats lists of children in Family
Group reports w correct carriage returns, so that they
will be enumerated correctly in LaTeX.
on formatlists(input, beginningtag, endingtag)
set ix1 to {}
set ix2 to {}
set ix1 to offset of beginningtag in input
-- index of "ending tag", but start searching from
ix1
set ix2 to offset of endingtag in (text from
character ix1 to (count of last character of input))
-- resolving ix2 index to absolute index of input;
i.e. how many characters from index one "beginning
tag"
set ix2 to ix2 + ix1 - 1
-- Collect different string "parts": Begining text,
Name, and closing text.
-- Selects all of text up to first index; i.e.
beginning tag
set StartText to text from character 1 to character
(ix1 + (length of beginningtag)) of input
-- Selects text btwn the tags; e.g. \b tag My Name
\b0
set startchar to (ix1 + (length of beginningtag))
set endchar to (ix2 + (length of endingtag))
-- Selects all oftext following closing index; i.e.
ending tag
set EndText to text from character endchar to
character -1 of input
set TheContent to text from character startchar to
character endchar of input
set FindList2 to {"\\\\" & return & return, return &
return, "**"}
set ReplaceList2 to {"**", " \\\\" & return, return
& return}
repeat with I from 1 to the count of FindList2
set TheContent to change (FindList2's item I) into
(ReplaceList2's item I) in TheContent with whole word
end repeat
-- Assemble parts of string that have been collected
set FinalText to StartText & TheContent & EndText
return FinalText
end formatlists
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden