× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.


  • Subject: Re: Clever UNIX/C Constructs
  • From: Jim Langston <jimlangston@xxxxxxxxxxxxxxxx>
  • Date: Fri, 29 Dec 2000 14:30:00 -0800
  • Organization: Pacer International

Dan,

In most languages when I say 
str = 'Hi there '
str = str + 'text'
str winds up being 'Hi there text'

We know from RPG, however,
it would wind up being something like 'Hi there           '
But, this is because most languages treat strings as being variable length.
Basic stores the length of the string in the first byte, C uses fixed length
strings, but uses the Null terminator.  RPG uses neither.
We can get RPG to do it closely with constructs like:
str = %trim(str) + 'text'
but then str winds up being
'Hi theretext        '
We would have to say
str = %trim(str) + ' text'

Given the examples you show, I would expect free form RPG to convert it to
str = %trim(str) + 'text'
as you state, unless they keep a record of the end of the string somewhere.

Regards,

Jim Langston

D.BALE@handleman.com wrote:
> 
> Given the examples in the survey, couldn't we just as well do this?:
> 
>     /free
>        str = str + 'text';      // append 'text' to str
>        date = date + %days(7);  // add 7 days to date
>        num = num - 17;          // decrement num by 17
>        num = num * 2;           // multiply num by 2
>        array(findStart(array:start)+offset) =
> array(findStart(array:start)+offset) + 1;
>     /end-free
> 
> Er, doesn't "eval str = str + 'text'" result in field str being unchanged?
> Presuming that the += operates the same way, it will be fairly useless for
> concatenating text to a string.  Unless they'll make it *act* like "eval str =
> %TRIMR(str) + 'text'".
> 
> Dan Bale
> IT - AS/400
> Handleman Company
> 248-362-4400  Ext. 4952
> 
> -------------------------- Original Message --------------------------
> Hi Dan -
> 
> >Maybe we should designate an anti-vote on the form?  Or say,
> >"George, take $50 of my $100 and take it away from #21, i.e.:
> >[-$50]  21  $10  Short form assignment operators += -= *= /= **=
> 
> Unlike some of the C stuff, there shouldn't be any real confusion
> interpreting evals using what is being proposed in #21.
> 
> eval field [extra operator]= expression
> 
> always translates to
> 
> eval field = field [extra operator](expression)
> 
> I'm sure that the only reason it costs $10 is because of complications if
> "field" is an array or substring or something and has expressions contained
> within it, to make sure that it is resolved only once.
> 
> Ken
> Southern Wine and Spirits of Nevada, Inc.
> Opinions expressed are my own and do not necessarily represent the views of
> my employer or anyone in their right mind.
> +---
> | This is the RPG/400 Mailing List!
> | To submit a new message, send your mail to RPG400-L@midrange.com.
> | To subscribe to this list send email to RPG400-L-SUB@midrange.com.
> | To unsubscribe from this list send email to RPG400-L-UNSUB@midrange.com.
> | Questions should be directed to the list owner/operator: david@midrange.com
> +---
+---
| This is the RPG/400 Mailing List!
| To submit a new message, send your mail to RPG400-L@midrange.com.
| To subscribe to this list send email to RPG400-L-SUB@midrange.com.
| To unsubscribe from this list send email to RPG400-L-UNSUB@midrange.com.
| Questions should be directed to the list owner/operator: david@midrange.com
+---

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.