Difference between revisions of "Studio:How do I access an array in the parameter list through Perl?"
Line 17: | Line 17: | ||
<source lang="perl"> | <source lang="perl"> | ||
my @a = (11, 12, 13, 14, 15, 16, 17, 18, 19, 20); | my @a = (11, 12, 13, 14, 15, 16, 17, 18, 19, 20); | ||
− | $user->ParameterList->a | + | $user->ParameterList->a->{SafeArray} = \@a; |
$user->Call(); | $user->Call(); | ||
</source> | </source> | ||
[[Category:Perl Info]] | [[Category:Perl Info]] |
Revision as of 23:53, 7 October 2008
By using a simple interface such as:
void test1(char s[10]);
#pragma scl_function(test1)
The following Perl script example illustrates how to access an array in the parameter list. The following example sets element 0 of s to 15.
my $test = $ascript->Functions->Item("test1")->User;
my $data = $test->ParameterList;
$data->SetProperty("s", 0, 15);
$test->Call();
Another option is to use safearray to directly copy a Perl array into an array of the parameter list. Here is an example:
my @a = (11, 12, 13, 14, 15, 16, 17, 18, 19, 20);
$user->ParameterList->a->{SafeArray} = \@a;
$user->Call();