midrange.com code scratchpad
Name:
Characters: Prototypes and Example Calls
Scriptlanguage:
Plain Text
Tabwidth:
4
Date:
08/20/2014 06:46:35 pm
IP:
Logged
Description:
The user was to lazy to give a description
Code:
  1.        //=======================================================================
  2.        //     ___ _         ___         _          _____ _    _
  3.        //    / __| |_  _ _ / __|___ _ _| |_ ___ _ |_   _| |_ (_)___
  4.        //   | (__| ' \| '_| (__/ -_) ' \  _/ -_) '_|| | | ' \| (_-<
  5.        //    \___|_||_|_|  \___\___|_||_\__\___|_|  |_| |_||_|_/__/
  6.        //
  7.        //Center text into a field given it's length and contents.
  8.        //
  9.        // Example:
  10.        //  myString = ChrCenterThis(myString);
  11.        //=======================================================================
  12.      DChrCenterThis    PR         32740A   Varying
  13.      D InputStr                   32740A   Const Varying
  14.  
  15.  
  16.        //=======================================================================
  17.        //     ___ _         ___     _   ___            _ _
  18.        //    / __| |_  _ _ / __|___| |_| __|_ __  __ _(_) |
  19.        //   | (__| ' \| '_| (_ / -_)  _| _|| '  \/ _` | | |
  20.        //    \___|_||_|_|  \___\___|\__|___|_|_|_\__,_|_|_|
  21.        //
  22.        //Get email address for any purpose.
  23.        //
  24.        // Examples:
  25.        //  myEmail = ChrGetEmail;
  26.        //  myEmail = ChrGetEmail(myPgm);
  27.        //  myEmail = ChrGetEmail(myPgm:myTitle:'Please Enter Email');
  28.        //  myEmail = ChrGetEmail(myPgm:myTitle:myMsg1:myMsg2:myError);
  29.        //=======================================================================
  30.      DChrGetEmail      PR           100A   Varying
  31.      D PgmName                       10A   Const Options(*NoPass)
  32.      D Title                         40A   Const Options(*NoPass)
  33.      D Msg1                          66A   Const Options(*NoPass)
  34.      D Msg2                          66A   Const Options(*NoPass)
  35.      D Error                         65A   Const Options(*NoPass)
  36.  
  37.  
  38.        //=======================================================================
  39.        //     ___ _         ___     _   ___     _
  40.        //    / __| |_  _ _ / __|___| |_| __|_ _| |_
  41.        //   | (__| ' \| '_| (_ / -_)  _| _|\ \ /  _|
  42.        //    \___|_||_|_|  \___\___|\__|___/_\_\\__|
  43.        //
  44.        //Get extension of a file given it's complete name.
  45.        //
  46.        // Example:
  47.        //  MyExt = ChrGetExt(myString);
  48.        //=======================================================================
  49.      DChrGetExt        PR         32740A   Varying
  50.      D InputStr                   32740A   Const Varying
  51.  
  52.  
  53.        //=======================================================================
  54.        //     ___ _         ___     _   _
  55.        //    / __| |_  _ _ / __|___| |_| |   _____ __ _____ _ _
  56.        //   | (__| ' \| '_| (_ / -_)  _| |__/ _ \ V  V / -_) '_|
  57.        //    \___|_||_|_|  \___\___|\__|____\___/\_/\_/\___|_|
  58.        //
  59.        //Convert Input to Lower Case.
  60.        //
  61.        // Example:
  62.        //  myString = ChrGetLower(myString);
  63.        //=======================================================================
  64.      DChrGetLower      PR         32740A   Varying
  65.      D InputStr                   32740A   Const Varying
  66.  
  67.  
  68.        //=======================================================================
  69.        //     ___ _         ___     _   _   _
  70.        //    / __| |_  _ _ / __|___| |_| | | |_ __ _ __  ___ _ _
  71.        //   | (__| ' \| '_| (_ / -_)  _| |_| | '_ \ '_ \/ -_) '_|
  72.        //    \___|_||_|_|  \___\___|\__|\___/| .__/ .__/\___|_|
  73.        //                                    |_|  |_|
  74.        //Convert Input to Upper Case.
  75.        //
  76.        // Example:
  77.        //  myString = ChrGetUpper(myString);
  78.        //=======================================================================
  79.      DChrGetUpper      PR         32740A   Varying
  80.      D InputStr                   32740A   Const Varying
  81.  
  82.  
  83.        //=======================================================================
  84.        //     ___ _       ___ ___ ___
  85.        //    / __| |_  _ |_ _|_ _| __|
  86.        //   | (__| ' \| '_| | | || _|
  87.        //    \___|_||_|_||___|___|_|
  88.        //
  89.        //Allow for single line comparisons, fill field depending on result.
  90.        //
  91.        // Layout:
  92.        //  CharField = ChrIIF(Condition : IfTrue : IfFalse)
  93.        // Examples:
  94.        //  ErrorYN = ChrIIF(myNumber >= 1 : 'Y' : 'N')
  95.        //  Output = ChrIIF(myString = *blanks : 'Generic' : Input)
  96.        //
  97.        // Note:
  98.        //  This function only allows char result field.  RPGLE has similar
  99.        //    ability for indicators already built in.
  100.        //
  101.        //   Layout:
  102.        //      *indicator = (Condition)
  103.        //   Example:
  104.        //      *in25 = (Error >= 1);
  105.        //   (If Condition is true, indicator = *On, otherwise = *Off)
  106.        //=======================================================================
  107.      DChrIIF           PR         32740A   Varying
  108.      D Condition                       N           Value
  109.      D True                       32740A   Varying Value
  110.      D False                      32740A   Varying Value
  111.  
  112.  
  113.        //=======================================================================
  114.        //     ___ _       ___
  115.        //    / __| |_  _ |_ _|_ _
  116.        //   | (__| ' \| '_| || ' \
  117.        //    \___|_||_|_||___|_||_|
  118.        //
  119.        //Allow for Single Line "=" Comparison, True if Input IN Any Matches (Up
  120.        // to 20 Matches)
  121.        //
  122.        // Layout:
  123.        //  If ChrIn(myString:myMatch1:myMatch2:myMatch3:etc...);
  124.        //    //Do Something
  125.        //  EndIf;
  126.        //
  127.        // Example:
  128.        //  If ChrIn(myString:'String':'Yarn':'Thread':otherString);
  129.        //
  130.        //  EndIf;
  131.        //=======================================================================
  132.      DChrIn            PR              N
  133.      D Input                      32740A   Const Varying
  134.      D Match1                     32740A   Const Varying
  135.      D Match2                     32740A   Const Varying
  136.      D Match3                     32740A   Const Varying Options(*NoPass)
  137.      D Match4                     32740A   Const Varying Options(*NoPass)
  138.      D Match5                     32740A   Const Varying Options(*NoPass)
  139.      D Match6                     32740A   Const Varying Options(*NoPass)
  140.      D Match7                     32740A   Const Varying Options(*NoPass)
  141.      D Match8                     32740A   Const Varying Options(*NoPass)
  142.      D Match9                     32740A   Const Varying Options(*NoPass)
  143.      D Match10                    32740A   Const Varying Options(*NoPass)
  144.      D Match11                    32740A   Const Varying Options(*NoPass)
  145.      D Match12                    32740A   Const Varying Options(*NoPass)
  146.      D Match13                    32740A   Const Varying Options(*NoPass)
  147.      D Match14                    32740A   Const Varying Options(*NoPass)
  148.      D Match15                    32740A   Const Varying Options(*NoPass)
  149.      D Match16                    32740A   Const Varying Options(*NoPass)
  150.      D Match17                    32740A   Const Varying Options(*NoPass)
  151.      D Match18                    32740A   Const Varying Options(*NoPass)
  152.      D Match19                    32740A   Const Varying Options(*NoPass)
  153.      D Match20                    32740A   Const Varying Options(*NoPass)
  154.  
  155.  
  156.        //=======================================================================
  157.        //     ___ _        ___ _____ _    _     _
  158.        //    / __| |_  _ _| _ \_   _(_)__| |__ / |
  159.        //   | (__| ' \| '_|   / | | | / _| / / | |
  160.        //    \___|_||_|_| |_|_\ |_| |_\__|_\_\ |_|
  161.        //
  162.        //Replace apostrophe (') with grave accent (`) for SQL and CL commands
  163.        // (Usually used for reports)  1 to 1 replacement, so no characters will
  164.        //  be lost in the conversion.  NOT usable when wanting to search by
  165.        //  field that includes an apostrophe (i.e. A filter that searches by
  166.        //  name based on an input that includes apostrophes).  To perform that
  167.        //  type of replacement, see ChrRTick2 (and note it's limitations).
  168.        //
  169.        // Example:
  170.        //  myString = ChrRTick1(myString);
  171.        //=======================================================================
  172.      DChrRTick1        PR         32740A   Varying
  173.      D InputStr                   32740A   Const Varying
  174.  
  175.  
  176.        //=======================================================================
  177.        //     ___ _        ___ _____ _    _     ___
  178.        //    / __| |_  _ _| _ \_   _(_)__| |__ |_  )
  179.        //   | (__| ' \| '_|   / | | | / _| / /  / /
  180.        //    \___|_||_|_| |_|_\ |_| |_\__|_\_\ /___|
  181.        //
  182.        //Replace apostrophe (') with 2 apostrophes ('') for SQL and CL commands
  183.        // (Usually used for searches based on field that includes apostrophes)
  184.        // 1 to 2 replacement, so a field with all positions filled will start
  185.        // to drop off the last characters during the conversion (more will drop
  186.        // depending on the number of apostrophes in the string being searched).
  187.        // NOT useful for reports, due to the varying length of the field.
  188.        //
  189.        // Example:
  190.        //  myString = ChrRTick2(myString);
  191.        //=======================================================================
  192.      DChrRTick2        PR         32740A   Varying
  193.      D InputStr                   32740A   Const Varying
  194.  
  195.  
  196.        //=======================================================================
  197.        //     ___ _        ___               ___      _
  198.        //    / __| |_  _ _/ __| __ __ _ _ _ | _ \_ __| |
  199.        //   | (__| ' \| '_\__ \/ _/ _` | ' \|   / '_ \ |
  200.        //    \___|_||_|_| |___/\__\__,_|_||_|_|_\ .__/_|
  201.        //                                       |_|
  202.        //Our version of %scanrpl - Scan for original character(s) and replace
  203.        // with replacement character(s).  The original and replacement strings
  204.        // ARE case sensitive.
  205.        //
  206.        // Examples:
  207.        //  myString = ChrScanRpl(myString:'*':' ');
  208.        //  myString = ChrScanRpl(myString:'1':'One');
  209.        //  myString = ChrScanRpl(myString:'One':'1');
  210.        //=======================================================================
  211.      DChrScanRpl       PR         32740A   Varying
  212.      D InputStr                   32740A   Const Varying
  213.      D Orig                       32740A   Const Varying
  214.      D Rpl                        32740A   Const Varying
  215.  
  216.  
  217.        //=======================================================================
  218.        //     ___ _      __   __    _ ___            _ _
  219.        //    / __| |_  _ \ \ / /_ _| | __|_ __  __ _(_) |
  220.        //   | (__| ' \| '_\ V / _` | | _|| '  \/ _` | | |
  221.        //    \___|_||_|_|  \_/\__,_|_|___|_|_|_\__,_|_|_|
  222.        //
  223.        //Determine if email address is valid - 'Y' = Valid, 'N' = Not Valid.
  224.        //
  225.        // *** RETURN **********************************************************
  226.        // *On or *Off (True or False)
  227.        // *********************************************************************
  228.        //
  229.        // Examples:
  230.        //  If ChrValEmail(myEmail);
  231.        //    ExSr @SendEmail;
  232.        //  Else;
  233.        //    myError = 'Sorry, that is an invalid email address';
  234.        //    Iter;
  235.        //  EndIf;
  236.        //
  237.        // -Could also check if NOT true-
  238.        //  If Not ChrValEmail(myEmail);
  239.        //    myError = 'Sorry, that is an invalid email address';
  240.        //    Iter;
  241.        //  EndIf;
  242.        //=======================================================================
  243.      DChrValEmail      PR              N
  244.      D Email                        100A   Const Varying 
© 2004-2019 by midrange.com generated in 0.008s valid xhtml & css