Difference between revisions of "Studio:How do I access an array in the parameter list through Perl?"

From STRIDE Wiki
Jump to: navigation, search
Line 8: Line 8:
 
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.
 
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.
 
<source lang="perl">
 
<source lang="perl">
  my $test = $ascript->Functions->Item("test1")->User;
+
my $test = $ascript->Functions->Item("test1")->User;
  my $data = $test->ParameterList;
+
my $data = $test->ParameterList;
  $data->SetProperty("s", 0, 15);
+
$data->SetProperty("s", 0, 15);
  $test->Call();
+
$test->Call();
 
</source>
 
</source>
  
 
Another option is to use safearray to directly copy a Perl array into an array of the parameter list. Here is an example:
 
Another option is to use safearray to directly copy a Perl array into an array of the parameter list. Here is an example:
 
<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->seq_num->{SafeArray} = \@a;
+
$user->ParameterList->a->seq_num->{SafeArray} = \@a;
$user->Call();  
+
$user->Call();  
 
</source>
 
</source>
  
 
[[Category:Perl Info]]
 
[[Category:Perl Info]]

Revision as of 23:36, 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->seq_num->{SafeArray} = \@a;
$user->Call();