Free2Code

Warning: Illegal offset type in /home/free2code/vhosts/free2code.net/httpdocs/jtdb/drivers/mysql/mysql.php on line 305
 
Time: 2008-12-04, 08:04pm
VMS help
Subject: VMS help  ·  Posted: 2005-01-11, 04:00am
Rank: Unregistered
Hello world

Im looking for a little help in VMS. I need to find a way of creating a program that will search a txt file for a particular "string" when its found this string to delete anything above it in the file (Through the editor?). If there anyway that this can be done. All help would be appriciated.


Thanks
Limey
 
  Reply to this ·  Post link ·  Top
Subject: Re: VMS help  ·  Posted: 2005-06-04, 03:36pm
Rank: Unregistered
You can't delete backwards, but what you CAN do is open a file, read it, and when you find the string you're looking for you open a second file (or a new version of the file you're reading and start writing.

file = x.x
string XYZ

DCL off the top of my head:

$! open the file you want to read
$!
$ open/read F1 X.X
$!
$! open a new version of the file to write to
$!
$ open/write F2 X.X
$!
$! loop 1
$!
$ LP1:
$!
$! read a record if error or EOF goto ENDE1
$!
$ read/err=ENDE1 F1 REC1
$!
$! if the string doesn't contain XYZ goto LP (and read next record)
$!
$ if f$locate("XYZ",REC1) .eq. f$length(REC1) then goto LP1
$!
$! if we're here we've found the record with XYZ in it.
$! write it to F2
$!
$ write F2 REC1
$!
$! next loop
$!
$ LP2:
$!
$! read F1 to EOF and write to F2
$!
$ read/err=ende1 F1
$!
$ write F2 REC1
$!
$ goto LP2
$!
$ ENDE1:
$!
$! we're either at EOF or hit an error
$! so close the files
$!
$ close F1
$ close F2
$!
$ exit
 
  Reply to this ·  Post link ·  Top

Pages: 1

Please login or register to post a reply.

icons