Results 1 to 4 of 4

Thread: Open & read redirected output from DOS app

  1. #1

    Thread Starter
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Show you're code you're using and i'll have a look at it
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  2. #2
    Member
    Join Date
    Jun 2000
    Posts
    45
    kedaman, here's the code, such as it is. thanks for looking at it.

    Don Goyette
    [email protected]

    ---------------------------------------------
    Private stCraftDir As String

    Private Sub ActiveBar21_ToolClick(ByVal Tool As ActiveBar2LibraryCtl.Tool)

    If Len(stCraftDir) = 0 Then
    'stCraftDir = CurDir()
    stCraftDir = "C:\craft"
    End If

    Select Case Tool.Name

    Case "miCraftware": craft
    Case "miCalLoad": CalLoad
    Case "miCheckFiles": CheckFiles
    Case "miCaPrint": CaPrint

    Case "miExit": End

    End Select

    End Sub

    Private Sub craft() 'run campaign craftware
    Dim RetVal
    Form1.Show
    RetVal = Shell(stCraftDir + "\craft3.exe", 1)
    End Sub
    Private Sub CalLoad() 'run CalLoad (upload to sec'y of state)
    Dim RetVal
    RetVal = Shell(stCraftDir + "\cal\CALoad.exe", 1)
    End Sub
    Private Sub CaPrint() 'print upload file
    Dim RetVal
    RetVal = Shell(stCraftDir + "\cal\CaPrint.exe", 1)

    End Sub
    Private Sub CheckFiles()
    Dim TaskID, RetVal As String

    CommonDialog1.ShowOpen

    pid = Shell(stCraftDir + "\cal\Caervw.exe " + CommonDialog1.FileName + _
    " >" + stCraftDir + "\el\validtext.txt", 4)

    RetVal = TextSrch(stCraftDir + "\el\validtext.txt", "return code:")

    iretval = Val(Mid(RetVal, 13))
    If iretval < 2 Then
    intMsgBox = MsgBox("Passed OK: " + RetVal, vbCritical, "Verify")
    Else
    intMsgBox = MsgBox("Failed: " + RetVal, vbCritical, "Verify")
    End If
    End Sub

    Private Function TextSrch(stFilename, stSrchStr) As String

    ' searches stFilename for line containing stSrchStr string and returns it
    Dim stLine As String
    lensrchstr = Len(stSrchStr)

    'kedaman: this is where it fails as there is no
    'file named stCraftDir + "\el\validtext.txt" (stCraftDir)

    Open stFilename For Input As #1
    Do While Not EOF(1)
    Line Input #1, stLine
    lenline = Len(stLine)
    For ichar = 1 To lenline - lensrchstr + 1

    If Mid(stLine, ichar, lensrchstr) = stSrchStr Then
    TextSrch = Mid(stLine, ichar)

    Exit For
    End If
    Exit Do
    Next 'For ichar = 1 To lenline - lensrchstr + 1
    Loop 'Do While Not EOF(1)

    End Function

  3. #3

    Thread Starter
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    I don't have ActiveBar2LibraryCtl or cal\Caervw.exe so i can't test it out but it's possible that you can't execute a file and return the output in a file, i haven't done that so i can't tell you
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  4. #4
    New Member
    Join Date
    Jun 2000
    Posts
    3
    Just 'shelling' out won't allow you to redirect output to a file, this is your problem.

    In a DOS window this would work:
    dir *.* >dir.txt

    You would end up with a dir.txt containing a text listing of the directory.

    Doing the same in VB using 'shell' will NOT work

    You need to add 'command.com'

    You have to change it to:

    Shell ("c:\command.com /c dir c:\*.* >c:\dir.txt")

    This would now work from within VB



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width