Author Topic: Sequential File Question  (Read 9114 times)

adewitt

  • Professional
  • ***
  • Posts: 45
Sequential File Question
« on: September 08, 2010, 02: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.

CKilgore

  • Professional
  • ***
  • Posts: 20
Re: Sequential File Question
« Reply #1 on: September 08, 2010, 05:16:42 PM »
The code we normally use is this:
Code: [Select]
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.
Chris Kilgore
Brake Supply Co., Inc.
Prelude ADS Version 20.2

adewitt

  • Professional
  • ***
  • Posts: 45
Re: Sequential File Question
« Reply #2 on: September 08, 2010, 08:16:32 PM »
I forgot to say that we're on Windows and we're using System Builder.

Al

precisonline

  • President
  • Administrator
  • Rock Star
  • *****
  • Posts: 1612
    • Precision Solutions
Re: Sequential File Question
« Reply #3 on: September 10, 2010, 12:10:43 PM »
Al.. did you get what you need on this from the EUG?
-Kevin
Accidents "happen"; success, however, is planned and executed.

DonQuixote

  • Rock Star
  • *****
  • Posts: 204
  • To Dream the Impossible Dream...
Re: Sequential File Question
« Reply #4 on: September 16, 2010, 11: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


precisonline

  • President
  • Administrator
  • Rock Star
  • *****
  • Posts: 1612
    • Precision Solutions
Re: Sequential File Question
« Reply #5 on: September 16, 2010, 12:05:59 PM »
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, 12:07:40 PM by precisonline »
-Kevin
Accidents "happen"; success, however, is planned and executed.

adewitt

  • Professional
  • ***
  • Posts: 45
Re: Sequential File Question
« 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.