• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 143
  • Last Modified:

Command Line Options

I have a problem. On my spalsh screen I test if there is a determined file using this code:

    ' Check command options
    If Command <> "" Then
        If Chr(34) <> Left(Command, 1) Then
            FileName = Command
        Else
            lencommand% = Len(Command) - 2
            FileName$ = Mid(Command, 2, lencommand%)
        End If
    Else
    End If
   
    ' check file
    On Error GoTo nofile:
    Dim strTemp As String * 1
    Dim i As Integer
    i = 0
    Open "file.txt" For Input As 1#
    Do Until EOF(1)
    i% = i% + 1
    Line Input #1, strTemp
    Loop
    Close #1
    If i% <> 70 Or FileLen("file.txt") <> 6368 Then
nofile:
    MsgBox "No file"
    End
    Else
    End If

This works fine if there is no command line. When I drag a file to the aplication icon it causes an error opening the file that I want to check. Is there anything I can do? I don't understand why. It's supposed to open and check file.txt wherever the aplication is. (this file will be there as well)

Thank you
0
igfp
Asked:
igfp
1 Solution
 
GERTJANCommented:
On wich line is the error occuring and what is the specific error description?

When the error is that the program can not locate the path then you can try

Open App.Path & "\file.txt" For Input As 1#

Gertjan
0
 
igfpAuthor Commented:
that's it!!! Apparently once there is a command line input it confunds everything (no idea why) but telling the program to open on App.Path corrects the problem! Excellent!
Thank you!
0

Featured Post

[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now