I'm new here, also I am new with C# and UCCNC... I have some Mach3 and VB scripting experience but this is another story.
I am trying to make a macro which have to read the Evar variable and use it in some other functions.
I made a form, I can initially read the Evar value but finally this variable is lost.
I think is something related with public/private variables but it seems is too "early" for me to figure out how to solve this.
So, the macro is the next one:
I want it to work like this:
Entering MDI: M20000 E125
Windows popup appear (and ask for some other info, not implemented for now)
And finally do G0 X125 (Evar's value)
- Code: Select all
exec.AddStatusmessage("Evar = " + Evar);
if (Evar != null)
{
AS3.Setfield (Convert.ToInt32(Evar),21111);
AS3.Validatefield(21111);
}
Button button1 = new Button();
button1.Size = new System.Drawing.Size(110, 47);
button1.Location = new System.Drawing.Point(28, 149);
button1.Text = "Press me";
button1.Click += new EventHandler(button1_Click);
Label label1 = new Label();
label1.Size = new System.Drawing.Size(57, 22);
label1.Location = new System.Drawing.Point(56, 93);
label1.AutoSize = true;
label1.Font = new System.Drawing.Font("Trebuchet MS", 12F, ((System.Drawing.FontStyle)((System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Italic))), System.Drawing.GraphicsUnit.Point, ((byte)(0)));
label1.Text = Convert.ToString(Evar);
MyForm = new Form();
MyForm.Size = new System.Drawing.Size(630, 300); // Enter width & height of Form
MyForm.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
MyForm.Controls.Add(button1); // Add Button1
MyForm.Controls.Add(label1); // Add label1
MyForm.ShowDialog();
MyFunction();
#Events
Form MyForm; //This is a global variable, a Windows Form
void button1_Click(object sender, EventArgs e)
{
MessageBox.Show("Evar " + Evar); // CS0103 | in line: 57 | error text: The name 'Evar' does not exist in the current context
MyForm.Close();
}
void MyFunction()
{
exec.Code("G0 X" + Evar); // CS0103 | in line: 57 | error text: The name 'Evar' does not exist in the current context
}
It seems the Evar is "lost" after #Events and lines like "MessageBox.Show("Evar " + Evar);" or "exec.Code("G0 X" + Evar); ", are generating the CS0103 error.
How can I make this working?
Thank you very much,
Seb