Normal way of extracting Field 877 (Active Modal) is
- Code: Select all
string Activemodal = AS3.Getfield(877); // Field 877: Activemodal;
string[] WordSeparator = new string[] {"|"};
string[] Modals = Activemodal.Split(WordSeparator, StringSplitOptions.None);
And then
- Code: Select all
Modals[0]; // GROUP 1
Modals[1]; // GROUP 2
Modals[2]; // GROUP 7
Modals[3]; // GROUP 8
Modals[4]; // GROUP 16
Modals[5]; // GROUP 12
Modals[6]; // GROUP 13
Modals[7]; // GROUP 17
Modals[8]; // GROUP 3
Modals[9]; // GROUP 5
Modals[10]; // GROUP 10
you'll see that they are not in order..... and if any other modal groups are added later on the array will extend and change the positions {note this is from the current development version of UCCNC which is 2.108 ..... hence there are 11 fields ....... 2.106 only had 9 (GROUP 8 & 10 were are added .... and they weren't added to the end of the string of field 877 either
alternative.....
exec.Modalcodes which is a double [] (array) and at present contains 18 items
.... the 18 items correspond to the 18 groups within the table of the UCCNC manual.... and they are in order.... group "0" to Group "17"
Arrays start at position 0 in c#
Here is a code snippet that may help you with coding and testing arrays
- Code: Select all
string Activemodal = AS3.Getfield(877); // Field 877: Activemodal;
string[] WordSeparator = new string[] {"|"};
string[] Modals = Activemodal.Split(WordSeparator, StringSplitOptions.None);
string Gcode = "";
// BODY OF FILE
Gcode = (Gcode + Modals.Length + " (Modals length)") + Environment.NewLine;
for (var x = 0; x < Modals.Length; x++)
{
Gcode = (Gcode + Modals[x] + "( Array position " + x + " )") + Environment.NewLine;
}
Gcode = (Gcode + exec.Modalcodes.Length + " (Modals length)") + Environment.NewLine;
for (var x = 0; x < exec.Modalcodes.Length; x++)
{
Gcode = (Gcode + exec.Modalcodes[x] + "( GROUP " + x + " )" ) + Environment.NewLine;
}
// Save file
System.IO.File.WriteAllText(Application.StartupPath + @"/Example_codes/Test.tap" , Gcode );
// Load file
exec.Loadfile(Application.StartupPath + @"/Example_codes/Test.tap");
Happy coding