Reply to topic  [ 3 posts ] 
Type Text vs Type Attributed Text 
Author Message

Joined: 2007-03-28 07:30:34
Posts: 139

The macro reference states:
Type Text text
Replaces the currently selected text with the text provided. The inserted text uses the attributes that were applied to the selected text.

Type Attributed Text text
....The inserted text will have the attributes that are applied to the argument in the macro itself.

However, using the Type Text statement in the following macro (abbreviated, which converts 2-byte Japanese characters to 1-byte equivalents), all attributes are removed from the text -- so red text goes black and superscript/subscript attributes are stripped.

Using the Type Attributed Text statement retains the attributes in the original text. But, there are no attributes "applied to the argument in the macro itself."

If the documentation isn't wrong, why isn't Type Text the correct command?

[code]$sel = $doc.selectedSubtext
$len = $sel.length
If $len < 1
Prompt "Select some text first."

$map =
$map{'A'} = 'A'
$map{'B'} = 'B'
$map{'C'} = 'C'
$map{'0'} = '0'
$map{'1'} = '1'
$map{'2'} = '2'
$map{'3'} = '3'
$map{'4'} = '4'

$range =, $len)
$sel.transliterateInRange($range, $map)
Type Attributed Text $sel[/code]


2017-01-13 18:56:11
User avatar

Joined: 2007-02-07 00:58:12
Posts: 876
Location: Japan
Hello Cliff,
I don't know that the "documentation isn't wrong". But what you are seeing is the difference between using a variable and a literal. If you use Type Attributed Text with a literal, it will apply the attributes that are applied to the literal in the macro. However if you are using a variable the command applies the attributes that are applied to the text held in the variable.

And as a side note: You are aware that you could just transliterate the selection in place, without needing to copy it into a variable and then typing the variable back into the document? The command would look like this:
$sel = $doc.textSelection
$sel.text.transliterateInRange($sel.range, $map)

This approach will, as a matter of course, keep the attributes in the document. It won't keep the selection. If you want the selection to get specific attributes, you could re-select it, and then apply the wanted attributes with menu commands. For example
$sel = $doc.textSelection
$sel.text.transliterateInRange($sel.range, $map)
$doc.setSelection $sel
Text Color:Red


2017-01-14 04:36:58

Joined: 2007-03-28 07:30:34
Posts: 139
Hello, Philip.

Thank you for your help.

I was not aware that

$sel.text.transliterateInRange($sel.range, $map)

was valid, and have changed my macro. In the process, (prompted by .textSelection) I learned I was using a deprecated command.

And I have been re-reading the lang ref in the process about literals and interpolated variables.

Thanks again.

2017-01-14 23:04:33
Display posts from previous:  Sort by  
Reply to topic   [ 3 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group
Designed by ST Software