Loading a File
Posted: Sun Nov 17, 2024 4:38 pm
Solved another task. The below example will write the contents of a text box to a file then send load a job, ready for a cycle start to be hit. More error protection is needed but the basic function works well.
Code: Select all
Private Sub btnSendMDI_Click(sender As Object, e As EventArgs) Handles btnSendMDI.Click
Dim folderPath As String = "C:/cncm"
Dim filePath As String = System.IO.Path.Combine(folderPath, "MDI.txt")
System.IO.File.WriteAllText(filePath, txtMDI.Text)
SendJob(filePath)
End Sub
Code: Select all
Function SendJob(WhatFile As String)
' check that pipe is initialized
If CNCPipeManager.Pipe IsNot Nothing Then
If CNCPipeManager.Pipe.IsConstructed Then
Dim cmd As New CentroidAPI.CNCPipe.Job(CNCPipeManager.Pipe)
Return cmd.Load(WhatFile, "C:/cncm")
End If
End If
' if we failed, send back an unknown error
Return CentroidAPI.CNCPipe.ReturnCode.ERROR_UNKNOWN
End Function