Convert lowcase to upcase 
Author Message
 Convert lowcase to upcase

Are there any method to convert a lowcase character to a upcase
character (like upcase() in VB)?
I have an idea but I think it is not a good method:

EVALUATE WS-IN
  WHEN "a"
      MOVE "A" TO WS-IN
   ..........
  WHEN "z"
      MOVE "Z" TO WS-IN
END-EVALUATE.

Thanks



Wed, 20 Sep 2000 03:00:00 GMT  
 Convert lowcase to upcase

Quote:
You wrote...
>Are there any method to convert a lowcase character to a upcase
>character (like upcase() in VB)?
>I have an idea but I think it is not a good method:

>EVALUATE WS-IN
>  WHEN "a"
>      MOVE "A" TO WS-IN
>   ..........
>  WHEN "z"
>      MOVE "Z" TO WS-IN
>END-EVALUATE.

>Thanks

Hi, it depends on the compiler. I kno wwith MicroFocus, you can use the
intrinsic functions UPPER-CASE and LOWER-CASE. OTOH, you can just do an
inspect.

INSPECT FIELD
    CONVERTING "abcd..............z" TO
       "ABCD.........Z"

Good luck

Bosun


http://members.aol.com/bbello5778/bosun.htm
Programmer/Analyst. Bloomington, IL



Wed, 20 Sep 2000 03:00:00 GMT  
 Convert lowcase to upcase

Quote:

>You wrote...

>>Are there any method to convert a lowcase character to a upcase
>>character (like upcase() in VB)?
>>I have an idea but I think it is not a good method:

>>EVALUATE WS-IN
>>  WHEN "a"
>>      MOVE "A" TO WS-IN
>>   ..........
>>  WHEN "z"
>>      MOVE "Z" TO WS-IN
>>END-EVALUATE.

>>Thanks

>Hi, it depends on the compiler. I kno wwith MicroFocus, you can use the
>intrinsic functions UPPER-CASE and LOWER-CASE. OTOH, you can just do an
>inspect.

>INSPECT FIELD
>    CONVERTING "abcd..............z" TO
>       "ABCD.........Z"

This is a good method, and I use it.  But if your compiler has the 1989 FUNCTION
extensions to COBOL 85, you can also use FUNCTION UPPER-CASE:

    MOVE FUNCTION UPPER-CASE(field) TO field.
--
Judson McClendon          This is a faithful saying and worthy of all
Sun Valley Systems        acceptance, that Christ Jesus came into the

(please remove numbers from email id to respond)



Wed, 20 Sep 2000 03:00:00 GMT  
 Convert lowcase to upcase

Quote:

> Are there any method to convert a lowcase character to a upcase
> character (like upcase() in VB)?
> I have an idea but I think it is not a good method:

> EVALUATE WS-IN
>   WHEN "a"
>       MOVE "A" TO WS-IN
>    ..........
>   WHEN "z"
>       MOVE "Z" TO WS-IN
> END-EVALUATE.

> Thanks

First choice FUNCTION LOWER-CASE(MY-FIELD).
If your compiler doesn't support intrinsic functions this is a
reasonably efficient option.

 01  CHAR-X.
   05  CHAR-HEX         PIC 99 COMP.
 01  IDX                PIC 9(04) COMP.
 01  FILLER                     VALUE SPACE.
   05  SPACE-HEX        PIC 99 COMP.

* EBCDIC translation
    PERFORM VARYING IDX from 1 by 1 until IDX > length of MY-FIELD
        IF MY-FIELD (IDX:1) >= "a" AND MY-FIELD (IDX:1) <= "z"
             MOVE MY-FIELD (IDX:1) TO CHAR-X
             ADD SPACE-HEX TO CHAR-HEX
             MOVE CHAR-X TO MY-FIELD (IDX:1)
        END-IF
     END-PERFORM

* ASCII translation
    PERFORM VARYING IDX from 1 by 1 until IDX > length of MY-FIELD
        IF MY-FIELD (IDX:1) >= "a" AND MY-FIELD (IDX:1) <= "z"
             MOVE MY-FIELD (IDX:1) TO CHAR-X
             SUBTRACT SPACE-HEX FROM CHAR-HEX
             MOVE CHAR-X TO MY-FIELD (IDX:1)
        END-IF
     END-PERFORM

Karl Wagner

        ADD



Wed, 20 Sep 2000 03:00:00 GMT  
 Convert lowcase to upcase


Quote:
>Are there any method to convert a lowcase character to a upcase
>character (like upcase() in VB)?
>I have an idea but I think it is not a good method:

>EVALUATE WS-IN
>  WHEN "a"
>      MOVE "A" TO WS-IN
>   ..........
>  WHEN "z"
>      MOVE "Z" TO WS-IN
>END-EVALUATE.

>Thanks

What COBOL compiler are you using?  There are several ways to do this.
If you are using COBOL 74 or before, try looking up the EXAMINE verb.
If you are using 85 or beyond, look into the fuinctions (function
uppercase).

Dave




Thu, 21 Sep 2000 04:00:00 GMT  
 Convert lowcase to upcase


Quote:

>If your compiler doesn't support intrinsic functions this is a
>reasonably efficient option.

[sniped routine]

Care should be taken with looking at strings based on 1-byte character values.
These don't work if your text field contains DBCS/MBCS data. Stick to using
the intrinsic function if you can.

Shaun



Fri, 22 Sep 2000 03:00:00 GMT  
 Convert lowcase to upcase

Quote:

> Are there any method to convert a lowcase character to a upcase
> character (like upcase() in VB)?
> I have an idea but I think it is not a good method:

> EVALUATE WS-IN
>   WHEN "a"
>       MOVE "A" TO WS-IN
>    ..........
>   WHEN "z"
>       MOVE "Z" TO WS-IN
> END-EVALUATE.

I think you were using Micro Focus?  They have extensions to do it.
Try INSPECT .... CONVERTING...


Fri, 22 Sep 2000 03:00:00 GMT  
 Convert lowcase to upcase



Quote:

>> Are there any method to convert a lowcase character to a upcase
>> character (like upcase() in VB)?
>> I have an idea but I think it is not a good method:

[Method using EVALUATE snipped]

Quote:
>First choice FUNCTION LOWER-CASE(MY-FIELD).
>If your compiler doesn't support intrinsic functions this is a
>reasonably efficient option.

[snip]

>* EBCDIC translation
>    PERFORM VARYING IDX from 1 by 1 until IDX > length of MY-FIELD
>        IF MY-FIELD (IDX:1) >= "a" AND MY-FIELD (IDX:1) <= "z"

Considering that the alphabet, in EBCDIC, is three non-contiguous
ranges (C1 thru C9, D1 thru D9, E2 thru E9), this might not be such
a good idea. For example, "a" < CA < DF < ED < "z" but I think you
probably don't want to translate CA, DF, and ED if they appear in
your data.

Best to stick with INSPECT ... CONVERTING as others have suggested.



Fri, 22 Sep 2000 03:00:00 GMT  
 Convert lowcase to upcase

8<

Quote:
> Pardon my yellow card!

These are becoming a collectors item here in Holland. The Real Good Programmers
are immediately recogniseable: they still have such a card available in their
suitcase. (Some freaks even in their head).

Quote:
> The uppercase alphabet is C1-C9, D1-D9, and E2-E9.  The lower case alphabet
> starts at x'81'.  The 4's bit on the high order nibble determines case.

> 1000 0001 = "a"  1100 0001 = "A"

True for EBCDIC (only!)

Quote:
> If this were assembler, an OI could be used to change the case.

Which a smart function-writer participating in ibm-cobol-compiler-contruction
could very well be using

Quote:
> As far as a solution to this problem, Inspect Converting generates a TRT
> instruction, which is probably the most efficient solution.

Almost true on big blue. It's a TR, not TRT as far as I recall. TRT is used in
things like NUMERIC / ALPHABETIC. Very efficient in speed, costs a bit more
than 256 bytes for the table.

I would indeed recommend the inspect replacing/converting. On blues, it can be
translated to the TR, on other platforms, non-EBCDIC, other machine code etc,
the compiler will do the thinking/optimizing. A programmer in COBOL should say
*what* he wants ("inspect this and convert a's to A, b's to B ...) and now
*how* he wants it (get that byte, put it in a binary register, add such that
leftmost bit .. .. ..).

The Cobol Frog



Sat, 23 Sep 2000 03:00:00 GMT  
 Convert lowcase to upcase


Quote:

>> Pardon my yellow card!

>These are becoming a collectors item here in Holland. The Real Good Programmers
>are immediately recogniseable: they still have such a card available in their
>suitcase. (Some freaks even in their head).

You mean the IBM EBCDIC chart cards were yellow too?  Mine is a Burroughs card,
and it's yellow, dated April 1969.  I've still got my little blue plastic IBM
Flowcharting Template, FORM X20-8020, in the original paper sleeve, which I got
September 1968.  Does that make me a Real Good Programmer? ;-)
--
Judson McClendon          This is a faithful saying and worthy of all
Sun Valley Systems        acceptance, that Christ Jesus came into the

(please remove numbers from email id to respond)


Sat, 23 Sep 2000 03:00:00 GMT  
 Convert lowcase to upcase

Quote:

(snip)

> You mean the IBM EBCDIC chart cards were yellow too?  Mine is a Burroughs card,
> and it's yellow, dated April 1969.  I've still got my little blue plastic IBM
> Flowcharting Template, FORM X20-8020, in the original paper sleeve, which I got
> September 1968.  Does that make me a Real Good Programmer? ;-)

Certainly makes you a *real* programmer. 'Can't comment on the *good*
part:-)

Bill {*filter*}

Quote:
> --
> Judson McClendon          This is a faithful saying and worthy of all
> Sun Valley Systems        acceptance, that Christ Jesus came into the

> (please remove numbers from email id to respond)



Sat, 23 Sep 2000 03:00:00 GMT  
 Convert lowcase to upcase

Quote:



>> Considering that the alphabet, in EBCDIC, is three non-contiguous
>> ranges (C1 thru C9, D1 thru D9, E2 thru E9), this might not be such
>> a good idea. For example, "a" < CA < DF < ED < "z" but I think you
>((snip))

>Pardon my yellow card!

>The uppercase alphabet is C1-C9, D1-D9, and E2-E9.  The lower case
alphabet
>starts at x'81'.  The 4's bit on the high order nibble determines

case.

Oops. Excuse me while I wipe the egg off my face. I knew that.
That'll teach me to proofread my posts more carefully. But the
point I was trying to make is still valid: "a" < 8A < 9F < "z",
so testing if a character is between "a" and "z" may produce
unexpected results.



Sun, 24 Sep 2000 03:00:00 GMT  
 
 [ 21 post ]  Go to page: [1] [2]

 Relevant Pages 

1. upcase/downcase first character of a word

2. Keywords: UPCASE, downcase or Capitalized?

3. char-upcase settable?

4. Need help with assembler program - convert.asm - convert.asm (1/2)

5. Need help with assembler program - convert.asm - convert.asm (2/2)

6. symbols: upcase = downcase. WHY?

7. Question from a Tcl convert looking to convert a few DLL modules...

8. Converting Java to Smalltalk

9. Converting Dyalog APL Multiple Assignments to APL*PLUS

10. Converting Fortran77 to C

11. converting a windows api into dolphin code, eg ClipCursor

12. problems converting to tacit form

 

 
Powered by phpBB® Forum Software