Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Re: Some ignorant questions about text handling
Allodoxaphobia wrote:

> On Wed, 26 Mar 2008 15:24:06 +0200, yusakhar wrote: 
>
> newline window$ + OS/2, or newline linux?
>
> Jonesy

The script is for use in a Linux system. The problem that is beyond me is:

Given a long string (than can be PARSEd to line-length pieces), to form the
pieces into a multiline text variable which can be passed to a parent
process by a RETURN statement.

--
yusakhar

Report this thread to moderator Post Follow-up to this message
Old Post
yusakhar
03-27-08 12:57 AM


Re: Some ignorant questions about text handling
Dave Saville wrote:

> On Wed, 26 Mar 2008 13:24:06 UTC, yusakhar <some.user@some.domain>
> wrote:
> 
>
> /* */
>
> CRLF = '0a0d'X
>
> stuff = hello||crlf||world
>
> rc = lineout(STDOUT, stuff)
>
> HTH
>

That looks like what I want. But (it is a Linux system) I think I need only
the LF, so it would be '0A'X.

It would be very easy to embed ||'0A'X|| in the file of long strings,
because it is obvious where the linebreaks belong. so I would not need to
code the PARSE.

Thanks.

--
yusakhar

Report this thread to moderator Post Follow-up to this message
Old Post
yusakhar
03-27-08 12:57 AM


Re: Some ignorant questions about text handling
On Wed, 26 Mar 2008 07:43:19 -0700 (PDT), legacymainframe@gmail.com wrote:

> Here is the blog: http://legacymainframe.wordpress.com.

Which opened up as a totally blank page in konqueror. W3C Validator
offers a clue:
http://tinyurl.com/3x4qo6

It played better in Opera.

Jonesy
--
Marvin L Jones    | jonz          | W3DHJ  | linux
38.24N  104.55W  |  @ config.com | Jonesy |  OS/2
*** Killfiling google posts: <http://jonz.net/ng.htm>

Report this thread to moderator Post Follow-up to this message
Old Post
Allodoxaphobia
03-27-08 12:57 AM


Re: Some ignorant questions about text handling
In <47eaa251$0$23348$c3e8da3@news.astraweb.com>, on 03/26/2008
at 09:22 PM, yusakhar <some.user@some.domain> said:

>The script is for use in a Linux system.

Then you need to concatenate LF between lines.

--
Shmuel (Seymour J.) Metz, SysProg and JOAT  <http://patriot.net/~shmuel>

Unsolicited bulk E-mail subject to legal action.  I reserve the
right to publicly post or ridicule any abusive E-mail.  Reply to
domain Patriot dot net user shmuel+news to contact me.  Do not
reply to spamtrap@library.lspace.org


Report this thread to moderator Post Follow-up to this message
Old Post
Shmuel (Seymour J.) Metz
03-27-08 04:00 AM


Re: Some ignorant questions about text handling
In <47ea3aa5$0$23425$c3e8da3@news.astraweb.com>, on 03/26/2008
at 02:02 PM, yusakhar <some.user@some.domain> said:

>1) Given variable which is to contain a string to be printed as several
>lines, how are the line breaks of the string to be indicated? I have
>tried "\n" and "^J", neither of which work.

Why would you expect them to? In REXX there are no metacharacters other
than the trivial case of having to double the framing characters in a
quoted string, e.g., 'this '' is an apostrope' and "this "" is a quote."
If you want to use a control character, express it as hex, e.g.,
Ctrl_J='0a'x.

>What's the right way?

Define CRLF in hex, then concatenate. Depending on the platform, you might
need CR, LF, CRLF or NL, in the appropriate code.

>2) The content of this variable would be RETURNed to the parent of the
>script. Because I do not have access to the parent right now, I am
>trying to simulate this  by the output of a series of commands
>like "LINEOUT(outfile,singleline)".

That's not a command, it's a function.

>(I am not sure that this is a good emulation.)

CHAROUT(outfile,singleline) might be more appropriate. but LINEOUT should
work.

>sh: 0: command not found

That's because LINEOUT is a function. When a statement contains only an
expression, the value of that expression is treated as a command in the
default environment. As others have noted, you need to one of

call LINEOUT outfile, singleline
status=LINEOUT(outfile,singleline)

>although the content of singleline is transferred correctly to outfile.
>If the command works, why is it reported as unfound?

It isn't; look at the message and you will see that "0" is the command not
found.

--
Shmuel (Seymour J.) Metz, SysProg and JOAT  <http://patriot.net/~shmuel>

Unsolicited bulk E-mail subject to legal action.  I reserve the
right to publicly post or ridicule any abusive E-mail.  Reply to
domain Patriot dot net user shmuel+news to contact me.  Do not
reply to spamtrap@library.lspace.org


Report this thread to moderator Post Follow-up to this message
Old Post
Shmuel (Seymour J.) Metz
03-27-08 04:00 AM


Re: Some ignorant questions about text handling
yusakhar wrote:
> The script is for use in a Linux system. The problem that is beyond me is:
>
> Given a long string (than can be PARSEd to line-length pieces), to form th
e
> pieces into a multiline text variable which can be passed to a parent
> process by a RETURN statement.

As others have told you, you can insert the correct newline character(s)
into the string and issue it in one go.

In general, you can parse any length delimited string as follows (note
that this example works with any delimiter, it simply requires the first
character of the string to be the delimiter):

null = '00'x
teststring = null"String 1"null"string 2"null"String 3"
PARSE VAR teststring delim +1 teststring
DO WHILE teststring \= ""
PARSE VAR teststring onepiece (delim) teststring
SAY onepiece
END

You can substitute a multi-character delimiter if you need to by
changing "+1" in the first PARSE.

Graham.

Report this thread to moderator Post Follow-up to this message
Old Post
Graham
03-27-08 04:00 AM


Re: Some ignorant questions about text handling
On Wed, 26 Mar 2008 17:04:17 UTC, Phil Hobbs
<pcdh@SpamMeSenseless.pergamos.net> wrote:

> BTW on Windows and OS/2, that should be crlf = '0d0a'x.

I know, I did it from memory and had a 50% chance of gettting it right
:-) Actually it works either way around.
--
Regards
Dave Saville

NB Remove nospam. for good email address

Report this thread to moderator Post Follow-up to this message
Old Post
Dave Saville
03-28-08 12:35 AM


Re: Some ignorant questions about text handling
"Graham" <norrisg@spam_free.linkline.com> wrote in message
news:--adnTGKdZ3Ui3banZ2dnUVZ_h6hnZ2d@linkline.com...
> null = '00'x
> teststring = null"String 1"null"string 2"null"String 3"
> PARSE VAR teststring delim +1 teststring
> DO WHILE teststring \= ""
>   PARSE VAR teststring onepiece (delim) teststring
>   SAY onepiece
> END
>
> You can substitute a multi-character delimiter if you need to by changing
> "+1" in the first PARSE.
>
> Graham.

Wonderful!

I first saw this construct in some inherited code (pun not intended)
virtually word-for-word and I've re-used it several times and never stopped
long enought to smell the roses... it was obvious what it did.  Now I see it
explained (albeit without any real explanation) I like it even better.

Phil
----



Report this thread to moderator Post Follow-up to this message
Old Post
Phil
03-29-08 12:29 AM


Re: Some ignorant questions about text handling
Dave Saville wrote:
> On Wed, 26 Mar 2008 17:04:17 UTC, Phil Hobbs
> <pcdh@SpamMeSenseless.pergamos.net> wrote:
> 
>
> I know, I did it from memory and had a 50% chance of gettting it right
> :-) Actually it works either way around.

Putting the linefeed before the carriage return?  You complete
Bolshevik, you.

Cheers,

Phil Hobbs

Report this thread to moderator Post Follow-up to this message
Old Post
Phil Hobbs
03-29-08 12:29 AM


Re: Some ignorant questions about text handling
On Fri, 28 Mar 2008 14:34:46 -0500, Phil Hobbs
<pcdhSpamMeSenseless@pergamos.net> wrote:

> Putting the linefeed before the carriage return?  You complete
> Bolshevik, you.

Wouldn't that make him a Menshevik?

Best,
Tony

Report this thread to moderator Post Follow-up to this message
Old Post
Tony Mc
03-30-08 12:28 AM


Sponsored Links




Last Thread Next Thread Next
Pages (3): « 1 [2] 3 »
Search this forum -> 
Post New Thread

Rexx archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 09:31 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.