diff --git a/archive/a/algol60/capitalize.alg b/archive/a/algol60/capitalize.alg new file mode 100644 index 000000000..89edcf154 --- /dev/null +++ b/archive/a/algol60/capitalize.alg @@ -0,0 +1,95 @@ +begin + procedure usage; + begin + outstring(1, "Usage: please provide a string\n"); + stop + end usage; + + integer procedure inAsciiChar; + begin + integer ch; + + comment For some reason '%' needs to be represented as '\x25'; + inchar( + 0, + "\x01\x02\x03\x04\x05\x06\x07\x08\t\n\x0b\x0c\r\x0e\x0f" + "\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f" + " !\"#$\x25&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNO" + "PQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\x7f", + ch + ); + if ch >= 128 then ch := 0; + inAsciiChar := ch + end inAsciiChar; + + integer procedure inCharArray(s, maxLen); + value maxLen; + integer array s; + integer maxLen; + begin + integer len, ch; + + len := 0; + inloop: + ch := inAsciiChar; + if ch != 0 & len < maxLen then + begin + len := len + 1; + s[len] := ch; + goto inloop + end; + + inCharArray := len + end inCharArray; + + procedure outAsciiChar(ch); + value ch; + integer ch; + begin + comment For some reason '%' needs to be represented as '\x25'; + outchar( + 1, + "\x01\x02\x03\x04\x05\x06\x07\x08\t\n\x0b\x0c\r\x0e\x0f" + "\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f" + " !\"#$\x25&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNO" + "PQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\x7f", + ch + ) + end outAsciiChar; + + procedure outCharArray(s, len); + value len; + integer array s; + integer len; + begin + integer i; + for i := 1 step 1 until len do outAsciiChar(s[i]) + end outCharArray; + + procedure capitialize(s, len); + value len; + integer array s; + integer len; + begin + if len > 0 then + begin + comment a (97) ... z (122) -> A (65) ... Z (90); + if s[1] >= 97 & s[1] <= 122 then s[1] := s[1] - 32 + end + end capitialize; + + integer argc, len; + integer array s[1:256]; + + comment Get number of parameters. Exit if too few; + ininteger(0, argc); + if argc < 1 then usage; + + comment Get string as integer array. Exit if empty; + len := inCharArray(s, 256); + if len < 1 then usage; + + comment Capitialize first character and output string as integer array; + capitialize(s, len); + outCharArray(s, len) +end