Hello,
To help, if anyone is looking, here is the same code to look up the (0-based) number of a column :
using System;
using System.Text;
using System.Windows.Forms;
public class VAInline
{
public void main()
{
string input = VA.GetText("~textFile");
if (input == null)
{
VA.WriteToLog("Error: \"~textFile\" has not been set", "red");
return;
}
string target = VA.GetText("~target");
if (input == null)
{
VA.WriteToLog("Error: \"~target\" has not been set", "red");
return;
}
string[] lines = input.Split(new[] {Environment.NewLine}, StringSplitOptions.RemoveEmptyEntries);
string[] sections = lines[0].Split(',');
for (int targetSection = 0 ; targetSection <= sections.Length ; targetSection++)
{
//VA.WriteToLog("Loop stage : " + targetSection , "orange");
string targetColumn = sections[targetSection];
bool test = targetColumn.Contains(target);
//VA.WriteToLog("test result : " + test , "blue");
if (test == true)
{
VA.WriteToLog("The searched column number (columnID) = " + targetSection , "black");
VA.SetInt("columnID", targetSection );
return;
}
}
}
}