Difference between revisions of "Make Quoted String"

From MidrangeWiki
Jump to: navigation, search
(Summary)
 
(5 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
[[Category:Sample Code]]
 
[[Category:Sample Code]]
 
[[Category:Service Procedures]]
 
[[Category:Service Procedures]]
 +
__FORCETOC__
 
== Summary ==
 
== Summary ==
 
The following are the RPG/LE fully free-form definitions and instructions needed for using the {{AN}} service procedure.  This service procedure simply allows the caller to create a single-quoted string out of another character string that may or may not have embedded single quotes in it.
 
The following are the RPG/LE fully free-form definitions and instructions needed for using the {{AN}} service procedure.  This service procedure simply allows the caller to create a single-quoted string out of another character string that may or may not have embedded single quotes in it.
 
{| class="wikitable"
 
{| class="wikitable"
|+Rule of Thumb
+
|+ style="padding-left:6px;text-align:left;"|Rule of Thumb
 
|-
 
|-
 
|Sometimes, having a service procedure is simply a means of making code more self-documenting (i.e., easier for others to understand).
 
|Sometimes, having a service procedure is simply a means of making code more self-documenting (i.e., easier for others to understand).
 
|}
 
|}
  
== Service Procedure ==
+
By [[User:DaveLClarkI|Dave Clark]]
 +
 
 +
== Service Prototype ==
 +
Place the following in a separate copybook for inclusion in both the caller and the service program source members.
 
<pre>
 
<pre>
 
**free
 
**free
Line 20: Line 24:
 
   pString                        varchar(3000) const;
 
   pString                        varchar(3000) const;
 
end-pr;
 
end-pr;
 +
</pre>
 +
 +
== Service Procedure ==
 +
Place the following in a service program source member.
 +
<pre>
 +
**free
 +
ctl-opt NoMain AlwNull(*UsrCtl) Debug Option(*SrcStmt:*NoDebugIo)
 +
        DatFmt(*ISO) TimFmt(*ISO);
  
 
//==============================================================================
 
//==============================================================================

Latest revision as of 16:35, 17 December 2018


Summary

The following are the RPG/LE fully free-form definitions and instructions needed for using the Make Quoted String service procedure. This service procedure simply allows the caller to create a single-quoted string out of another character string that may or may not have embedded single quotes in it.

Rule of Thumb
Sometimes, having a service procedure is simply a means of making code more self-documenting (i.e., easier for others to understand).

By Dave Clark

Service Prototype

Place the following in a separate copybook for inclusion in both the caller and the service program source members.

**free

//==============================================================================
// This procedure returns the supplied string as a single-quoted string
// with any embedded single-quotes appropriately doubled.
//==============================================================================
dcl-pr GenUtl_MakeQuotedString    varchar(4096) rtnparm;
  pString                         varchar(3000) const;
end-pr;

Service Procedure

Place the following in a service program source member.

**free
ctl-opt NoMain AlwNull(*UsrCtl) Debug Option(*SrcStmt:*NoDebugIo)
        DatFmt(*ISO) TimFmt(*ISO);

//==============================================================================
// This procedure returns the supplied string as a single-quoted string
// with any embedded single-quotes appropriately doubled.
//==============================================================================
dcl-proc GenUtl_MakeQuotedString  export;
  dcl-pi *n                       varchar(4096) rtnparm;
    pString                       varchar(3000) const;
  end-pi;

  return ( ''''
         + GenUtl_ScanAndReplace('''': %trimr(pString): '''''')
         + '''' );                     // return resulting entry
end-proc;

References