Handling array from scripting

A forum devoted to the discussion of all topics having to do with scripting and other advanced programming using iX Developer.
Post Reply
fsturlese
Posts: 36
Joined: Tue Nov 22, 2011 11:57 am

Handling array from scripting

Post by fsturlese »

Hello, I am trying to initialize an array into my PLC by means of a script using the following code, launched by a button:
public partial class ScriptModule1
{
public void InitTags()
{
int i;
Globals.Tags.Tag2.Value = 10;
for (i=0; i<10; i++)
Globals.Tags.Tag1.Values.Value = i;
}
}
Tag2 gets intialized with 10, nothing happens to the Tag1 array. Any idea on what I am doing wrong?
Project is attached.
Thanks,
Federico
PerfTestServer.zip
(47.09 KiB) Downloaded 598 times
[/i][/i]

AMitchneck
Posts: 137
Joined: Mon Jun 11, 2012 2:10 pm

Re: Handling array from scripting

Post by AMitchneck »

Hi fsturlese,

You need to access Tag1's value by index. Try the following

Code: Select all

public partial class ScriptModule1
{
  public void InitTags()
  {
    int i;
    Globals.Tags.Tag2.Value = 10;
    for (i=0; i<10; i++)
    {
      Globals.Tags.Tag1.Values[i].Value = i;
    }
  }
}
Adam M.
Controls Engineer
FlexEnergy

fsturlese
Posts: 36
Joined: Tue Nov 22, 2011 11:57 am

Re: Handling array from scripting

Post by fsturlese »

Thanks Adam

Post Reply