READSEQ and CR/LF on Unix

542 views
Skip to first unread message

MarcoM

unread,
Mar 29, 2010, 7:50:14 AM3/29/10
to jBASE
Is there a way to tell jBASE to discard the CR (CHAR(13)) at the end
of the line if the file being processed was ftp'ed from DOS in binary
mode?

I have hundreds of programs to migrate from UV to jBASE with
constructs like this:

LOOP WHILE READSEQ LINE FROM FILE
* do something with the LINE
REPEAT

Im changing in jBASE to this:

CR = CHAR(13)
LOOP
READSEQ LINE FROM FILE ELSE BREAK
CHANGE CR TO "" IN LINE
* do something with the LINE
REPEAT

UV will give the same output regardless of whether the file is
terminated with LF or CRLF and Im wondering if jBASE has a switch
(perhaps an environment variable or some IOCTL option) to achieve the
same.

Thanks for any help

Daniel Klein

unread,
Mar 29, 2010, 11:23:31 AM3/29/10
to jb...@googlegroups.com
http://www.jbase.com/r5/knowledgebase/manuals/3.0/30manpages/man/adv12_SEQUENTIAL.FILE.EXTENSIONS.htm

Dan

--
Please read the posting guidelines at: http://groups.google.com/group/jBASE/web/Posting%20Guidelines

IMPORTANT: Type T24: at the start of the subject line for questions specific to Globus/T24

To post, send email to jB...@googlegroups.com
To unsubscribe, send email to jBASE-un...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/jBASE?hl=en

To unsubscribe from this group, send email to jbase+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.

Marco Manyevere

unread,
Mar 29, 2010, 12:15:44 PM3/29/10
to jb...@googlegroups.com
Thanks I already came across this document but didnt see which option would help me achieve what I want. I was looking more for an environmental variable that would affect the behaviour of _all_ the existing programs without having to do an IOCTL after every OPENSEQ in every subroutine. If there is an IOCTL option that does what I want, it would only help me in situations where there are multiple READSEQs to the same file in the same routine.

Jim Idle

unread,
Mar 29, 2010, 1:12:38 PM3/29/10
to jb...@googlegroups.com

> -----Original Message-----
> From: jb...@googlegroups.com [mailto:jb...@googlegroups.com] On Behalf
> Of MarcoM
> Sent: Monday, March 29, 2010 4:50 AM
> To: jBASE
> Subject: READSEQ and CR/LF on Unix
>
> Is there a way to tell jBASE to discard the CR (CHAR(13)) at the end
> of the line if the file being processed was ftp'ed from DOS in binary
> mode?

Well, err, don't ftp a text file in binary mode?

>
> I have hundreds of programs to migrate from UV to jBASE with
> constructs like this:
>
> LOOP WHILE READSEQ LINE FROM FILE
> * do something with the LINE
> REPEAT
>
> Im changing in jBASE to this:
>
> CR = CHAR(13)
> LOOP
> READSEQ LINE FROM FILE ELSE BREAK
> CHANGE CR TO "" IN LINE
> * do something with the LINE
> REPEAT
>
> UV will give the same output regardless of whether the file is
> terminated with LF or CRLF and Im wondering if jBASE has a switch
> (perhaps an environment variable or some IOCTL option) to achieve the
> same.

Well, do you have to do it like this?
Firstly, why send text files to UNIX with a CRLF terminator?
Secondly, if you cannot fix this (which is your real problem), then fix the line endings after the files are received, all at once with the tr -d command.
Thirdly, if you feel you need to change the programs, then just wrote a bash script to find all the programs with OPENSEQ and insert the IOCTL directly after it with sed. UNIX is essentially a text manipulation system you know - it behooves you to know how to use it. Personally, I would probably use awk to 'fix' those programs if I was not able to fix the actual problem at source, which is the transmission.

The other _actual_ problem is that UniVerse is wrong to behave like that of course; that isn't what UNIX does with text. ;-) Perhaps though, jBASE should be bug compatible with UniVerse if that is the emulation that is configured.

Finally, please read the posting guidelines and remember to include information about your operating systems and versions of jBASE and so on.

http://groups.google.com/group/jBASE/web/Posting%20Guidelines
http://groups.google.com/group/jBASE/web/Posting%20Guidelines
http://groups.google.com/group/jBASE/web/Posting%20Guidelines
http://groups.google.com/group/jBASE/web/Posting%20Guidelines


Jim

Marco Manyevere

unread,
Mar 29, 2010, 4:20:56 PM3/29/10
to jb...@googlegroups.com
Thanks Jim,
 
The thing is that there are already hundreds of existing programs that work correctly because of the "bug" in Universe and if there was a way to make jBASE bug compatible with UV in this case it would be the perfect solution.
 
The files do come into the Unix environment in different ways (not necessarily ftp). Even then, some of the ftp'ed files have checksums that would not match unless they were transmitted byte for byte from the source system. The idea is that third party systems and procedures must be left as they are as much as possible otherwise the testing would become a much much bigger effort.
 
Adding a tr -d for every channel still means there are several different places to change.

MarcoM

unread,
Mar 30, 2010, 4:29:24 AM3/30/10
to jBASE
jBASE : Major 5.0 , Minor 21 , Patch 0366 (Change 86108)
OS : AIX 5.3

I tested IOCTL on CRLF terminated text files and obtained the
following:

IOCTL(FILE, JIOCTL_COMMAND_SEQ_CHANGE_DELIMITER, CHAR(13):CHAR(10))
Only works on the first line but all subsequent lines now begin with
CHAR(10)

IOCTL(FILE, JIOCTL_COMMAND_SEQ_CHANGE_DELIMITER, CHAR(13))
Only works on the first line but all subsequent lines now begin with
CHAR(10)

This is nowhere near what I want, which is that READSEQ must not
include the CR or LF character in the string regardless of whether the
file is CRLF (Windows) or LF only (Unix) terminated. This is because I
am migrating from UV which already works this way. I do not have
control over how the text files are transfered to jBASE so suggesting
to change that will not help me.

On Mar 29, 5:23 pm, Daniel Klein <danielklei...@gmail.com> wrote:
> http://www.jbase.com/r5/knowledgebase/manuals/3.0/30manpages/man/adv1...
>
> <http://www.jbase.com/r5/knowledgebase/manuals/3.0/30manpages/man/adv1...>

> > ME" as the subject.- Hide quoted text -
>
> - Show quoted text -

Daniel Klein

unread,
Mar 30, 2010, 11:27:56 AM3/30/10
to jb...@googlegroups.com
If you are concerned about the CR:LF at the end of each line then why not just do:

READSEQ line
line = line[1,-3]

and live happily ever after ;-)

Dan


To unsubscribe from this group, send email to jbase+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.

Jim Idle

unread,
Mar 30, 2010, 12:26:35 PM3/30/10
to jb...@googlegroups.com
Well, getting frustrated with us on this forum isn't going to help you mate ;-) We don't have the ability to change the product for you, and you don't have control over the idiocy of transmitting text files in the wrong format to UNIX.

The fact that UniVerse does it one way is fair enough (even though it is technically wrong), but if you want jBASE to behave the same way (which is probably best), then you need to ask your TEMENOS support people to request an enhancement. At one point we (jBASE) would have made such a patch overnight for you, but I am afraid that you will probably now have to submit the request in triplicate, have it rejected, amended, returned, amended again, and finally recycled as firelighters.

Though to be honest, even if you had 300 programs to modify by hand, I could have changed them all by now. If you write a quick awk program, then you could change the programs in a few hours (including writing the program taking you a long time for your first one). Just add:

READSEQ Line FROM ....
CONVERT CHAR(10):CHAR(13) TO "" IN Line

And if you don't want to learn awk, then just write a jBC program to do this. It is pretty trivial and you can even display the lines of code and ask if the proposed change is good, store the names of any programs where the answer is no and so on and so forth. Just apply your initiative to this problem - it really isn't such a big deal.

I presume that you have set the jBASE emulation to UniVerse right?

Jim


> -----Original Message-----
> From: jb...@googlegroups.com [mailto:jb...@googlegroups.com] On Behalf
> Of MarcoM

> jbase+unsubscribegooglegroups.com or reply to this email with the words

Dhilip_kumar

unread,
Mar 30, 2010, 1:11:44 PM3/30/10
to jBASE
There are definite no benefits for repeatedly asking the posters about
their jBase version and the platform it runs. They simply ignore
thinking its waste of time. :)

MacroM,

If you are using a unix type operating system such as RH it is
possible that you have utility like "dos2unix" which does the work for
you without you having to write a separate program.

Eg:
$dos2unix mydosfile.txt myunixfile.txt

http://linux.die.net/man/1/dos2unix

Regards,
Dhilip

Reply all
Reply to author
Forward
0 new messages