As an astute comment pointed out, the code that I presented the other day for converting a currency string (like $1,234.56) to a real would have problems if the string represented an amount greater than one million. I was going to write that Priority has no STRPOS function; if it had one, then locating the commas and removing them would be simpler than my laborious code.
I have just discovered that whilst there is no STRPOS function, there is a function called STRINDEX that is more or less the same. So if there was a string like '$1,234,567.89', it could be turned into a string that can be turned into a real with the following code.
SUB 850; /* :ASTRING will be something like '$1,234,567.89'; */ :ASTRING = SUBSTR (:ASTRING, 2, 24); /* Lose the leading dollar */ :AREAL = ''; :RESULT = 0E9; :POS = 0; LABEL 851; SELECT STRINDEX (:ASTRING, ',', 1) INTO :POS FROM DUMMY; GOTO 852 WHERE :POS = 0; :AREAL = STRCAT (:AREAL, SUBSTR (:ASTRING, 1, :POS - 1)); :ASTRING = SUBSTR (:ASTRING, :POS + 1, 24); LOOP 851; LABEL 852; :AREAL = STRCAT (:AREAL, :ASTRING); :RESULT = ATOR (:AREAL); RETURN;
Note that the $ sign is liable to be converted into the procedure's name (see here). Fortunately, in my case, the currency sign is ₪ which is ignored by the preprocessor.
Now that I know about the existance of the function STRINDEX, I am liable to use it whenever necessary. I doubt that I am going to update existing code but I will use it in the future.
It turns out that STRINDEX exists only from version 21 onwards - and of course, the client who needs this code is running version 20.