Type Text vs Type Attributed Text
Posted: 2017-01-13 18:56:11
Greetings.
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."
Exit
End
$map = Hash.new
$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 = Range.new(0, $len)
$sel.transliterateInRange($range, $map)
Type Attributed Text $sel[/code]
Cliff
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."
Exit
End
$map = Hash.new
$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 = Range.new(0, $len)
$sel.transliterateInRange($range, $map)
Type Attributed Text $sel[/code]
Cliff