[Date Prev][Date Next][Thread Prev][Thread Next]
[Author Index]
[Date Index]
[Thread Index]
[SQR-USERS Info]
[SQRUG Home Page]
Re: dat output files
- Subject: Re: dat output files
- From: YMCKINNE <YMCKINNE@LANIER.COM>
- Date: Tue, 20 Jan 1998 15:10:47 -0500
This worked for me!!! Thanks to Scott Gunter
Question:
I am a new user of sqr and I am trying to create a flat file. I am
opening and writing to a file within my sqr code. When I run my code,
my output is sent to my temp file in my c directory.
When I run my code, I am not finding my .dat file in the temp file on
my c directory or anywhere on my c drive. I was wondering if someone
could give me some advice on what I might try to fix the problem.
______________________________ Forward Header __________________________________
Answer:
Yolanda,
I've included some code that might help you get started.
begin-procedure InitRoutine
.
.
.
!Assign filename and path to variable <optional>
!and call procedure to handle opening your file(s)
let $output_file = 'c:\temp\filename.dat'
Do Open-files
.
.
.
end-procedure
begin-procedure Open-files
OPEN $output_file AS 1
FOR-WRITING
RECORD=050:FIXED
STATUS = #Open1
IF #Open1 = -1
DISPLAY 'Error opening ' || $output_file
DISPLAY 'Status is ' NOLINE
DISPLAY #Open1
STOP QUIET
END-if
end-procedure
! Once you open the file you must select your data
! and move it to the output fields (defined in your
! write statement.)
move &a.emplid to $0field1
move &a.name to $0field2
move &a.misc to $0field3
! Call the write procedure for each record
! you want to write.
Do WriteRecordOut
!Write procedure
Begin-Procedure WriteRecordOut
WRITE 1 FROM $Ofield1:6
$Ofield2:20
$Ofield3:20
$Ofiller:4
End-Procedure
I don't use an explicit close statement. I assume SQRW handles that
at program termination. But you can include one if you like
!close output file
close 1