为什么我的HMI在进入程序中的foreach循环时重新启动?C#
每次运行program时都会显示错误,并且没有为数组设置任何值。知道为什么吗?我在iXDeveloper上编写程序并将其导出到X2 pro 7 HMI 请向我们展示例外情况。感谢您的回复并愿意提供帮助,但问题已经解决。您能否将解决方案发布在此处作为答案?将来可能会帮助其他遇到同样问题的人!为什么我的HMI在进入程序中的foreach循环时重新启动?C#,c#,C#,每次运行program时都会显示错误,并且没有为数组设置任何值。知道为什么吗?我在iXDeveloper上编写程序并将其导出到X2 pro 7 HMI 请向我们展示例外情况。感谢您的回复并愿意提供帮助,但问题已经解决。您能否将解决方案发布在此处作为答案?将来可能会帮助其他遇到同样问题的人! void Button3_Click(System.Object sender, System.EventArgs e) { try {
void Button3_Click(System.Object sender, System.EventArgs e)
{
try
{
string path = (@"Hard Disk\POINTS.txt");
StreamReader sr = new StreamReader(path);
int k = 0;
string[] chartlines = sr.ReadToEnd().Split(new char[]{'\n'});
foreach(string file in chartlines)
{
string Chart = chartlines[k];
string xchart = Chart.Split(';')[0];
string ychart = Chart.Split(';')[1];
int xval = Int32.Parse(xchart);
int yval = Int32.Parse(ychart);
Globals.Tags.X_ARRAY[k].Value = xval;
Globals.Tags.Y_ARRAY[k].Value = yval;
k++;
}
Globals.Tags.CHECK.Value = Globals.Tags.X_ARRAY[15].Value;
//check values on screen
Globals.Tags.CHECK1.Value = Globals.Tags.Y_ARRAY[15].Value;
}
catch
{
MessageBox.Show("Error"):
}
}