VERSION 5.00 Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "comdlg32.ocx" Begin VB.Form Form1 Caption = "Form1" ClientHeight = 6570 ClientLeft = 60 ClientTop = 450 ClientWidth = 9270 LinkTopic = "Form1" ScaleHeight = 6570 ScaleWidth = 9270 StartUpPosition = 3 'Windows Default Begin VB.TextBox Text1 Height = 3135 Left = 120 MultiLine = -1 'True TabIndex = 6 Text = "Form1.frx":0000 Top = 2640 Width = 4695 End Begin MSComDlg.CommonDialog CommonDialog1 Left = 120 Top = 5880 _ExtentX = 847 _ExtentY = 847 _Version = 393216 End Begin VB.ListBox List1 Height = 6105 Left = 4920 TabIndex = 5 Top = 120 Width = 4215 End Begin VB.CommandButton goBTN Caption = "GO " Height = 375 Left = 1440 TabIndex = 4 Top = 1800 Width = 1335 End Begin VB.CommandButton FileBTN Caption = "Choose file" Height = 375 Left = 1440 TabIndex = 3 Top = 1200 Width = 1335 End Begin VB.TextBox clockTXT Height = 375 Left = 1800 TabIndex = 1 Text = "1000" Top = 120 Width = 1455 End Begin VB.Label Label2 Caption = "Hz" Height = 255 Left = 3360 TabIndex = 2 Top = 240 Width = 375 End Begin VB.Label Label1 Caption = "Clock Rate" Height = 255 Left = 600 TabIndex = 0 Top = 240 Width = 975 End End Attribute VB_Name = "Form1" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Option Explicit Dim ClockRate As Double Dim fName As String Dim done As Boolean Dim DeviceIndex As Long Private Sub clockTXT_Change() ClockRate = clockTXT.Text End Sub Private Sub FileBTN_Click() CommonDialog1.ShowOpen If CommonDialog1.FileName <> "" Then fName = CommonDialog1.FileName goBTN.Enabled = True List1.AddItem fName End If End Sub Private Sub Form_Load() Dim Dlg As New DetectForm Dlg.Show (vbModal) DeviceIndex = Dlg.DeviceIndex End Sub Private Sub Form_Unload(Cancel As Integer) done = True List1.AddItem "Exiting, this may take a few moments..." End Sub Private Function getNumDacs(line As String) As Integer Dim numFound As Boolean Dim Count As Integer Dim howMany As Integer Dim finished As Boolean Dim currentChar As String Count = 1 howMany = 0 numFound = False Do currentChar = Mid$(line, Count, 1) Count = Count + 1 If (currentChar = ",") And (numFound = False) Then finished = True ElseIf IsNumeric(currentChar) = True Then If numFound = False Then howMany = howMany + 1 numFound = True End If ElseIf currentChar = "," Then numFound = False End If Loop Until (finished = True) Or (howMany = 8) getNumDacs = howMany End Function Private Sub goBTN_Click() Dim numDacs, oldDacs As Long Dim currentLine As String Dim Count As Integer Dim FrameData(0 To 8191) As Integer Dim FramePoints As Long Dim index As Integer Dim currentVal As Integer Dim loopfile As Boolean Dim status As Long Dim clock As Double Dim bytePos As Long done = False index = 0 FramePoints = 0 clock = clockTXT.Text oldDacs = 8 DACOutputOpen DeviceIndex, clock DACOutputSetCount DeviceIndex, oldDacs Open fName For Input As #1 Do If EOF(1) = True Then Seek #1, 1 End If bytePos = Seek(1) Line Input #1, currentLine numDacs = getNumDacs(currentLine) Seek #1, bytePos For Count = 0 To 7 Input #1, FrameData(Count + index) Next Count If numDacs = oldDacs Then FramePoints = FramePoints + 1 index = index + numDacs If (index + numDacs > 8191) Then DACOutputSetCount DeviceIndex, numDacs Do status = DACOutputFrame(DeviceIndex, FramePoints, FrameData(0)) Loop Until status <> 21 index = 0 FramePoints = 0 End If Else DACOutputSetCount DeviceIndex, oldDacs Do status = DACOutputFrame(DeviceIndex, FramePoints, FrameData(0)) Loop Until status <> 21 For Count = 0 To numDacs FrameData(Count) = FrameData(Count + index) Next Count index = numDacs FramePoints = 1 oldDacs = numDacs End If DoEvents Loop Until done = True DACOutputClose DeviceIndex, False End Sub