Difference between revisions of "Parse Decimal"
From MidrangeWiki
DaveLClarkI (talk | contribs) (Created page with "Category:Sample Code Category:Service Procedures __FORCETOC__ == Summary == The following are the RPG/LE fully free-form definitions and instructions needed for using...") |
DaveLClarkI (talk | contribs) (→Summary) |
||
Line 4: | Line 4: | ||
== 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 extract a decimal value that is embedded in a character string with other (alpha) data. | 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 extract a decimal value that is embedded in a character string with other (alpha) data. | ||
+ | |||
+ | By [[User:DaveLClarkI|Dave Clark]] | ||
== Service Prototype == | == Service Prototype == |
Latest revision as of 16:09, 17 December 2018
Summary
The following are the RPG/LE fully free-form definitions and instructions needed for using the Parse Decimal service procedure. This service procedure simply allows the caller to extract a decimal value that is embedded in a character string with other (alpha) data.
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 parses the first blank-delimited "word" of a character string // into a decimal format as a return result. If the first "word" cannot be // parsed into a decimal format then the caller must monitor for the exception // which will occur as a result. //****************************************************************************** dcl-pr GenUtl_parseDecimal packed(31:9); pString varchar(40) value; 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 parses the first blank-delimited "word" of a character string // into a decimal format as a return result. If the first "word" cannot be // parsed into a decimal format then the caller must monitor for the exception // which will occur as a result. //****************************************************************************** dcl-proc GenUtl_parseDecimal export; dcl-pi *n packed(31:9); pString varchar(40) value; end-pi; dcl-s pos packed(3:0); pString = %trim(pString) + ' '; // trim off all but one blank pos = %scan(' ': pString); // find first blank in string return %dec(GenUtl_LeftString(pString:pos):31:9); // return parsed value end-proc;
References
- GenUtl_LeftString service procedure