× 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.



IMHO a good way to do this would be similar to what JavaScript does.  Use a different type of quote, and if that type was used, it can process interpolation -- that way, you don't have to worry about breaking backward compat with existing programs.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals

For example:

myString = `I have ${apples} apples and ${bananas} bananas`;

Or

result = logMessage(`Error code ${err} occurred in routine ${rout}`);

Or

CALLP QCMDEXC( `WRKSPLF SELECT(${List(1).UserId})`: 200);

Under the covers, the RPG compiler would essentially convert it to something like this:

CALLP QCMDEXC( 'WRKSPLF SELECT('  + %trim(List(1).UserId) + ')': 200);

I'm thinking making it trim the spaces is a good default, too... it's what you want most of the time.

I realize that this doesn't really give us any new functionality -- we can do everything with concatenation already (or %ScanRpl) but this is the sort of coding that people do every day, and it would make it significantly more elegant, imho.   This is one of the things from JavaScript that I miss the most when I'm working in RPG.


On 10/20/2021 10:27 AM, Justin Taylor wrote:
Description:

Add string interpolation support so variables can be inserted into string
literals without having to use concatenation with + symbols and multiple
literals.

For example:

apples = 4

bananas = 3

print(f"I have {apples} apples and {bananas} bananas")


http://www.ibm.com/developerworks/rfe/execute?use_case=viewRfe&CR_ID=152890

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.