Visual basic source code, Ommands, Esting – Acroprint AcroComm User Manual
Page 58: Ransfer, Acrocomm programming manual
AcroComm Programming Manual
10.7. Visual Basic Source Code
The following is a Visual Basic Source used in the example POLL_CLK.5.3.4.XLS. The
SHELLARG command is used to poll/program the Acroprint terminals. The
DATALOG.DAT is a temporary file used to store previously polled data. The data is then
stored in an Excel spreadsheet. The source code for this example may be copied,
used/altered/modified and included in your own application.
Sub Poll_Clock(Optional Clock_Num)
'******************************
'Calls Acrocomm to poll the clock and copies data from the Datalog.Dat file
'into the Excel sheet. It also calls other procedures for formatting
'and conversions to the final format seen on the sheet
Dim WORKBOOK_NAME As String
Dim TaskID As Single
Dim ID As Variant
WORKBOOK_NAME = ActiveWorkbook.Name
Application.ScreenUpdating = False
'If Validate_Paths() = False Then
'MsgBox "There are invalid path/file names." & Chr(13) & Chr(13) & _
'"They must be corrected before execution can continue.", vbExclamation, "INVALID
PATHS"
'Exit Sub
'End If
Range("a31").Select
Application.DisplayAlerts = False
If IsMissing(Clock_Num) Then Clock_Num = 1
ID = Clock_Num
If Range("Back_Up_Data") = True Then
shellarg = "c:\acrocomm\acrocomm.exe -s#" & ID & " -
ec:\acrocomm\Datalog.dat -a" & Range("Back_Up_Path") & " -r"
Else
shellarg = "c:\acrocomm\acrocomm.exe -s#" & ID & " -
ec:\acrocomm\Datalog.dat -r"
End If
'TaskID = Null
'CTR = 1
TaskID = Shell(shellarg, 1)
'Do While TaskID = Null
'wait_time = DateAdd("s", 1, Time())
'Application.Wait wait_time
'CTR = CTR + 1
'If CTR = 200 Then Exit Do
'Loop
If TaskID = 0 Then Exit Sub 'if TaskID=0 Acrocomm failed somehow
Workbooks.OpenText FileName:="c:\acrocomm\datalog.dat", Origin:=2, _
StartRow:=2, DataType:=xlDelimited, Comma:=True
58