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



Well said, Mark; If we get there, it would be sweeet!
Hopefully the team in Rochester is able to respond.




"Mark Murphy/STAR BASE Consulting Inc." <mmurphy@xxxxxxxxxxxxxxx>
Sent by: rpg400-l-bounces@xxxxxxxxxxxx
01/20/2011 10:22 AM
Please respond to
RPG programming on the IBM i / System i <rpg400-l@xxxxxxxxxxxx>


To
RPG programming on the IBM i / System i <rpg400-l@xxxxxxxxxxxx>
cc

Subject
RE: HereDoc






The goal is to put a fully formed SQL statement in the source in context
so that it can be easily read and understood in that context rather than
shuffled off to some other location where I would have to go and find it
while going through the code. A list of all the SQL statements used in
the program placed in a compile time array does not achieve that goal. The

quoted string does a better job, just not very prettily. I have a
workaround to the lack of HereDoc support, it just isn't very pretty. I
guess that this is all it is about.

Mark Murphy
STAR BASE Consulting, Inc.
mmurphy@xxxxxxxxxxxxxxx



From: "jmckay@xxxxxxxxxxxxxxxx" <jmckay@xxxxxxxxxxxxxxxx>
To: rpg400-l@xxxxxxxxxxxx
Date: 01/20/2011 11:48 AM
Subject: RE: HereDoc
Sent by: rpg400-l-bounces@xxxxxxxxxxxx



My own suggestion ...

updateStmt = inStmt("V2020Z");

where inStmt is a subprocedure that builds the string with all those
quotes &c.

Regards,
John McKay mba
www.mckaysoftware.ie
www.rpglanguage.com

Original Message:
-----------------
From: Morgan, Paul Paul.Morgan@xxxxxxxxxxx
Date: Thu, 20 Jan 2011 11:14:36 -0500
To: rpg400-l@xxxxxxxxxxxx
Subject: RE: HereDoc


Mark,

Have you considered a compile time array or INZ on a variable to get
around
coding the SQL statement directly in the calculations? You'd have
different syntax because of the different position of the text in the
program.

Paul

Principal Programmer Analyst
IT Supply Chain/Replenishment


-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx]
On Behalf Of Mark Murphy/STAR BASE Consulting Inc.
Sent: Thursday, January 20, 2011 9:46 AM
To: RPG programming on the IBM i/System i
Subject: HereDoc

Some time ago I learned PHP, and was introduced to a concept called
HereDoc. Essentially a way to insert a string inline. Didn't really see
the use of it, and never really thought about it much until now. I have a


piece of code where it would be highly useful for improving the
readability of my program. Unfortunately The use is in an RPG program,
and the feature does not exist there.

Anyway here is what I was thinking. I am using dynamic SQL in a
particular program (so that I can use set schema to direct unqualified
references to the environment of my choice). Some of the SQL commands are


quite complex, and I have to double quotes in my string literals. the
whole thing degenerates into a bunch of extra quotes and continuation
marks that would not be necessary with a HereDoc.

Consider the following (very simple, but serves to make the point):

updateStmt =
'Update MCPSRV Set SESCLS=''O'', ' +
' semdat = Date_As_Cymd(Current_Date), ' +
' semtim = time_As_Hms(Current_Time), seuser = user, ' +
' sempgm = ''SQL'' ' +
'Where SEICD9=''V2020Z''';

With a HereDoc I could write something like:

updateStmt = <<<DOC
Update MCPSRV Set SESCLS='O',
semdat = Date_As_Cymd(Current_Date),
semtim = time_As_Hms(Current_Time), seuser = user,
sempgm = 'SQL'
Where SEICD9='V2020Z'
<<<DOC

Even with a simple example the lack of superfluous quotes and continuation


marks makes the second far more readable than the first.

Any thoughts?

Mark Murphy
STAR BASE Consulting, Inc.
mmurphy@xxxxxxxxxxxxxxx

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.