Announcement

Collapse

New Sub-Forum

In an effort to help make sure there are appropriate categories for topics of discussion that are happening, there is now a sub-forum for databases and database programming under Special Interest groups. Please direct questions, etc., about this topic to that sub-forum moving forward. Thank you.
See more
See less

OPEN statement and shortcut files.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • OPEN statement and shortcut files.

    PB/win 8.04 won't open a shortcut file for input, output, or append. For example, if I use NotePad to create a file named "input.txt" in directory1, and use Windows Explorer (in Windows XP Professional) to create a shortcut to that file and move it to directory2 (which also contains my PB/win 8.04 program), then my program will not access the shortcut file.
    My program has the following line:
    OPEN "input.txt" FOR INPUT AS filenum
    while my program's directory contains a shortcut to input.txt. The program will not open the shortcut file. This is also true when using APPEND in the OPEN statement.
    When trying to output, with the original file in another directory and a shortcut to that file in the directory containing the program, the program creates another output file distinct from the shortcut but with the same name. For example, the directory will now contains output.txt and a shortcut to output.txt, which are actually different files with different contents.

  • #2
    I know there is code here to find the target of a shortcut. Try a search on 'shortcut' in message subject.

    IIRC, you have to test that the file extension is ".lnk" first to make this work.
    Michael Mattias
    Tal Systems Inc. (retired)
    Racine WI USA
    [email protected]
    http://www.talsystems.com

    Comment


    • #3
      Full example code to resolve a shortcut...

      http://www.powerbasic.com/support/pb...light=dragdrop

      I just tested this code on Windows Vista and it works fine.
      kgpsoftware.com | Slam DBMS | PrpT Control | Other Downloads | Contact Me

      Comment


      • #4
        The shortcuts file name is not input.txt. Shortcuts have the extention of .lnk and windows simply shows the filename that this shortcut links to. That is why trying to open the file does not work and why the routine Kev points to does.
        Barry

        Comment


        • #5
          Therefore, it is the programmer's responsibility to test for a link file and follow it to the destination. The operating system (ie. Windows XP) and PB/win 8.04 will not perform this task automatically, as a function of the operating system or the programming language. Thank you for your guidance in this topic.
          Last edited by John Harvill; 29 Oct 2007, 10:31 PM.

          Comment


          • #6
            The operating system (ie. Windows XP) and PB/win 8.04 will not perform this task [resolve shortcuts ] automatically..
            When you think about it a bit, you realize neither the compiler nor the operating system SHOULD do this: How could you EVER then maintain a shortcut file, e.g., when your program offers to create a desktop shortcut for a user?


            MCM
            Michael Mattias
            Tal Systems Inc. (retired)
            Racine WI USA
            [email protected]
            http://www.talsystems.com

            Comment


            • #7
              I'm using shortcuts to manage data. I place a file containing data in one directory and provide a shortcut to it in another directory. This helps me organize different subject matters which use the same data. I pull all my data together into one location using links so that I won't be distracted looking for files throughout my directory structure, then I start concentrating (reading and analyzing) a particular subject.

              I don't want to copy my data because it might get updated, which renders the other copies obsolete, and would require me to track all the different copies of the data (wherever they may be) and ensure they are up to date. Linking to the same data file is an efficient method of ensuring that all directories are looking at the same data. If the data changes in one directory, I'll see the same change when accessing the data in the other directories containing the shortcut.

              I guess this really doesn't need to be accomplished with a shortcut; perhaps it could be accomplished with some other style of link, but shortcuts are convenient in Windows Explorer -- Just right click on a file and select "Create Shortcut" and move the shortcut to another directory.

              Comment


              • #8
                I guess this really doesn't need to be accomplished with a shortcut; perhaps it could be accomplished with some other style of link.
                Not that will work directly from Windows' [file] Explorer.

                But I do find your use of a directory full of shortcuts an innovative and very clean approach.

                I probably would have written an application to maintain an indexed database of "User folder name" (key) and "real folder name" (data), then used ShellExecute "open" to call Explorer to explore the target folders.

                "shortcut" is a lot cleaner if all you'll want to do is 'explore.' If you want to start comparing timestamps or contents of directories or files, you'll likely need to write that application.

                MCM
                Michael Mattias
                Tal Systems Inc. (retired)
                Racine WI USA
                [email protected]
                http://www.talsystems.com

                Comment

                Working...
                X