1828240 Members
2355 Online
109975 Solutions
New Discussion

Escape sequence

 
Danilo Martinez
Occasional Advisor

Escape sequence

Hi, I need to add an end of line to every line into one ascii file, anyone knows how to do this?

Thanks
Danilo M.
14 REPLIES 14
Tim Hughes_3
Advisor

Re: Escape sequence

Try convert..

$ create x.fdlFILE
ORGANIZATION sequential

RECORD
FORMAT stream_cr

$ conv/fdl=x.fdl y.y x.x

You also try stream_lf to insert lf's. Depends on how you are using the file but also need to play around "set file/att"

Tim
Huc_1
Honored Contributor

Re: Escape sequence

Hello

is your question releated to Linux or to VMS
if it is VMS above answer should work

If it is Linux try dos2unix

first do a dos2unix --help and/or read man page

save original in a save place then try out

dos2unix on your file

Jean-Pierre
Smile I will feel the difference
Huc_1
Honored Contributor

Re: Escape sequence

Hello

Please discard my the above reply It is an Open VMS question you where asking, I must not be totaly awake yet !


Jean-Pierre
Smile I will feel the difference
Gary Sachs
Advisor

Re: Escape sequence

you could use a simple read/write DCL command procedure. The procedure could read the one file append the EOL to each line and write out to another file. Should not be a problem provided the records are less than 1024 bytes, a limitation in symbol sizes in DCL.
Martin P.J. Zinser
Honored Contributor

Re: Escape sequence

On the topic in general: If you are tranfering
"ASCII" data between VMS/Unix/Windows if often pays to compress the files using zip and then to
take advantage or the -l qualifier to Zip or -a to Unzip to do the required line termination conversion.
Antoniov.
Honored Contributor

Re: Escape sequence

Hi Danilo,
end of line or new line is not a ASCII code. On Ms-Dos and Windows OS is CR-LF sequence (HEX 0D followed by 0A). On Unix/linux is only LF (hex 0A). On VMS could be a lot of thing depending by file structure/attribute. Usually VMS use CR-LF sequence.
End of line is depending by use of file: need more info to help you.
Bye
Antonio Maria Vigliotti
Danilo Martinez
Occasional Advisor

Re: Escape sequence

Hi All, thanks a lot for yours answers, I??m going to clarify my question.

As you can see I have the following procedure, I??m reading records from a database and putting its to a file but each registry is being followed immediately of the other in the same line of the file, I need to put every record on different line into my text file.
At this moment I??m putting a "," symbol in order to identofy where ended every record.

$ delete dka300:[pic.ftp.txt]line_summary.txt;1
$ def/user sys$output dka300:[pic.ftp.txt]line_summary.txt
$ rdo :== $rdo
$ rdo
print "BEGIN LINE_SUMMARY_TABLE"
for i
in LINE_SUMMARY_TABLE
print i.line,",",
i.time_stamp,",",
i.current_speed,",",
i.previous_speed,",",
i.two_hours_ago_speed,",",
i.current_efficiency,",",
i.previous_efficiency,",",
i.two_hours_ago_efficiency,",",
i.current_forming_eff,",",
i.previous_forming_eff,",",
i.two_hours_ago_forming_eff,",",
i.four_worst_defects,",",
i.four_worst_cavities,","
end_for
print "END LINE_SUMMARY_TABLE"

print "BEGIN LINE_TABLE"
for i
in LINE_TABLE
print i.line,",",
i.line_unit,",",
i.ida_node_number,",",
i.number_of_sections,",",
i.number_of_gobs,",",
i.mold,",",
i.bottle_finish,",",
i.color,",",
i.job_name,",",
i.lehr_time,",",
i.num_fps,",",
i.min_fp_sample_size,",",
i.efficiency,",",
i.forming_efficiency,",",
i.gob_weight,",",
i.on_line,",",
i.number_of_active_sections,",",
i.art,","

end_for
print "END LINE_TABLE"

I will Apreciate your help.
Thanks
Danilo
Hein van den Heuvel
Honored Contributor

Re: Escape sequence


The default VMS file format is in DIRECTORY/FULL terms:

Record format: Variable length
Record attributes: Carriage return carriage control

In this file format there is not 'end-of-line' stored. It is implied, and assumed to be added by the reader, facilitated by RMS/VMS. Thus if you $TYPE or $PRINT the file on VMS is should look 'right'. Does it? However, if you more it to a different OS you may want the impleid EOL replaced by an explicit characted set. To do so, use an CONVERT with FDL file, just as Tim's first reply suggested. Did you try that?
Also check out HELP EXCHANGE /NETWORK
Alternative format for Tim's reply:

$convert/fdl=sys$input line_summary.txt x.txt
record; format stream
$ ! (or stream_lf or stream_cr as needed).




> At this moment I????m putting a "," symbol in
> order to identofy where ended every record.
:
> print i.line,",", > i.time_stamp,",", > i.current_speed,",",

Hmmm... this confuses me somewhat. We may have a terminology problem. It appears to me that you are putting a comma after each FIELD withing a record. Do you want a new line after 'time_stamp', before 'current_speed'? If so, you'll need multipel print statements, one for each field. Or you'll need to dig up the RDO command to put a CR/LF code in a constant string instead of that comma.

Remember... to find out exactly what your data
file is supposed to be use $DIRECTORY/FULL.
TO know exactly what it looks like, byte by byte, use DUMP.
In record mode:
$DUMP/RECOR=COUNT=10/FIXED line_summary.txt
Or in block mode
$DUMP/BLOCK=COUNT=1 line_summary.txt

hth,
Hein
Antoniov.
Honored Contributor

Re: Escape sequence

Hi Danilo,
1) After you are executed this procedure, you can type line_summary.txt correctly? I think your Database append EOL at end of every line. If you can type this file you can read exactly with this command procedure:
$ open/read src dka300:[pic.ftp.txt]line_summary.txt
$mloop:
$ read src myline /end=xitloop
$ write sys$output myline,"<- End of line"
$ goto mloop
$xitloop:
$ close src
This simple procedure say you output file contain EOL.

Now, if you will export to another platform, you could convert the text file, but for this operation is required more information about your network and target platform.


You can fee awarding point.
Bye.

Antonio Maria Vigliotti
Burkart Beat
Frequent Advisor

Re: Escape sequence

Hi

This is a simple RDO problem, just use this:

print "BEGIN LINE_SUMMARY_TABLE"
for i
in LINE_SUMMARY_TABLE
print i.line
print i.time_stamp
print i.current_speed
print i.previous_speed
print i.two_hours_ago_speed
print i.current_efficiency
print i.previous_efficiency
print i.two_hours_ago_efficiency
print i.current_forming_eff
print i.previous_forming_eff
print i.two_hours_ago_forming_eff
print i.four_worst_defects
print i.four_worst_cavities
end_for
print "END LINE_SUMMARY_TABLE"

this should work - every field in a separate line....

regards

Beat
Danilo Martinez
Occasional Advisor

Re: Escape sequence

Hi Birt, I tried to implement your suggestion but I receive the followin errors:

BEGIN REJECT_HISTORY
i.time_on
^
%RDO-W-LOOK_FOR_STT, syntax error, looking for:
%RDO-W-LOOK_FOR_CON, *, /, -, +, |, =, >, <, EQ, <>, NE, >=,
%RDO-W-LOOK_FOR_CON, GE, GT, LT, <=, LE, NOT, CONT, MISSING,
%RDO-W-LOOK_FOR_CON, BETWEEN, STARTING, MATCHING,
%RDO-W-LOOK_FOR_CON, CONTAINING, AND, OR, ,, ;, FOR, ERASE,
%RDO-W-LOOK_FOR_CON, FETCH, PRINT, PLACE, STORE, MODIFY,
%RDO-W-LOOK_FOR_CON, END_STREAM, START_STREAM,
%RDO-W-LOOK_FOR_CON, END_SEGMENTED_STRING,
%RDO-W-LOOK_FOR_CON, START_SEGMENTED_STRING,
%RDO-W-LOOK_FOR_CON, CREATE_SEGMENTED_STRING, END_FOR,
%RDO-F-LOOK_FOR_FIN, found I instead
I.time_off
^
%RDO-F-LOOK_FOR, syntax error, looking for a valid RDO statement, found I inste
i.cavity_number
^
%RDO-F-LOOK_FOR, syntax error, looking for a valid RDO statement, found I inste
i.section_number

Thanks for your answer.
Hein van den Heuvel
Honored Contributor

Re: Escape sequence


Looks like a made a simpel typo in the procedure. The structure that Beat (and I) proposed to you is:
FOR i IN table
PRINT i.some_field
PRINT i.other_field
:
END_FOR

Please use other examples in your collection to verfy punctuation (commas, semicolons, begin/end, whatever needed).
If you still can't figure it out, be sure to reply with a relevant chunk of actual code, not just the error message. I did not see 'reject_history' or 'time_on' prior in the post so we can only speculate. Try with a simple single print, then add more.

Good luck,
Hein.

Danilo Martinez
Occasional Advisor

Re: Escape sequence

Hi all, this problem was solved putting a print
instrucction before every field.

Thanks a lot
Danilo M.
Antoniov.
Honored Contributor

Re: Escape sequence

Hi Danilo,
then you can assign point to people help you.
Bye
Antonio Maria Vigliotti