0

Can anyone suggest me how to passing class program to another class file? My code: (main form)

private SpelNetLib.Spel m_spel;
Robot robot = new Robot();
private void Prototype_Load(object sender, EventArgs e)
    {
        m_spel = new SpelNetLib.Spel();
        m_spel.Initialize();
        m_spel.Project = "c:\\EPSONRC50\\projects\\TimCS\\TimCS.sprj";
        m_spel.MotorsOn = true;
        m_spel.PowerHigh = true;
        m_spel.Speed(100);
    }
 private void startBt_ButtonClick(object sender, EventArgs e)
    {
       SpelPoint pt = new SpelPoint();
        pt = m_spel.GetPoint("P*");
        pt.X = (float)125.5;   
        robot.goTOPT(pos,10,5,5);
        }

Robot Class

class Robot
public void goToPt(SpelPoint point,int x,int y,int z)
{
 point.X=point.X+x;
 m_spel.Go(point); // Want to use this function direct from class
}
}

Hope someone could help? Thank you.

Pound19
  • 7
  • 2

1 Answers1

0

You do this by passing it in as a parameter:

private SpelNetLib.Spel m_spel;
Robot robot = new Robot();

private void startBt_ButtonClick(object sender, EventArgs e)
{
    SpelPoint pt = new SpelPoint();
    pt = m_spel.GetPoint("P*");
    pt.X = (float)125.5;   
    robot.goTOPT(m_spel, pos,10,5,5);
}

Robot Class

class Robot
{
    public void goToPt(SpelNetLib.Spel m_spel, SpelPoint point,int x,int y,int z)
    {
        point.X=point.X+x;
        m_spel.Go(point); 
    }
}
David Arno
  • 42,717
  • 16
  • 86
  • 131