Results 1 to 8 of 8

Thread: VBasic help

  1. #1
    Your very own Pikachu! Banned Peegee's Avatar
    Join Date
    Mar 2001
    Posts
    19,488
    Blog Entries
    81

    Grin VBasic help

    I'm trying to use VBasic to make a simple gui for a command line program. The program takes a single parameter -- a filename (complete with directory and so forth). So the idea is eventually I'll run the command

    Code:
        Shell ("mplayer.exe """ + File + """")
    Where File is the entire file path.

    So I have my file window, my directory window, my drive window, a window showing the "File" variable. But a snag.

    File = Directory + filename right? What happens when I encounter two distnction different directories:

    C:\

    and

    C:\Dir1

    ?

    I can't put Directory + "\" + filename because it would lead to C:\\filename, and I can't put Directory + filename because it would lead to c:\directoryfilename

    I actually did this, but I was fiddling with the code and somehow undid my work. My original solution didn't need if's, so I think a very simple solution isn't presenting itself to me :p

    Edit: oh, on a completely unrelated note, what is the difference in meaning if you swap the terms in "x no y" in japanese? For example what does "kawaii no chibi" mean as opposed to "chibi no kawaii"?

  2. #2
    Ominous Wanderer Tech Admin Samuraid's Avatar
    Join Date
    Oct 2001
    Posts
    5,522

    Default

    Use right() to check to see if the rightmost char of the directory path is a "\". If there is no backslash, then append one and then add + File on the end, and there you have it.

  3. #3
    Hypnotising you crono_logical's Avatar
    Join Date
    May 2001
    Location
    Back in Time
    Posts
    9,313
    Contributions
    • Former Administrator
    • Former Cid's Knight

    Default

    Doesn't the particular API you're using in VB provide something that will let you check if the given string is an existing path/file and if so, exactly which it is? Or you could use that strategy yourself to work it out from the string, although it will be slightly more complex and/or slower than just analysing the string and assuming that it exists on the file system.

    Edit: neko no shippo - the cat's tail, or the tail of the cat. shippo no neko - the tail's cat, or the cat of the tail. Probably not the best example, but you can see the effect of reversing the words is like reversing the words around an of or 's in English
    Problems playing downloaded videos? Try CCCP


  4. #4
    ORANGE Dr Unne's Avatar
    Join Date
    Dec 1999
    Posts
    7,394
    Articles
    1
    Contributions
    • Former Administrator
    • Former Developer
    • Former Tech Admin

    Default

    In Linux, /home/chester and /home//////chester are the same. Isn't it the same in Windoze?

    The short answer of course is just use Perl, since parsing text is what Perl was designed for in the first place.

  5. #5
    Your very own Pikachu! Banned Peegee's Avatar
    Join Date
    Mar 2001
    Posts
    19,488
    Blog Entries
    81

    Grin

    You guys are so silly xD

    Samuraid, your advice helped to ensure the success of PG's 'first' application (as opposed to the stuff I did in class seven or eight years ago, which I don't count as applications, but more of an assignment). The thing was, when I used the right(string, stringlength as string) function, I didn't know what to do with the stringlength. So I just plugged 2 in there (c:\ = string of 0 1 2 chars I reasoned), and it didn't work. So I put a textbox to see what right (string, 2) was, and it was ":\" (!!)

    So I just adjusted the if statement to look for ":\" and all was super! Yay

  6. #6
    ORANGE Dr Unne's Avatar
    Join Date
    Dec 1999
    Posts
    7,394
    Articles
    1
    Contributions
    • Former Administrator
    • Former Developer
    • Former Tech Admin

    Default

    This is an example of something which someone else somewhere in the world already wrote, tested, debugged, and left lying around on the internet. Re-using other people's source code is a good thing, in almost every case. So long as the source code is good quality.

    "Reinventing the wheel", you've probably heard that term before; a lot of programmers reinvent the wheel on a nearly hourly basis. Your code only handles one specific kind of path, which is an artificial and fairly severe limitation. If you found a standard library for parsing filenames, you could handle any sort of path you want. Perl, for example, has File::Basename, which can handle filenames from Unix, Windows, AIX, VMS, and AmigaOS.

    Another good thing about code reuse is that you don't have to care about that code. If there's a bug in the filename parsing code, it's not your problem. You're doing fileparse($my_filename), and that's it. You update your File::Basename module (or whatever) and your one line of code still works without having to change anything at all.

  7. #7
    Ominous Wanderer Tech Admin Samuraid's Avatar
    Join Date
    Oct 2001
    Posts
    5,522

    Default

    Quote Originally Posted by ShlupMoo
    You guys are so silly xD

    Samuraid, your advice helped to ensure the success of PG's 'first' application (as opposed to the stuff I did in class seven or eight years ago, which I don't count as applications, but more of an assignment). The thing was, when I used the right(string, stringlength as string) function, I didn't know what to do with the stringlength. So I just plugged 2 in there (c:\ = string of 0 1 2 chars I reasoned), and it didn't work. So I put a textbox to see what right (string, 2) was, and it was ":\" (!!)

    So I just adjusted the if statement to look for ":\" and all was super! Yay
    Cool. Actually I was suggesting:

    If Right(pathstring, 1) <> "\" Then
    pathstring = pathstring & "\"
    End If

    But it's good you got it figured out anyway.

  8. #8
    Your very own Pikachu! Banned Peegee's Avatar
    Join Date
    Mar 2001
    Posts
    19,488
    Blog Entries
    81

    Grin

    Quote Originally Posted by Dr Unne
    This is an example of something which someone else somewhere in the world already wrote, tested, debugged, and left lying around on the internet. Re-using other people's source code is a good thing, in almost every case. So long as the source code is good quality.

    "Reinventing the wheel", you've probably heard that term before; a lot of programmers reinvent the wheel on a nearly hourly basis. Your code only handles one specific kind of path, which is an artificial and fairly severe limitation. If you found a standard library for parsing filenames, you could handle any sort of path you want. Perl, for example, has File::Basename, which can handle filenames from Unix, Windows, AIX, VMS, and AmigaOS.

    Another good thing about code reuse is that you don't have to care about that code. If there's a bug in the filename parsing code, it's not your problem. You're doing fileparse($my_filename), and that's it. You update your File::Basename module (or whatever) and your one line of code still works without having to change anything at all.
    Agreed, but this isn't a case where I have the time to learn Perl. I just wanted a haphazardly created (quite literally...you should see the actual program) program. And you know what? You can drag and drop media files on the mplayer executable anyway, thus making my program completely pointless and excessive. :p

    But I didn't know that to begin with, so etiher way even if I were to use Perl I would be making an excessive program :D

    Quote Originally Posted by Samuraid
    Cool. Actually I was suggesting:

    If Right(pathstring, 1) <> "\" Then
    pathstring = pathstring & "\"
    End If

    But it's good you got it figured out anyway.
    See the thing was that I didn't know what the number parameter did. Now I do. :D

Posting Permissions

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