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 [/i][/i]
Handling array from scripting
-
- Posts: 137
- Joined: Mon Jun 11, 2012 2:10 pm
Re: Handling array from scripting
Hi fsturlese,
You need to access Tag1's value by index. Try the following
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
Controls Engineer
FlexEnergy
Re: Handling array from scripting
Thanks Adam