Precisely Speaking
February 04, 2012, 07:05:21 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: So what's news with you?  Tell us about it in "Getting To Know You"!
 
   Home   Help Calendar Login Register  
Pages: [1]   Go Down
  Print  
Author Topic: Sequential File Question  (Read 835 times)
adewitt
Professional
***
Posts: 42


« on: September 08, 2010, 01:29:21 PM »

This is the first time I've had a need to use seqential files. I want to open a sequential file that doesn't exist, write records to it and close it.  I am using the command OPENSEQ but I need to create it at the same time. 
OUTPUT = \\GONDOLA\POSIPAY$\
REG.NBR = 1000
FNAME = OUTPUT:'CHKS':REG.NBR

OPENSEQ FNAME TO OUT.FILE ELSE....

And here is where I'm stumped.  Do I need to create FNAME first?  How do I do that? 

Last but not least, is there an easier way?

Thanks.
Logged
CKilgore
Professional
***
Posts: 19



« Reply #1 on: September 08, 2010, 04:16:42 PM »

The code we normally use is this:
Code:
UNIXFILE = "/var/www/extract/whatever"
OPENSEQ UNIXFILE TO F.UNIX ELSE
  EXECUTE "!touch ":UNIXFILE CAPTURING DSP
  OPENSEQ UNIXFILE TO F.UNIX ELSE
    **ERROR OUT
  END
END

This code attempts to open the file and if it is not found will create it.
Logged

Chris Kilgore
Brake Supply Co., Inc.
Prelude ADS Version 20.2
adewitt
Professional
***
Posts: 42


« Reply #2 on: September 08, 2010, 07:16:32 PM »

I forgot to say that we're on Windows and we're using System Builder.

Al
Logged
precisonline
President/Chief Technologist
Administrator
Rock Star
*****
Posts: 1524



WWW
« Reply #3 on: September 10, 2010, 11:10:43 AM »

Al.. did you get what you need on this from the EUG?
Logged

-Kevin
Accidents "happen"; success, however, is planned and executed.
DonQuixote
Uber-Pro
****
Posts: 99


To Dream the Impossible Dream...


« Reply #4 on: September 16, 2010, 10:52:26 AM »

I was checking the Prelude code and you're right.
When I checked the manual I did find another way.

FPATH = "/bktest/filename.txt"
OPENSEQ FPATH TO F.FLAT ELSE
  ** should create a new file **
  WEOFSEQ F.FLAT ON ERROR
     CALL SB.DISP(3,"error message")
     GOTO PGM.EXIT
  END
END

Logged
precisonline
President/Chief Technologist
Administrator
Rock Star
*****
Posts: 1524



WWW
« Reply #5 on: September 16, 2010, 11:05:59 AM »

You want to be careful using OPENSEQ with just a flat file spec instead of a directory and separate file spec.  In a past life I recall that opening a file as:

OPENSEQ "/full/path/to/file" TO...

...can create other issues later, especially with locking.  Better to create a VOC pointer for the path to the file and then OPENSEQ the file like this:

OPENSEQ "VOCname","file" TO...

The added advantage is that the VOC pointer can change to point to a different directory at any time and the code doesn't need to be modified for the change.

BTW, this is Unidata only.  The OPENSEQ with the FQPN works fine on UV and as far as I know, always has.
« Last Edit: September 16, 2010, 11:07:40 AM by precisonline » Logged

-Kevin
Accidents "happen"; success, however, is planned and executed.
adewitt
Professional
***
Posts: 42


« Reply #6 on: November 23, 2011, 01:57:27 PM »

I actually figured out myself and ended up using the VOC method Kevin described earlier.
Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.7 | SMF © 2006-2008, Simple Machines LLC Valid XHTML 1.0! Valid CSS!