Announcement

Collapse
No announcement yet.

DIR$ and Prompt mask

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

  • DIR$ and Prompt mask

    When I use this routine for to verify if a folder exist:

    Code:
    ESIST$=DIR$("PCL",16)
    the inconvenient is that the Prompt of MsDos appear for a little instant, and it's very tedious. How to avoid that the Prompt appear?
    Thanks
    mailto:[email protected]
    From Italy.

  • #2
    This might help, though I have not used it in the context you describe:

    Code:
    '----------------------------------------------------------------------------------
    'Check to see whether a file or directory exists. Found on the PB forums.
    FUNCTION IsDir(sObj AS STRING) AS DWORD
    '   If not a 2, then not a dir at least not one you can use.
    '   CASE 1: STDOUT "File"
    '   CASE 2: STDOUT "Dir"
    '   CASE 53: STDOUT "No such file/directory"
    '   CASE 70: STDOUT "Permission denied"
    '   CASE 75: STDOUT "No such volume"
    #REGISTER NONE
        LOCAL dwAttr AS DWORD, lErr AS DWORD
    
        ERRCLEAR
        dwAttr = GETATTR(sObj)
        lErr = ERR
        ! mov eax, lErr ;Error
        ! Or eax, eax
        ! jne Done
        ! mov eax, dwAttr
        ! And eax, 16
        ! jz File
    Dir:
        ! mov eax, 2 ;dir
        ! jmp Done
    File:
        ! mov eax, 1 ;file
    Done:
        ! mov Function, eax
    END FUNCTION

    Comment


    • #3
      I have used DIR$ hundreds of times and have never seen that behaviour. There is no reason why a console would be displayed.

      It sounds like you have a virus/adware or some program hooking the FindFirstFile API. I would do a virus scan or check add/remove programs for anything suspicious.

      Unless you mean you have a DOS/PBCC program that calls DIR$
      kgpsoftware.com | Slam DBMS | PrpT Control | Other Downloads | Contact Me

      Comment


      • #4
        > I have used DIR$ hundreds of times and have never seen that behaviour.

        Likewise.
        "Not my circus, not my monkeys."

        Comment


        • #5
          Code:
          ' LATEST FUNCTION 8/26/03 THIS ONE WORKS
          FUNCTION IsValidFolder (szPath AS ASCIIZ) AS LONG
          
            LOCAL  FA AS LONG
          
            FA         = GetFileAttributes(szPath)
            'MSGBOX "FA=" & HEX$(FA,8) & $CRLF & szPath
            IF FA = -1& THEN
                FUNCTION = 0
            ELSE
               FUNCTION = (FA AND %FILE_ATTRIBUTE_DIRECTORY) = %FILE_ATTRIBUTE_DIRECTORY
            END IF
          
          END FUNCTION
          Michael Mattias
          Tal Systems (retired)
          Port Washington WI USA
          [email protected]
          http://www.talsystems.com

          Comment


          • #6
            Excuse me, you be right.
            I have notice that is te following row that give the problem, but why this problem appear when then folder PCL exist already?
            When this folder exist, it don't should dysplay the Prompt.

            Code:
            ESIST$=DIR$("PCL",16)
            [B]IF ESIST$<>"PCL" THEN SHELL"CMD /C MD PCL"[/B]
            mailto:[email protected]
            From Italy.

            Comment


            • #7
              OK all resolved.

              Code:
              ESIST$=DIR$("PCL",16)
              IF ESIST$<>"PCL" THEN PID???=SHELL("CMD /C MD PCL",0)
              I put 0 and the prompt don't appear.

              Thanks to all
              mailto:[email protected]
              From Italy.

              Comment


              • #8
                >IF EXIST$<>"PCL" THEN PID???=SHELL("CMD /C MD PCL",0)

                Help file, MKDIR:
                MKDIR (make directory) creates the subdirectory specified by path$. If you try to create a directory that already exists, a run-time Error 75 occurs ("Path/file access error"). If path$ includes an parent folder that does not exist, a run-time Error 76 occurs ("Path not found").

                Code:
                    ERRCLEAR
                    MKDIR       "PCL"
                    IF ERR = 75 THEN 
                       "I don't care if MKDIR failed because it already exists"
                   ELSEIF ERR <> 0 THEN
                      " I **do** care that MKDIR failed"
                   END IF
                MCM
                PS: Also no annoying "command-shell flash"
                Michael Mattias
                Tal Systems (retired)
                Port Washington WI USA
                [email protected]
                http://www.talsystems.com

                Comment


                • #9
                  Originally posted by Michael Mattias View Post
                  Code:
                      ERRCLEAR
                      MKDIR       "PCL"
                      IF ERR = 75 THEN 
                         "I don't care if MKDIR failed because it already exists"
                     ELSEIF ERR <> 0 THEN
                        " I **do** care that MKDIR failed"
                     END IF
                  MCM

                  Mr. Mattias, I like that snippet, but how about this?

                  Code:
                  ERRCLEAR
                  MKDIR "PCL"
                  IF ERR = 75 THEN
                     "I don't care either."
                  ELSEIF ERRCLEAR <> 0 THEN
                     "I care AND I've cleared the error for the next mistake."
                  END IF
                  Stan
                  Last edited by StanHelton; 13 May 2008, 10:15 AM. Reason: correct a spelling error
                  Do not go quiet into that good night,
                  ... Rage, rage against the dark.

                  Comment


                  • #10
                    I continue to be amazed at the number of posts we see here where someone is using a SHELL to CMD.EXE or a *.BAT file to do something you can do in less than ten lines of 'native' PowerBASIC code.

                    MS-DOS must have had a powerful ability to cast a spell.

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

                    Comment


                    • #11
                      Too bad using ERRCLEAR that way means you can't report WHAT the error was, huh?
                      Michael Mattias
                      Tal Systems (retired)
                      Port Washington WI USA
                      [email protected]
                      http://www.talsystems.com

                      Comment


                      • #12
                        Originally posted by Michael Mattias View Post
                        I continue to be amazed at the number of posts we see here where someone is using a SHELL to CMD.EXE or a *.BAT file to do something you can do in less than ten lines of 'native' PowerBASIC code.

                        MS-DOS must have had a powerful ability to cast a spell.

                        MCM
                        We are borned with MsDos, and our istinct is to return at MsDos!
                        mailto:[email protected]
                        From Italy.

                        Comment


                        • #13
                          > We are borned with MsDos, and our istinct is to return at MsDos

                          Um, "MKDIR" and "ERR" have been included in every MS-DOS BASIC I've ever seen.
                          Michael Mattias
                          Tal Systems (retired)
                          Port Washington WI USA
                          [email protected]
                          http://www.talsystems.com

                          Comment


                          • #14
                            Originally posted by Michael Mattias View Post
                            Too bad using ERRCLEAR that way means you can't report WHAT the error was, huh?
                            That's the reason why TRY/END TRY is especially useful for such situations. From the help file

                            Because of the nesting requirements, the ERR value is local to the TRY structure. Upon exit, the prior ERR value is restored, so be sure to save the value of ERR if it will be needed outside of the TRY structure.
                            Code:
                            TRY
                               MKDIR "PCL"
                            CATCH
                               SELECT CASE ERR
                               CASE IS <> 75
                                  "Problem here, watch out!"
                               CASE ELSE
                                  "I don't care either."
                               END SELECT
                            END TRY

                            Takes care of the error locally without tampering with the global ERR value.

                            Comment


                            • #15
                              We are borned with MsDos, and our istinct is to return at MsDos!
                              Much like my ole' quote of:
                              "If it Can't be done in Windows....DOS it"
                              Even though supposedly not existing....to this day, show me a batch file, dos prompt, commandline, (properly coded of course) that does not work then as well as today?????

                              (Even Windows IT Mag is constantly showing code for something supposedly "Non-Existing" monthly in their magazine)
                              Engineer's Motto: If it aint broke take it apart and fix it

                              "If at 1st you don't succeed... call it version 1.0"

                              "Half of Programming is coding"....."The other 90% is DEBUGGING"

                              "Document my code????" .... "WHYYY??? do you think they call it CODE? "

                              Comment


                              • #16
                                Originally posted by Michael Mattias View Post
                                > We are borned with MsDos, and our istinct is to return at MsDos

                                Um, "MKDIR" and "ERR" have been included in every MS-DOS BASIC I've ever seen.
                                Gwbasic too?
                                mailto:[email protected]
                                From Italy.

                                Comment


                                • #17
                                  Originally posted by Cliff Nichols View Post

                                  "If it Can't be done in Windows....DOS it"

                                  Much like my ole' quote of:
                                  Even though supposedly not existing....to this day, show me a batch file, dos prompt, commandline, (properly coded of course) that does not work then as well as today?????

                                  (Even Windows IT Mag is constantly showing code for something supposedly "Non-Existing" monthly in their magazine)
                                  Great Cliff!
                                  mailto:[email protected]
                                  From Italy.

                                  Comment

                                  Working...
                                  X