This commit is contained in:
Ingy döt Net 2013-10-27 22:24:23 +00:00
parent 6f050a029e
commit 776bba907c
3887 changed files with 59894 additions and 7280 deletions

View file

@ -0,0 +1,30 @@
IDENTIFICATION DIVISION.
PROGRAM-ID. string-case-85.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 example PIC X(9) VALUE "alphaBETA".
01 result PIC X(9).
PROCEDURE DIVISION.
DISPLAY "Example: " example
*> Using the intrinsic functions.
DISPLAY "Lower-case: " FUNCTION LOWER-CASE(example)
DISPLAY "Upper-case: " FUNCTION UPPER-CASE(example)
*> Using INSPECT
MOVE example TO result
INSPECT result CONVERTING "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
TO "abcdefghijklmnopqrstuvwxyz"
DISPLAY "Lower-case: " result
MOVE example TO result
INSPECT result CONVERTING "abcdefghijklmnopqrstuvwxyz"
TO "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
DISPLAY "Upper-case: " result
GOBACK
.

View file

@ -0,0 +1,32 @@
IDENTIFICATION DIVISION.
PROGRAM-ID. string-case-extensions.
DATA DIVISION.
WORKING-STORAGE SECTION.
78 example VALUE "alphaBETA".
01 result PIC X(9).
PROCEDURE DIVISION.
DISPLAY "Example: " example
*> ACUCOBOL-GT
MOVE example TO result
CALL "C$TOLOWER" USING result, BY VALUE 9
DISPLAY "Lower-case: " result
MOVE example TO result
CALL "C$TOUPPER" USING result, BY VALUE 9
DISPLAY "Upper-case: " result
*> Visual COBOL
MOVE example TO result
CALL "CBL_TOLOWER" USING result, BY VALUE 9
DISPLAY "Lower-case: " result
MOVE example TO result
CALL "CBL_TOUPPER" USING result BY VALUE 9
DISPLAY "Upper-case: " result
GOBACK
.

View file

@ -0,0 +1,15 @@
MODULE AlphaBeta;
IMPORT StdLog,Strings;
PROCEDURE Do*;
VAR
str,res: ARRAY 128 OF CHAR;
BEGIN
str := "alphaBETA";
Strings.ToUpper(str,res);
StdLog.String("Uppercase:> ");StdLog.String(res);StdLog.Ln;
Strings.ToLower(str,res);
StdLog.String("Lowercase:> ");StdLog.String(res);StdLog.Ln
END Do;
END AlphaBeta.

View file

@ -1,7 +1,7 @@
import std.stdio, std.string;
void main() {
auto s = "alphaBETA";
writeln(s.toUpper());
writeln(s.toLower());
import std.stdio, std.string;
immutable s = "alphaBETA";
s.toUpper.writeln;
s.toLower.writeln;
}

View file

@ -0,0 +1 @@
=LOWER(A1)

View file

@ -0,0 +1 @@
=UPPER(A1)

View file

@ -0,0 +1 @@
alphaBETA alphabeta ALPHABETA

View file

@ -0,0 +1,2 @@
supcase('alphaBETA');
sdowncase('alphaBETA');

View file

@ -0,0 +1,7 @@
import strutils
var s: string = "alphaBETA_123"
echo s," as upper case: ", toUpper(s)
echo s," as lower case: ", toLower(s)
echo s," as Capitalized: ", capitalize(s)
echo s," as normal case: ", normalize(s) # remove underscores, toLower

View file

@ -0,0 +1,65 @@
// Uppercase and Lowercase functions for a minimal standard Pascal
// where no library routines for these operations exist
PROGRAM upperlower;
// convert a character to uppercase
FUNCTION uch(ch: CHAR): CHAR;
BEGIN
uch := ch;
IF ch IN ['a'..'z'] THEN
uch := chr(ord(ch) AND $5F);
END;
// convert a character to lowercase
FUNCTION lch(ch: CHAR): CHAR;
BEGIN
lch := ch;
IF ch IN ['A'..'Z'] THEN
lch := chr(ord(ch) OR $20);
END;
// toggle uper/lower case character
FUNCTION ulch(ch: CHAR): CHAR;
BEGIN
ulch := ch;
IF ch IN ['a'..'z'] THEN ulch := uch(ch);
IF ch IN ['A'..'Z'] THEN ulch := lch(ch);
END;
// convert a string to uppercase
FUNCTION ucase(str: STRING): STRING;
var i: Integer;
BEGIN
ucase := '';
FOR i := 1 TO Length(str) DO
ucase := ucase + uch(str[i]);
END;
// convert a string to lowercase
FUNCTION lcase(str: STRING): STRING;
var i: Integer;
BEGIN
lcase := '';
FOR i := 1 TO Length(str) DO
lcase := lcase + lch(str[i]);
END;
// reverse cases in a given string
FUNCTION ulcase(str: STRING): STRING;
var i: Integer;
BEGIN
ulcase := '';
FOR i := 1 TO Length(str) DO
ulcase := ulcase + ulch(str[i]);
END;
VAR
ab : STRING = 'alphaBETA';
BEGIN
// demonstration
Writeln('Original string : ',ab);
Writeln('Reversed case : ',ulcase(ab));
Writeln('Upper case : ',ucase(ab));
Writeln('Lower case : ',lcase(ab));
END.