Announcement

Collapse
No announcement yet.

LFN under w2k

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

  • LFN under w2k

    I run PB3.5 Programs using long file names on win9x platforms with good success.
    I use the following statements:
    1. PBLFN Shareware, Version 2, 1998 by Hans Lunsing (LfnChdir, LfnCurDIr$ ... and so on)
    2. alternativ shell DOS$ with DOS$="MKDIR "+Longfilename$" or DOS$="CD "+Longfilename$" ... and so on

    My Problem is that all these statements do not work with windows 2000.
    Only one statement is successfull: shell "C:\winnt\system32\cmd.exe/c "+"DIR > c:\DIRDATA"
    I got this statement from Tom Hanlin. In this case the file DIRDATA contents the long filenames.

    All other DOS statements in analogous manner fail. e.g.: shell "C:\winnt\system32\cmd.exe/c "+"MKDIR "+Longfilename$

    How can I solve the problem ?

    ------------------

  • #2
    pblfn apparently does not work with nt/win2k. i do not recall seeing any specific code posted here to solve the problem, but it must be surmountable.

    if you search this forum for "lfn" then you should find some discussions on this, specifically http://www.powerbasic.com/support/pb...read.php?t=300

    in the mean time, i'll see what i can dig up from my archives, if anything.



    ------------------
    lance
    powerbasic support
    mailto:[email protected][email protected]</a>
    Lance
    mailto:[email protected]

    Comment


    • #3
      BTW, this works for me under Win2K:
      Code:
      shell "C:\winnt\system32\cmd.exe /c MKDIR " + CHR$(34) + "C:\long file name" + CHR$(34)
      As does:
      Code:
      shell "cmd.exe /c MKDIR " + CHR$(34) + "C:\long file name" + CHR$(34)

      ------------------
      Lance
      PowerBASIC Support
      mailto:[email protected][email protected]</A>
      Lance
      mailto:[email protected]

      Comment


      • #4
        I can tell you that the DOS interface to LFN functions works fine under Windows 2000,
        as I've used it myself. If PBLFN doesn't work under Windows 2000, that suggests a bug
        in PBLFN. You might start by making sure you have the latest version. If that fails,
        you might see if you can get in touch with Hans Lunsing.

        Lance's hint, there, is that you need to remember to quote long filenames in case
        they contain spaces; hence, the use of CHR$(34) around the filename.

        ------------------
        Tom Hanlin
        PowerBASIC Staff

        Comment


        • #5
          Greetings --

          What a Revelation (to Me) this is!

          Dos line commands such as md "Programs by Frank", rd FirstAmericaBank, Dir "My Documents" or
          cd "\program files" can be also done in Windows 9x!

          Six yesrs of using Win-9x and it's only NOW that I find this out !!!!!!!!!!!

          And it works with PB-DOS !! Here's some sample program code

          Code:
          $compile memory
          DIM Zern$(15)
          cls
          Color 15
             
          Zern$(1)="C:"
          Zern$(2)=CHR$(34)+"My Documents"+CHR$(34)
          Zern$(3)=CHR$(34)+"Program Files"+CHR$(34)
          Zern$(4)=CHR$(34)+"Pack Up Now"+CHR$(34)
              
          CHDRIVE Zern$(1)
          CHDIR "\"
              
          SHELL "command /c cd\"+ZERN$(2)
          FILES
          Sleep 5
              
          SHELL "command /c cd\"+ZERN$(3)
          FILES
          Sleep 5
              
          SHELL "command /c md\"+ZERN$(4)
          SHELL "command /c cd\"+ZERN$(4)
          Sleep 5
              
          END
          ------------------
          Thanx-A-Lot, Enjoy and God Bless Vespucci-Land,
          Frank -- Please visit My Humble Abode

          [This message has been edited by Frank Ferrell (edited October 17, 2001).]

          Comment


          • #6
            I'm quite sure that the reason why PBLFN does not work on Win2k is very related to
            a topic in another recent thread... about Win2k detection

            When I tested my own LFN library on Win2k, I noticed that all functions failed. Only later
            I found out that it would simply never pass the Windows check... After I had changed it like
            Lance suggested (with ENVIRON$("OS") stuff), all LFN functions worked fine...

            Of course, all this is useless to you if you don't have the source of the unit...

            ------------------
            Sebastian Groeneveld
            mailto:[email protected][email protected]</A>
            Sebastian Groeneveld
            mailto:[email protected][email protected]</A>

            Comment


            • #7
              Frank, in some cases you can actually only write LFN commands
              properly in DOS. Writing a CD/CHDIR program in Windows is worthless,
              because the "default directory" for a Windows program is local to
              that program: the state doesn't stick for later programs.

              Sebastian, the source code is provided with PBLFN. It looks to me
              like you may have hit the nail on the head: the LFN functions are
              disabled if the function LfnSupported3 thinks the OS doesn't support
              them. Unfortunately, this function is based on testing things like
              the OS version, rather than checking the error return from an actual
              LFN function. It doesn't seem to be an effective strategy.

              ------------------
              Tom Hanlin
              PowerBASIC Staff

              Comment


              • #8
                greetings --

                many of you are (or should be) familar with "exist" -- the directory checking feature found in dosunit.bas in the powerbasic example directory.

                i've discovered that exist won't work with win-95 long filenames when using chr$(34) " to enclose them. try the following code and see for yourself.
                Code:
                $compile memory
                
                  $include "pb35.inc"
                  '                  powerbasic auxillary file
                  test$=chr$(34)+"c:\program files\gold rush"+chr$(34)
                
                  if exist(test$) = -1 then     ' folder temp in c: found!
                      beep
                      shell "command /c dir "+test$
                  elseif exist(test$) = 0 then  ' folder temp in c: not found, create directory
                      shell "command /c md "+test$
                  end if
                end
                if you run it the first time it will create the "gold rush" folder.
                run it a second time -- you don't hear a beep and you should see the message "unable to create directory".

                what happens in both cases is that exist is unable to get a value of -1, so only the elseif part is executed each time.

                so, the challenge -- for those who know how to do such things -- would be to come up with a modified version of exist -- say, existlong -- which would succeed where exist as it exists now (wow, what a line!) failed.

                ------------------
                thanx-a-lot, enjoy and god bless vespucci-land,
                frank -- my humble abode -- 4000-and-beyond

                [this message has been edited by frank ferrell (edited october 18, 2001).]

                Comment


                • #9
                  I guess a variation of the LFN DIR$ should do it?

                  One point about your code above - rather than hard-code COMMAND[.COM] into the code, you should use the COMSPEC environment variable to get the name of the command-interpreter.
                  Otherwise, for example, your code may fail on a 4NT or 4DOS system.
                  Code:
                  shell ENVIRON$("COMSPEC") + " /c MD " + Test$

                  ------------------
                  Lance
                  PowerBASIC Support
                  mailto:[email protected][email protected]</A>
                  Lance
                  mailto:[email protected]

                  Comment


                  • #10
                    Filespecs should never be quoted within programs. They're only
                    quoted on the command line, so that the command line parser can tell
                    the difference between a filespec that contains a space and a pair of
                    filespecs with a space between them.

                    ------------------
                    Tom Hanlin
                    PowerBASIC Staff

                    Comment


                    • #11
                      greetings lance --

                      about your suggestion on using environ$ -- message understood. and i offer
                      the following example code as proof of my understanding --
                      Code:
                       $compile memory
                      
                       '   text enclosed within environ$ " must always be upper-case!
                       '   this author apologizes for using the ? mark instead of print
                       cls
                       color 15
                       ?: ? "comspec=";environ$("comspec")
                      
                       ?: ? "copycmd=";environ$("copycmd")
                      
                       ?: ? "dircmd=";environ$("dircmd")
                      
                       ?: ? "temp=";environ$("temp")
                      
                       ?: ?: end

                      ------------------
                      thanx-a-lot, enjoy and god bless vespucci-land,
                      frank -- my humble abode -- 4000-and-beyond

                      [this message has been edited by frank ferrell (edited october 20, 2001).]

                      Comment

                      Working...
                      X