Ascii

lord_icon

Member
Greetings,

I know how to use the ASCII function using BASIC (pants language I know)
It is a long time since I used this is the 4GL. How do I check a string using the 4GL / ABL - Open Edge 10 ??
TIA
 

RealHeavyDude

Well-Known Member
When you just want to know the ASCII number for a specific character then the ASC ( ) function is what you are looking for.

If you want to check a string for illegal characters then it's a completely different story depending on the code page and character set you are using and what you define as illegal.

Regards, RealHeavyDude.
 

lord_icon

Member
Thanks.
I am trying to compare strings for differences.
I were / am, unsure how to use the ASC function. The online help didnt return what I was looking for. I have a vague idea of how to use the function. To enable a workaround.
 

dunno

New Member
Why you need the ASC() function to compare 2 string for differences?
You can do it like this:

Code:
DEFINE VARIABLE vc1 AS CHARACTER INITIAL "Aacb" CASE-SENSITIVE NO-UNDO.
DEFINE VARIABLE vc2 AS CHARACTER INITIAL "aabc" CASE-SENSITIVE NO-UNDO.
DEFINE VARIABLE viCnt AS INTEGER     NO-UNDO.

DO viCnt = 1 TO LENGTH(vc1):
  IF SUBSTRING(vc1, viCnt, 1) <> SUBSTRING(vc2, viCnt, 1) THEN
    MESSAGE "Difference at position " + STRING(viCnt) + " " + SUBSTRING(vc1, viCnt, 1) + " and " + SUBSTRING(vc2, viCnt, 1).
END.
 
Top