Computing.Net > Forums > OpenVMS > editing a txt file using a com file

editing a txt file using a com file

Reply to Message Icon

Original Message
Name: VMS_fish
Date: February 22, 2008 at 14:41:15 Pacific
Subject: editing a txt file using a com file
OS: VMS 7.3
CPU/Ram: a
Model/Manufacturer: a
Comment:

I want to create a command file that can open a text file, find a specific word, edit it and save the new text file using lexical functions - is there an easy way to do this?


Report Offensive Message For Removal

Response Number 1
Name: Bob Gezelter
Date: February 22, 2008 at 16:26:49 Pacific
Subject: editing a txt file using a com file
Reply: (edit)

VMS_Fish,

I won't write the code for this simple example, but it is straightforward enough to make some observations that will point you to the appropriate HELP text on your system:

- OPEN/READ, OPEN/WRITE
- CREATE
- CLOSE
- READ, WRITE
- lexical functions F$EXTRACT, F$LOCATE

Other than the syntax, this is the classic "read a line, do some processing, write a line" example. The one unusual aspect, that is missed by many at first, is that DCL creates file with Printer Carriage Control by default. If one uses CREATE the output file, and then do an OPEN/APPEND, one creates a normal, plain text file.

- Bob Gezelter, http://www.rlgsc.com


Report Offensive Follow Up For Removal

Response Number 2
Name: HakZan
Date: February 23, 2008 at 03:00:15 Pacific
Subject: editing a txt file using a com file
Reply: (edit)

Why do you specificly ask for use of lexicals ?

You can use the "substitute"-command in EDT.

$ EDIT/EDT filename
SUBSTITUTE/old word/new word/ALL
EXIT
$ EXIT

This sequence substitute all "old words" with "new words" in the specified file.

But if you don't know if the "old word" exist, then you have to OPEN the file, READ it line by line, use F$LOCATE to locate the specific word on each line.......and so on.

regards,

Hakan Zanderau
HA-solution


Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: editing a txt file using a com file

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software