[Date Prev][Date Next][Thread Prev][Thread Next]
[Author Index]
[Date Index]
[Thread Index]
[SQR-USERS Info]
[SQRUG Home Page]
Re: File Attributes
It's a bit of a roundabout solution but you could pipe the results of dir to
a file and read that in line by line.
Check syntax of dir - especially /T and /A, or perhaps attrib also
here's some code I wrote for something similar - opened up each *.rec file
found in a directory for processing
you would change $comspec_params_1 amongst other things!
-----
let $comspec = 'c:\winnt\system32\cmd.exe /c '
let $comspec_params_1 = 'dir /b >'
let $comspec_params_2 = 'del '
let $sourcedir = $DirName
let $wildcard = '*.rec'
let $resultfile = $DirName || 'reclist.txt'
#debugf show 'Directory Name: ' $Dirname
! delete the existing file (if it exists)
let $systemcall = $comspec || $comspec_params_2 || $resultfile
call system using $systemcall #result
if #result >0
! an error occured deleting existing file
display '*** error calling DEL ***'
DISPLAY #RESULT
DISPLAY $SYSTEMCALL
stop-quiet
end-if
! create the new file with the file listing
let $systemcall = $comspec || $comspec_params_1 || $resultfile || ' ' ||
$sourcedir || $wildcard
#debugd show 'Systemcall: ' $systemcall
! get the directory listing
call system using $systemcall #result
! #result returns error for;
! >0 for DOS
! <32 for Windows
! note: NT cmd.exe seems to trick SQR thinking its DOS
if #result >0
! an error occured calling DIR
display '*** error calling DIR ***'
DISPLAY #RESULT
DISPLAY $SYSTEMCALL
stop-quiet
end-if
! dummy loop to give the OS time to finish creating the file
let #timer_wait = 0
while #timer_wait < 500000
add 1 to #timer_wait
end-while
let #of_updated_rows = 0
let #InputTran = 0
display 'Processing file: ' noline
display $resultfile
! was the file created (ie anything to process?)
if exists($resultfile) = 0
open $resultfile as 1 for-reading record=480:vary status=#filestatus
! did the file open OK?
if #filestatus != 0
!an error occured opening the file
show '*** error opening file - ' $resultfile ' ***'
display 'FileStatus = '
display #filestatus
stop-quiet
else
! File opened OK, infinite loop for reading each line of the file
while 1=1
read 1 into $recfile:30
! end of file?
if #end-file
break
end-if
display ' '
DISPLAY 'Reading receipt file: ' noline
display $recfile
display ' '
let $file = $sourcedir||$recfile
#debugd show 'Processing Receipt List: ' $file
! Call procedure to process each row of file
do process-interface-rows
! end infinite loop
end-while
do closing-process
! end file opened OK
end-if
! file didn't exist
else
show '*** no .REC files found to process ***'
show 'Directory Searched - ' $Dirname
end-if
show ' '
show 'Lines (receipts) read: ' #InputTran
show 'Number of Receipts created: ' #of_updated_rows
show 'Number of Lines in error: ' #invalid_receipt
-----
> -----Original Message-----
> From: Jason Sekkes (SB) [SMTP:Jason.Sekkes@STROEHMANN.COM]
> Sent: Thursday, 15 November 2001 1:44
> To: SQR-USERS@list.iex.net
> Subject: File Attributes
>
> Does anyone know if it is possible to check a files attributes (file size,
> modified date, etc) using SQR? We need a polling program to check for
> file
> downloads.
>
> Jason Sekkes
> Programmer Analyst
> Stroehmann Bakeries, LC
> * (610)-631-8214
> * Jason.Sekkes@Stroehmann.com
************** IMPORTANT MESSAGE **************
This e-mail message is intended only for the addressee(s) and contains
information which may be confidential. If you are not the intended recipient
please advise the sender by return email, do not use or disclose the contents,
and delete the message and any attachments from your system. Unless
specifically indicated, this email does not constitute formal advice or
commitment by the sender or the Commonwealth Bank of Australia (ABN 48 123 123
124) or its subsidiaries.
**************************************************