Embedded Perl macro and list variables
Posted: 2008-12-20 06:45:14
Hello,
I have a question about the embedded Perl scripts:
We read in the Macro Reference: "Scalar variables (integers, strings, etc) that have been defined by your macro are automatically made available to the Perl code. Array and hash variables are also available." But how can we have access to array or hash variables in the embedded Perl script? I have two array variables, containing one an array of ranges, and the other an array of attributes, that I get using this code:
I would like to process these arrays in an embedded Perl script, if possible like this:
But the two array variables are in fact not simple arrays of scalar values... Anyway, it seems that this code doesn't work.
I would appreciate any insight. Thank you in advance.
I have a question about the embedded Perl scripts:
We read in the Macro Reference: "Scalar variables (integers, strings, etc) that have been defined by your macro are automatically made available to the Perl code. Array and hash variables are also available." But how can we have access to array or hash variables in the embedded Perl script? I have two array variables, containing one an array of ranges, and the other an array of attributes, that I get using this code:
Code: Select all
$charIndex = 0
$limit = $text.length
$ranges = Array.new
$attributes_array = Array.new
# inspect the attributes applied to every character in the text
While $charIndex < $limit
$range = $text.rangeOfDisplayAttributesAtIndex($charIndex)
$ranges.push ($range)
$attributes = $text.displayAttributesAtIndex($charIndex)
$attributes_array.push ($attributes)
# move to the next area that has different attributes
$charIndex = $range.bound
End
Code: Select all
Begin Perl
@ranges = $ranges; # the Nisus variable "$ranges"
@attributes_array = $attributes_array; # the Nisus variable "$attributes_array"
for (@ranges) {
....;
}
for (@attributes_array) {
....;
}
....
End
I would appreciate any insight. Thank you in advance.