How to check for an existing subdirectory or not? (AREV Specific)
At 20 APR 1998 07:08:38PM Michael Slack wrote:
Does anyone know of a way to check for the existance or non-existande of a DOS sub-directory?
I'm using AREV 3.12. I'm writing a report program that will send the output to a DOS file. The user will be required to enter in the complete DOS pathing. What I want and need to do is to be able to check that the path they entered is pre-existing. If no such path exists then I can have the user try typing it in again. Until they get it correct or quit out of the program.
I know I can get the path from the user and then display it back to them with the question "Is this correct?". This is a last resort for me. Since we have users that run the entire spectrum, I would like this program to be as robust as possible. If I can put in a little extra time to get it right now then things will run better in the long run. Plus I'm making the assumption that this should be fairly easy to do (yes, I do know how to spell "ASS of U and ME").
I've done some testing with INITDIR, DIR() and DIRLIST. I haven't been able to find a process that works 100% releiably. I've got some positive results if the target sub-directory has some files in it. I'm unable to figure out a way to check on a sub-directory that exists but is empty. I haven't even tried to test on a non-existant sub-directory.
I did find a web page by Steve Smith (I beleive) that has some very interesting utilities. I found one that was very promising by the name of "SUBDIR". It worked great until I gave it a path with a sub-directory that didn't exist. Then is broke to the debugger. So I can't use that.
Any suggestions would be welcomed.
Thank You,
Michael Slack
At 21 APR 1998 03:50AM Egbert Poell wrote:
I will translate the one we are using since a few years form Dutch to English and mail it to you.
Please send me your email adress on Mecomp@xs4all.nl
Egbert Poell
Mecomp Automatisering
At 21 APR 1998 04:29AM Andrew P McAuley wrote:
REVMEDIA had an article on this yonks back (November 89). Here's a copy of the article from the FKB
amcauley@sprezzatura.com
World Leaders in all things RevSoft
Issue 4 considered the routines available for querying the DOS environment. This month's investigates the routines available for interfacing to DOS and DOS file structures. Whilst some of these routines are documented we will consider how their use may be extended. It is worth pointing out that this article is NOT exhaustive, there are other routines that can be used to interface to DOS - these will be covered at a later date.
OSOPEN
Internal statement. Used to open a DOS file for direct access. If an attempt is made to open a DOS file that does not exist, an error code of 4 will be returned in STATUS(). If an attempt is made to open a DOS subdirectory, an error code of 2 will be returned in STATUS(). Thus to see if a DOS directory exists, OSOPEN it and check the status. If the status is 2, the directory exists, if 2 a file exists with that name.
OPEN
Internal statement. The normal OPEN command can be used to access the various DOS special devices. Thus the printer could be addressed directly by
OPEN "PRN" TO PRN.FILE THENWRITE STRING TO PRN.FILEENDSETPTR
External subroutine (C or Assembler). Used by PDISK to redirect printer output to file. Passed Filename and Flag, returns Flag indicating status or requested operation. Filename must be appended with a CHAR(0) (this tends to imply a 'C' routine as 'C' uses CHAR(0) as an end of string marker). Flag should be set on entry to 1 for overwrite existing file or 0 for no overwrite.
FILENAME=C:\AREV\PRN.DAT"FILENAME := CHAR(0)FLAG=1CALL SETPTR(FILENAME,FLAG)The exit conditions are, unfortunately not just 0 or 1! They appear not to conform to the standard OSOPEN error conditions, but those of which I am aware are
2 Invalid Path3 No such path5 Access denied20 File exists21 Redirected OKIMPORT.READ
External subroutine. Used to read records sequentially from a DOS file. With this routine, if the filename and dos delimiters/record length are known, the developer can sequentially access records in a DOS file without access to OSBREAD! The calling syntax is
CALL IMPORT.READ(A,B,C,D,E,F,G)where
A is the DOS file var (OSOPENED)B is the offset within the fileC is the record delimiterD is the End of File markerE is the record lengthF is the record returnedG is a flag indicating OK (1) or EOF (2).Thus to process all records in TEST.DAT which is a CRLF delimited ASCII file with Ctrl-Z as EOF we would
OSOPEN "TEST.DAT" TO A ELSE STOPB=0 ; * offset, auto-incrementedC=CHAR(13) : CHAR(10)D=CHAR(26)E="F=" ; G="LOOPUNTIL G=2 DOCALL IMPORT.READ(A,B,C,D,E,F,G)PRINT FREPEATINP
Used to query a port address directly. As this is so hardware specific it
can be dangerous to use as it is not portable.
OUT
Used to output to a port address directly. As this is so hardware specific it can be dangerous to use as it is not specific.
FILE.SIZE
A function passed one parameter, the name of the Revelation file that is being sized. The routine returns the size of the DOS file indicating the overflow frames. Using this in conjunction with the DISKSIZE function allows the programmer to see whether there is enough space on disk for a file before attempting to move it, eg
DECLARE FUNCTION FILE.SIZE,DISKSIZEDECLARE SUBROUTINE MSGSPACE.NEEDED=FILE.SIZE("BP")AVAILABLE =disksize("C")IF SPACE.NEEDED ] AVAILABLE THENMSG("ERROR - No Room","","","")END ELSE
Transfer logic here
END(Volume 1, Issue 6, Pages 4,5)
At 21 APR 1998 09:58AM Steve Smith wrote:
Michael - could you please email the your code, or a specific
example so I can patch the SUBDIR routine as required. It was
written 1989, so it may require some surgery or withstand
improvements (given the experience of the last 9 years!) I may
have later routines which will help.
Regards,
Steve Smith
stsm@ozemail.com.au
At 21 APR 1998 10:34AM Eric Emu wrote:
Michael,
Try this. It's the worst bit of assembler ever written, but it
probably does the job for you…
Highlight this posting's code and Ctrl-C under Windows, then Ctrl-V
in notepad.exe and save as a dos text file C:\MYFILE.TXT
From AREV TCL: EDIT DOS C:\MYFILE.TXT and save the text in a basic program, save, compile and run to create the object.
Eric Emu
A =\02000000000000000000EB6390002020\
A:=\20202020202020202020202020202020\
A:=\20202020202020202020202020202020\
A:=\20202020202020202000002020202020\
A:=\20202020202020202020202020202020\
A:=\20202020202020202020202020202020\
A:=\202020202020000000000000000000E8\
A:=\D700E8EB00E81601E81B00E85F00E89D\
A:=\00E8420033C92E8A0E3E00B8001233D2\
A:=\2EFF1E0A00CB50535152571E2E803E05\
A:=\000175F1B40DBA01002EFF1E0A002E89\
A:=\0E6B002E89366D008CDA2E89166F001F\
A:=\5F5A595B58C31E50535152F88CCA8EDA\
A:=\B43BBA1200CD215A595B581FC31EBA3F\
A:=\002E8E1E6F002E8916710033DB2E8B0E\
A:=\6B008B0050532E8B1E71002E8907432E\
A:=\891E71005B58438BD33BD17702EBE333\
A:=\C0BB3F002E8B366B002E89001FC31E50\
A:=\535152568CCA8EDABA3F00F8B43BCD21\
A:=\72092EC6063E0000EB07902EC6063E00\
A:=\01F85E5A595B581FC31E505351528CCA\
A:=\8EDAB419CD212EA211005A595B581FC3\
A:=\1E56505351528CCA8EDABE120033C02E\
A:=\A011000541002E890446B93A002E890C\
A:=\46B95C002E890C5A595B585E1FC31E56\
A:=\505351528CCA8EDAF8B447BE120083C6\
A:=\03B200CD215A595B585E1FC31E505351\
A:=\52E8B900E8B600B4022E8A16110080C2\
A:=\41CD21B402B23ACD215A595B581FC31E\
A:=\56505351528CCA8EDAE89100B92000BB\
A:=\0000BE12008B10B402CD21433BD975F5\
A:=\5A595B585E1FC31E5650535152E86D00\
A:=\2E8B0E6B0041BB0000BE3F002E8B10B4\
A:=\02CD21433BD975F45A595B585E1FC31E\
A:=\5650535152E845002E8B0E6B0041BB00\
A:=\00BE3F002E8B10B40242CD21433BD975\
A:=\F35A595B585E1FC31E5650535152E81C\
A:=\00B92000BB0000BE12008B10B40242CD\
A:=\21433BD975F45A595B585E1FC3505351\
A:=\52B402B20DCD21B402B20ACD215A595B\
A:=\58C3505351528AD0B402CD215A595B58\
A:= \C3\
open 'BP' to bp.file then
write A on bp.file,'$PATH.EXISTS'end else
call msg('Modify BP in code to a file you have','','','')end
* catalog the function, and then in your code
declare function path.exists
error=path.exists('C:\DOS')
* returns error=1 if path is missing or error=0 if path is present
At 22 APR 1998 10:02AM Michael Slack wrote:
Thank you Mr. Emu. I was able to load your assembler program and do some inital testing last night. So far it looks like it will meet my needs.
Thank You,
Michael Slack
At 23 APR 1998 02:28AM Eric Emu wrote:
Good news. If you have any further suggestions about the program, leave a posting here.
Eric Emu
At 30 APR 1998 01:59PM Larry Sweet wrote:
Here's how I use Steve Smith's SUBDIR function. I use it to check to see if a subdirectory exists under c:\. That sounds like it ought to work for you, as it will not break if the subdir is not there.
* look for c:\TEMP directory on the workstation
* uses SUBDIR function from Steve Smith's web page
* SUBDIR returns a @FM delimited array of all the directories under the path
* then just locate the value in the array
tempdir=TEMP"
temppath=C:\"
subdirs=SUBDIR(temppath)
LOCATE tempdir IN subdirs USING @FM SETTING pos ELSE
MSG("ERROR: Unable to fax from this workstation|":temppath : tempdir: " does not exist.")STOPEND
Hope this helps…