You are not logged in. You can browse in the PowerBASIC Community, but you must click Login (top right) before you can post. If this is your first visit, check out the FAQ or Sign Up.
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
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$
' 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
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]
>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
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.
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.
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!
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.
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? "
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)
We process personal data about users of our site, through the use of cookies and other technologies, to deliver our services, and to analyze site activity. For additional details, refer to our Privacy Policy.
By clicking "I AGREE" below, you agree to our Privacy Policy and our personal data processing and cookie practices as described therein. You also acknowledge that this forum may be hosted outside your country and you consent to the collection, storage, and processing of your data in the country where this forum is hosted.
Comment