Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
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?

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$LOCATEOther 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

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
$ EXITThis 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

![]() |
![]() |
![]() |
| Login or Register to Reply | |
| Login | Register |
| Ads by Google |