From: Steve Wright [usenet@wrightnet.demon.co.uk] Sent: Wednesday, January 30, 2002 6:21 PM To: Info-VAX@Mvb.Saic.Com Subject: Re: STR$lowercase ? In message , danco@pebble.org writes >In article <3C55B3D5.5F431CAB@UIowa.EDU>, Rick Dyson wrote: > >>> In the past I've used calls to BAS$EDIT, IIRC. There was an old > > >Umm, but BAS$EDIT doesn't have "uppercase to lowercase" functionality, >does it? I don't see it in any case. :-) > > >EDIT$ > > Syntax > > > str-var = EDIT$(str-exp, int-exp) > > Values Effect > > 1% Trim parity bits > 2% Discard all spaces and tabs > 4% Discard characters: CR, LF,FF, ESC, RUBOUT, and NULL > 8% Discard leading spaces and tabs > 16% Reduce spaces and tabs to one space > 32% Convert lowercase to uppercase > 64% Convert [ to ( and ] to ) > 128% Discard trailing spaces and tabs > 256% Do not alter characters inside quotes > >- Dan I don't know the name of the library routine, but when we wanted to do something similar in DEC-BASIC, we used the XLATE function. From the on-line VMS manual ================== START OF CUT & PASTE =============================== XLATE$ The XLATE$ function translates one string to another by referencing a table string you supply. ----------------------------------------------------------------------- Format Str-result = xlate (Str-exp1, Str-exp2) ------------------------------------------------------------------------ ----------------------------------------------------------------------- Syntax Rules Str-exp1 is the input string. Str-exp2 is the table string. ----------------------------------------------------------------------- Remarks Str-exp2 can contain up to 256 ASCII characters, numbered from 0 to 255; the position of each character in the string corresponds to an ASCII value. Because 0 is a valid ASCII value (null), the first position in the table string is position zero. XLATE$ scans str-exp1 character by character, from left to right. It finds the ASCII value n of the first character in str-exp1 and extracts the character it finds at position n in str-exp2. XLATE$ then appends the character from str-exp2 to str-var. XLATE$ continues this process, character by character, until the end of str-exp1 is reached. The output string may be smaller than the input string for the following reasons: XLATE$ does not translate nulls. If the character at position n in str-exp2 is a null, XLATE$ does not append that character to str-var. If the ASCII value of the input character is outside the range of positions in str-exp2, XLATE$ does not append any character to str-var. ------------------------------------------------------------------------ Example DECLARE STRING A, table, source A = "abcdefghijklmnopqrstuvwxyz" table = STRING$(65, 0) + A LINPUT " Type a string of uppercase letters"; source PRINT XLATE$(source, table) Output Type a string of uppercase letters? ABCDEFG abcdefg ================== END OF CUT & PASTE ================================== Well look at that... the example in the manual shows how to convert uppercase to lowercase, although it does strip any non uppercase characters :-( Better to do something like TABLE = "" FOR I = 0% TO ASCII ("A") - 1% TABLE = TABLE + CHR$ (I) NEXT I TABLE = TABLE + "abcdefghijklmnopqrstuvwxyz" FOR I = ASCII ("Z") + 1% TO 255% TABLE = TABLE + CHR$ (I) NEXT I to set up the table. That way, any non uppercase characters are preserved. -- Steve Wright