Here is some basic string functions that might help start things off.
PROTOTYPES:
/IF NOT DEFINED(Utl_Toupper)
//===================================================================
//===================================================================
// @Name - Utl000_Toupper
// @Description - Convert string to upper cased text
// @Author - Matt Tyler
// @Usage - Newstring = Utl000_Toupper(String)
// @params -
// String........ any string up to 32767 in length
//===================================================================
//===================================================================
D Utl_Toupper PR 32767A VARYING
D String 32767A VARYING CONST
OPTIONS(*VARSIZE)
/DEFINE Utl_Toupper
/ENDIF
//
/IF NOT DEFINED(Utl_Tolower)
//===================================================================
//===================================================================
// @Name - Utl000_Tolower
// @Description - Convert string to lower cased text
// @Author - Matt Tyler
// @Usage - Newstring = Utl000_Tolower(String)
// @params -
// String........ any string up to 32767 in length
//===================================================================
//===================================================================
D Utl_Tolower PR 32767A VARYING
D String 32767A VARYING CONST
OPTIONS(*VARSIZE)
/DEFINE Utl_Tolower
/ENDIF
//
/IF NOT DEFINED(Utl_Tomixed)
//===================================================================
//===================================================================
// @Name - Utl000_Tomixed
// @Description - Convert string to mixed case text, first letter
// to upper case remaining to lower case of each
word.
// @Author - Matt Tyler
// @Usage - Newstring = Utl000_Tomixed(String)
// @params -
// String........ any string up to 32767 in length
//===================================================================
//===================================================================
D Utl_Tomixed PR 32767A VARYING
D String 32767A VARYING CONST
OPTIONS(*VARSIZE)
/DEFINE Utl_Tomixed
/ENDIF
FUNCTIONS:
//===================================================================
//===================================================================
* Procedure name: Utl_Toupper
//===================================================================
//===================================================================
P Utl_Toupper B EXPORT
D Utl_Toupper PI 32767A VARYING
D STRING 32767A VARYING CONST
OPTIONS(*VARSIZE)
D Newstring S 32767A VARYING
D UP C 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
D LO C 'abcdefghijklmnopqrstuvwxyz'
/Free
Newstring = %Xlate(LO :UP :String);
Return Newstring;
/End-free
P Utl_Toupper E
//===================================================================
//===================================================================
* Procedure name: Utl_Tolower
//===================================================================
//===================================================================
P Utl_Tolower B EXPORT
D Utl_Tolower PI 32767A VARYING
D String 32767A VARYING CONST
OPTIONS(*VARSIZE)
D* Local fields
D Newstring S 32767A VARYING
D UP C 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
D LO C 'abcdefghijklmnopqrstuvwxyz'
/Free
Newstring = %Xlate(UP :LO :String);
Return Newstring;
/End-free
P Utl_Tolower E
//===================================================================
//===================================================================
* Procedure name: Utl_Tomixed
//===================================================================
//===================================================================
P Utl_Tomixed B EXPORT
D Utl_Tomixed PI 32767A VARYING
D String 32767A VARYING CONST
OPTIONS(*VARSIZE)
D* Local fields
D Newstring S 32767A VARYING
D Pos S 10I 0
D Blankb4 S N
D UP C 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
D LO C 'abcdefghijklmnopqrstuvwxyz'
/Free
Newstring = String;
For Pos = 1 to %Len(String);
If %Subst(Newstring :Pos :1) <= x'40';
Blankb4 = *On;
Endif;
If %Subst(Newstring :Pos :1) > x'40' and
(Blankb4 or Not Blankb4 and Pos = 1);
Blankb4 = *Off;
%Subst(Newstring :Pos :1)
= %Xlate(LO :UP :%Subst(Newstring :Pos :1));
Else;
%Subst(Newstring :Pos :1)
= %Xlate(UP :LO :%Subst(Newstring :Pos :1));
Endif;
Endfor;
Return Newstring;
/End-free
P Utl_Tomixed E
Thanks, Matt
-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx
[mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Shannon ODonnell
Sent: Wednesday, February 08, 2012 1:20 PM
To: 'RPG programming on the IBM i / System i'
Subject: RE: Camel Case
Yeah...I'd prefer a solution that does it both ways but anything is
better
than nothing on this.
-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx
[mailto:rpg400-l-bounces@xxxxxxxxxxxx]
On Behalf Of Mike Wills
Sent: Wednesday, February 08, 2012 2:10 PM
To: RPG programming on the IBM i / System i
Subject: Re: Camel Case
I remember this conversation has happened many times before. It all came
down to questions like (McCarthy or Mccarthy?). It looks like you are
okay
with capitalizing just every first letter. Is that a correct
presumption?
--
Mike Wills
http://mikewills.me
On Wed, Feb 8, 2012 at 12:19 PM, Shannon ODonnell <
sodonnell@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
Hi,
Does anyone have a routine already written for RPG they would want to
share that does Camel Case/Proper Name on names?
That is:
SHANNON O'DONNELL
Becomes
Shannon O'Donnell
Or even this would be acceptable:
Shannon O'donnell
I can write this but thought I'd ask first if someone has already done
this, to save some time.
Thanks!
--
This is the RPG programming on the IBM i / System i (RPG400-L) mailing
list To post a message email: RPG400-L@xxxxxxxxxxxx To subscribe,
unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx Before posting, please take a
moment to review the archives at http://archive.midrange.com/rpg400-l.
--
This is the RPG programming on the IBM i / System i (RPG400-L) mailing
list
To post a message email: RPG400-L@xxxxxxxxxxxx To subscribe,
unsubscribe, or
change list options,
visit:
http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives at
http://archive.midrange.com/rpg400-l.
As an Amazon Associate we earn from qualifying purchases.