CNC DLL Application Script

'

  CNC_DLL.DLL function declarations

Declare Function dir_pp CDecl Lib "cnc_dll" Alias "dir_pp" (ByVal node_no As Long, ByVal path_no As Integer, ByRef prog() As Long, ByVal max_files As Integer) As Integer

Sub OnScreenOpen()

Dim i As Integer

Dim node As Long

Dim path As Integer

Dim progs(1023) As Long

Dim maxfiles As Integer

Dim idx As Integer

Dim pp(1023) As CimObjectVariable

Dim cnc_error As CimObjectVariable

Dim cnc_node As CimObjectVariable

Dim cnc_path As CimObjectVariable

Set pp(0)  = CimGetRootObject().GetVariable("pp0")

Set pp(1)  = CimGetRootObject().GetVariable("pp1")

Set pp(2)  = CimGetRootObject().GetVariable("pp2")

Set pp(3)  = CimGetRootObject().GetVariable("pp3")

Set pp(4)  = CimGetRootObject().GetVariable("pp4")

Set pp(5)  = CimGetRootObject().GetVariable("pp5")

Set pp(6)  = CimGetRootObject().GetVariable("pp6")

Set pp(7)  = CimGetRootObject().GetVariable("pp7")

Set pp(8)  = CimGetRootObject().GetVariable("pp8")

Set pp(9)  = CimGetRootObject().GetVariable("pp9")

Set pp(10) = CimGetRootObject().GetVariable("pp10")

Set pp(11) = CimGetRootObject().GetVariable("pp11")

Set pp(12) = CimGetRootObject().GetVariable("pp12")

Set pp(13) = CimGetRootObject().GetVariable("pp13")

Set pp(14) = CimGetRootObject().GetVariable("pp14")

Set pp(15) = CimGetRootObject().GetVariable("pp15")

Set cnc_error = CimGetRootObject().GetVariable("cnc_error")

Set cnc_node = CimGetRootObject().GetVariable("cnc_node")

Set cnc_path = CimGetRootObject().GetVariable("cnc_path")

' Initial arguments

node = 0

cnc_node = node

path = 1

cnc_path = path

maxfiles = 1024

' Get short directory (no comments or sizes)

i = dir_pp ( node, path, progs, maxfiles )

If i <> 0 Then

     ' Log error to Status Log

     LogStatus CIM_FAILURE,"dir_pp","Unable to get directory information from CNC.",i,0

     ' Initialize all part program screen variable to make them invisible

     For idx = 0 To 15

         pp(idx) = 0

     Next idx

     ' Set screen variable to display error

     cnc_error = """Unable to get directory info from CNC"""

     Exit Sub

End If

' Loop thru all part programs returned and set screen variables

Do While (progs(idx) <> 0)

     pp(idx) = progs(idx)

     dx = idx + 1

Loop

End Sub

Sub OnTimer()

Dim i As Integer

Dim node As Long

Dim path As Integer

Dim progs(1023) As Long

Dim maxfiles As Integer

Dim idx As Integer

Dim pp(1023) As CimObjectVariable

Dim cnc_error As CimObjectVariable

Dim cnc_node As CimObjectVariable

Dim cnc_path As CimObjectVariable

Set pp(0)  = CimGetRootObject().GetVariable("pp0")

Set pp(1)  = CimGetRootObject().GetVariable("pp1")

Set pp(2)  = CimGetRootObject().GetVariable("pp2")

Set pp(3)  = CimGetRootObject().GetVariable("pp3")

Set pp(4)  = CimGetRootObject().GetVariable("pp4")

Set pp(5)  = CimGetRootObject().GetVariable("pp5")

Set pp(6)  = CimGetRootObject().GetVariable("pp6")

Set pp(7)  = CimGetRootObject().GetVariable("pp7")

Set pp(8)  = CimGetRootObject().GetVariable("pp8")

Set pp(9)  = CimGetRootObject().GetVariable("pp9")

Set pp(10) = CimGetRootObject().GetVariable("pp10")

Set pp(11) = CimGetRootObject().GetVariable("pp11")

Set pp(12) = CimGetRootObject().GetVariable("pp12")

Set pp(13) = CimGetRootObject().GetVariable("pp13")

Set pp(14) = CimGetRootObject().GetVariable("pp14")

Set pp(15) = CimGetRootObject().GetVariable("pp15")

Set cnc_error = CimGetRootObject().GetVariable("cnc_error")

Set cnc_node = CimGetRootObject().GetVariable("cnc_node")

Set cnc_path = CimGetRootObject().GetVariable("cnc_path")

' Initial arguments

node = cnc_node

path = cnc_path

maxfiles = 1024

' Get short directory (no comments or sizes)

i = dir_pp ( node, path, progs, maxfiles )

If i <> 0 Then

     ' Initialize all part program screen variable to make them invisible

     For idx = 0 To 15

         pp(idx) = 0

     Next idx

     ' Set screen variable to display error

     cnc_error = """Unable to get directory info from CNC"""

     xit Sub

End If

' Loop thru all part programs returned and set screen variables

Do While (progs(idx) <> 0)

     pp(idx) = progs(idx)

     idx = idx + 1

Loop

End Sub

Sub OnF2KeyDown(key As Integer)

Dim cnc_node As CimObjectVariable

Set cnc_node = CimGetRootObject().GetVariable("cnc_node")

If ((cnc_node + 1) < 8) Then

     nc_node = cnc_node + 1

Else

     cnc_node = 0

End If 

End Sub

Sub OnF3KeyDown(key As Integer)

Dim cnc_path As CimObjectVariable

Set cnc_path = CimGetRootObject().GetVariable("cnc_path")

If ((cnc_path + 1) < 3) Then

     cnc_path = cnc_path + 1

Else

     cnc_path = 1

End If 

End Sub

More information

CNC DLL sample application script and screens