|
On Mon, 1 Apr 2002, James Rich wrote: > > I want to use the C function toupper() in an RPG program. I'm not sure > what I need to code to allow me to use it. It is a little tricky because > toupper() expects ints as arguments and I don't think RPG will let me pass > a non-int as an argument. > True... RPG won't let you use an alphanumeric var as an int, you'll need to convert it. So, I'd just wrap the C toupper() in an RPG procedure that converts the data type for you. Here's an example that I whipped up (which works): H DFTACTGRP(*NO) ACTGRP(*NEW) BNDDIR('QC2LE') D toupper PR 1A D character 1A const D test1 S 10A D x S 10I 0 c eval test1 = 'fUnKy 123t' c for x = 1 to %len(test1) c eval %subst(test1:x:1) = c toupper(%subst(test1:x:1)) c endfor c dsply test1 c eval *inlr = *on *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * toupper() -- convert a character to uppercase (requires QC2LE) * * args: * character = character to convert to uppercase * * returns: * uppercase character *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ P toupper B export D toupper PI 1A D character 1A const d C_toupper PR 10I 0 ExtProc('toupper') d character 10I 0 value D dsCvt DS D dsCvtChar 1A D dsCvtInt 3U 0 overlay(dsCvtChar:1) c eval dsCvtChar = character c eval dsCvtInt = C_toupper(dsCvtInt) c return dsCvtChar P E
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 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.