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

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

editing a txt file using a com file

Reply to Message Icon

Name: VMS_fish
Date: February 22, 2008 at 14:41:15 Pacific
OS: VMS 7.3
CPU/Ram: a
Product: 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?



Sponsored Link
Ads by Google

Response Number 1
Name: Bob Gezelter
Date: February 22, 2008 at 16:26:49 Pacific
Reply:

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


0

Response Number 2
Name: HakZan
Date: February 23, 2008 at 03:00:15 Pacific
Reply:

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


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More






Use following form to reply to current message:

Login or Register to Reply
LoginRegister


Sponsored links

Ads by Google


Results for: editing a txt file using a com file

How to edit a binary file ? www.computing.net/answers/openvms/how-to-edit-a-binary-file-/191.html

schedule a task, how? www.computing.net/answers/openvms/schedule-a-task-how/249.html

seperate a file to different file www.computing.net/answers/openvms/seperate-a-file-to-different-file-/497.html