ASC ( expression, target-codepage , source-codepage )An expression with a value of a single character that you want to convert to an ASCII (or internal code page) integer value. If expression is a constant, you must enclose it in quotation marks (" "). If the value of expression is other than a single character, ASC returns the value -1.The values for expression are case sensitive. For example, ASC("a") returns a different value than ASC("A").A character-string expression that evaluates to the name of a code page. The name that you specify must be a valid code page name available in the OpenEdge-install-dir/convmap.cp file (a binary file that contains all of the tables that ABL uses for character management). If you supply a non-valid name, the ASC function returns the value -1 and returns a runtime error. Before returning an integer value, the ASC function converts expression from source-codepage to target-codepage. The returned integer value is relative to target-codepage. If you do not specify target-codepage, the value returned is the code page identified with the Internal Code Page (-cpinternal) parameter.A character-string expression that evaluates to the name of a code page. The name that you specify must be a valid code page name available in the OpenEdge-install-dir/convmap.cp file. If you supply a non-valid name, the ASC function returns the value -1. The source-codepage specifies the name of the code page to which expression is relative. The default value of source-codepage is the code page identified with the Internal Code Page (-cpinternal) parameter.
DEFINE VARIABLE ix AS INTEGER NO-UNDO.DEFINE VARIABLE jx AS INTEGER NO-UNDO.DEFINE VARIABLE ltrl AS INTEGER NO-UNDO EXTENT 27.FOR EACH Customer NO-LOCK:ix = ASC(SUBSTRING(Customer.Name,1,1)).IF ix < ASC("A") or ix > ASC("Z") THEN ix = EXTENT(ltrl).ELSE ix = ix - ASC("A") + 1.ltrl[ix] = ltrl[ix] + 1.END.DO jx = 1 TO EXTENT(ltrl) WITH NO-LABELS USE-TEXT:IF jx <= 26 THENDISPLAY CHR(ASC("A") + jx - 1) @ ltr-name AS CHARACTER FORMAT "x(5)".ELSEDISPLAY "Other" @ ltr-name.DISPLAY ltrl[jx].END.
The ASC function is both double-byte and Unicode enabled. If the expression argument yields a double-byte character or multi-byte Unicode character in the target code page, this function can return a value greater than 255.
© 2013 Progress Software Corporation and/or its subsidiaries or affiliates. |