1828248 Members
2779 Online
109975 Solutions
New Discussion

DCL

 
SOLVED
Go to solution
Sentosa
Frequent Advisor

DCL

Dear ALL,

I want to open a file & retreive the desired record. Then, i will update the particular field into the same record & write back to the file.

Could anyone provide the DCL example to me how to update the particular field into the same record & write back to the file?

Thanks,
Sentosa
7 REPLIES 7
Hein van den Heuvel
Honored Contributor
Solution

Re: DCL


For an RMS indexed file using DCL as language it could look like (untested):

$key="xyz"
$open/read/write file name.ext
$read/key=&key file record
$write sys$output "old text: ", f$ext(20,10,record)
$write sys$output "old binary: ", f$cvsi(30*8,32,record)
$record[20,10] := "new text value"
$record[30*8,32] = 12345 ! New binary value
$write/update/symbol file record
$close close


hth,
Hein van den Heuvel
Sentosa
Frequent Advisor

Re: DCL

Dear ALL,

Sorry for missing some information.
the source & target file is normal text file in OpenVMS.

Thanks,
Sentosa
Jan van den Ende
Honored Contributor

Re: DCL

Sentosa,

>>>
the source & target file is normal text file in OpenVMS.
>>>
You will have to use some tool then.
You want to replace any occurrence of with >

$ create modify.edt
s???wh
exit
$
$ edit/edt /command=modify.edt


- oldstring or newstring contains a questionmark "?", then replace "?" in the EDT file with another character, eg "/" or "#"
- if you only need to replace 1 occurrence, leace out the "wh" ( = whole ) in the s ( = substitute ) command
- if targetfile is just a higher version of sourcefile, leave out the filename on the exit command.


Far, and far more is possible, but you will need the manual for that.

--- EDT is one possibility, there are many more.
EDT has the advantage to be available on ANY VMS system, without any extra software, I have used it since VMS V3.

hth

Proost.

Have one on me.

jpe
Don't rust yours pelled jacker to fine doll missed aches.
Sentosa
Frequent Advisor

Re: DCL

Thanks for your information.

Actually, i need to do the (update) action in batch mode using DCL for handling different suitation. So, edit mode is not suitable for me.

Regards,
Sentosa
Bojan Nemec
Honored Contributor

Re: DCL

Sentosa,

On a sequential file you can use a similar aproach as Hein give you for an indexed file:

$open/read/write file name.ext
$loop:
$read file record /end=end
$if ... (put some test for which record should b updated)
$then
$ write sys$output "old text: ", f$ext(20,10,record)
$ write sys$output "old binary: ", f$cvsi(30*8,32,record)
$ record[20,10] := "new text value"
$ record[30*8,32] = 12345 ! New binary value
$ write/update/symbol file record
$endif
$goto loop
$end:
$close file

The length of the new record must remain the same as the old record for all sequential files!

Bojan
Robert Gezelter
Honored Contributor

Re: DCL

Sentosa,

There are many choices for doing the change in batch.

If you wish to stay with using DCL, you can manipulate the record using the F$LOCATE, cut out the unchanging portions of the string using F$EXTRACT, and then use the "+" (which on strings does concatenation; or simple substitution) to put the pieces of the new record together again. I have used both approaches, depending on the context, to wit:

$! Extract Item Field and change it.
$ FRONTRECORD = F$EXTRACT(0, 20, RECORD)
$ BACKRECORD = F$EXTRACT(30, F$LENGTH(RECORD)-30, RECORD)
$ ITEM = F$EXTRACT(20, 10, RECORD)
$ IF ITEM .EQS. "C-09876543"
$ THEN
.....
$ ITEM = "D-12345678"
$ ENDIF
$!
$ RECORD = FRONTRECORD + ITEM + BACKRECORD


The above code snippet is for illustrative purposes, I sanitized it and had to retype it from an exemplar (Please type it into a test case and experiment with it before using).

For masses of records, there are also the SLP TPU and TECO editors which can be used for batch processing.

All of the functions and editors are documented in the help text and documentation set. The DCL lexical functions are documented under "Lexical functions".

I hope that the above is helpful.

- Bob Gezelter, http://www.rlgsc.com
Sentosa
Frequent Advisor

Re: DCL

Thanks