[OS X TeX] Re: Flashmode-Alpha Trial version

Claus Gerhardt gerhardt at math.uni-heidelberg.de
Thu Jan 6 11:24:26 EST 2005


Using "replaceText" as a name for the variable, was a vary bad choice, 
since this term has a special meaning in tcl, but apparently without 
any bad results.

Claus

On Jan 6, 2005, at 17:05, Claus Gerhardt wrote:

> Joachim's suggestion has to be slightly modified in order to work. The 
> general Applescript syntax should be
>
> set findText to "string1"
> set replaceText to "string2"
>
> tell application "AlphaX"
> 	DoScript "eval replaceText " & "[search -r 0  " & findText & " " & 
> "[minPos]]" & " " & "{" & replaceText & "}"
> end tell
>
>
> However, if string2 is supposed to be empty, then it must be specified 
> as
> set replaceText to "{}"
>
> and if string1 is embraced like "{sync}", then it has to be specified 
> as
>
> set findText to "{string1}"
>
> Thus, the optimal syntax is
>
> set findText to "{string1}"
> set replaceText to "{string2}"
>
> tell application "AlphaX"
> 	DoScript "eval replaceText " & "[search -r 0  " & findText & " " & 
> "[minPos]]" & " " & "{" & replaceText & "}"
> end tell
>
> where string1 is the literal string you are looking for and string2 
> can be empty.
>
> Claus
>
>
>
>
>
> On Jan 6, 2005, at 12:26, Joachim Kock wrote:
>
>>> Knowing another tcl command would be helpful. It doesn't affect
>>> Flashmode itself but one the accompanying scripts: finding and 
>>> removing
>>> a string in the front window, in short writing
>>>
>>> find "string"
>>> replace by ""
>>
>> Assuming that the string is a literal string (not a regexp), the 
>> AlphaTcl
>> command would be
>>
>>     eval replaceText [search -r 0 -- $findPat [minPos]] {""}
>>
>> where $findPat is the string you want to delete.
>>
>> (The -r 0 flag means literal string, not regexp.  (The command minPos
>> returns the numerical value of the start position of the document.  
>> This is
>> always 0 in AlphaX, but it is 1.0 in AlphaTk, because it uses the Tk 
>> text
>> rendering engine.  By using minPos instead of 0, you make sure the 
>> script
>> will work cross platform.)  If no match is found an error is raised.  
>> The
>> -- means 'end of options' for search, and is only needed if the 
>> $findPat
>> starts with a hyphen.  I know that -- means something else in 
>> AppleScript
>> so if there is any trouble with that, and if you know that the search
>> string does not start with - then you can omit --.  (The eval command 
>> has
>> the effect of 'unpacking' the list returned by search into two 
>> arguments,
>> as required by replaceText, and the empty string "" is protected by 
>> {} in
>> order not to be evaluated.))
>>
>> Cheers,
>> Joachim.
>>
>>
>> ------------------------------------------------------------
>> Få din egen @start.no-adresse gratis på http://www.start.no/
>>
>
>
> --------------------- Info ---------------------
> Mac-TeX Website: http://www.esm.psu.edu/mac-tex/
>           & FAQ: http://latex.yauh.de/faq/
> TeX FAQ: http://www.tex.ac.uk/faq
> List Post: <mailto:MacOSX-TeX at email.esm.psu.edu>
>
>

--------------------- Info ---------------------
Mac-TeX Website: http://www.esm.psu.edu/mac-tex/
           & FAQ: http://latex.yauh.de/faq/
TeX FAQ: http://www.tex.ac.uk/faq
List Post: <mailto:MacOSX-TeX at email.esm.psu.edu>





More information about the MacOSX-TeX mailing list