0

I am using a webacm attached to a CNC machine to provide the user a view of the part to be machined. As they jog around the area I want to allow them to record the X & Y co-ordinates of points of interest.

These points are read from internal system registers called Xmachpos and Ymachpos then written to a CSV file.

When I try to run the macro I get a CS1513 for missing "}" and a CS1022 name space EOF error but cannot see what I am missing.

Any help much appreciated

using System;
using System.IO;
using System.Windows.Forms;

class Program
{
    static void Main(string[] args)
    {
        string filePath = @"C:\dxf.txt";
        int Xpos, Ypos;

        //Check if file exists and create it if not
        if (!File.Exists(filePath))
        {
            File.Create(filePath).Close();
        }

        //Write Xpos and Ypos values to file and prompt user to enter more values
        do
        {
            Xpos = exec.GetXmachpos();
            Ypos = exec.GetYmachpos();
            using (StreamWriter writer = File.AppendText(filePath))
            {
                writer.WriteLine(Xpos.ToString() + "," + Ypos.ToString());
            }
        } while (PromptUser());

        MessageBox.Show("Values written to file. Click OK to exit.");
    }

    static bool PromptUser()
    {
        DialogResult result = MessageBox.Show("Do you want to enter more values?", "Enter Values", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
        return (result == DialogResult.Yes);
    }
}

Also tried the system vendor forum pages but no luck there

  • Can you see which line is giving this error? Have you tried isolating the program into parts, like, simply writing "0" in the text file instead of getting the value from the CNC? – dwpessoa Mar 27 '23 at 17:27
  • I resolved it the easier way; rewrote the procedure in VB and configured the application to use VB macros :) – David Childs Mar 28 '23 at 20:17

0 Answers0