Announcement

Collapse
No announcement yet.

DIR$ and Prompt mask

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

  • Giuseppe Belziti
    replied
    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!

    Leave a comment:


  • Giuseppe Belziti
    replied
    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?

    Leave a comment:


  • Cliff Nichols
    replied
    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)

    Leave a comment:


  • Knuth Konrad
    replied
    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.

    Leave a comment:


  • Michael Mattias
    replied
    > 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.

    Leave a comment:


  • Giuseppe Belziti
    replied
    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!

    Leave a comment:


  • Michael Mattias
    replied
    Too bad using ERRCLEAR that way means you can't report WHAT the error was, huh?

    Leave a comment:


  • Michael Mattias
    replied
    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

    Leave a comment:


  • StanHelton
    replied
    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

    Leave a comment:


  • Michael Mattias
    replied
    >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"

    Leave a comment:


  • Giuseppe Belziti
    replied
    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

    Leave a comment:


  • Giuseppe Belziti
    replied
    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]

    Leave a comment:


  • Michael Mattias
    replied
    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

    Leave a comment:


  • Eric Pearson
    replied
    > I have used DIR$ hundreds of times and have never seen that behaviour.

    Likewise.

    Leave a comment:


  • Kev Peel
    replied
    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$

    Leave a comment:


  • Chris Holbrook
    replied
    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

    Leave a comment:


  • Giuseppe Belziti
    started a topic DIR$ and Prompt mask

    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
Working...
X