PDA

View Full Version : Bug in Lastword() function


ABC123

michaelklein
09-23-2014, 02:01 PM
Hey folks,

I've found an interesting bug in the Lastword() function while trying to parse a database containing liquor descriptions. When attempting to retrieve a product size from a fieldname or variable which contains a decimal point, say 1.75L, Lastword() will only return 75L. However, if you go to the Interactive tab of the Code Editor and use a literal enclosed in quotes as the parameter to Lastword() and add " " as the 2nd parameter, it returns 1.75L as it should.

Any ideas how to get around this when trying to perform an Update Operation on an Alpha table?

Thanks.
--Michael

Stan Mathews
09-23-2014, 02:09 PM
Same behavior in V11. Can you not use the delimiter specification in your update operation?

Note: The same pecularity exists when using word().

? word("this is 1.75L",-1)
= "75L"
? word("this is 1.75L",-1," ")
= "1.75L"

Al Buchholz
09-23-2014, 03:53 PM
Hey folks,

When attempting to retrieve a product size from a fieldname or variable which contains a decimal point, say 1.75L, Lastword() will only return 75L.

Michael

What I read confuses me if you are using a fieldname or the value in a field.

Same with the variable concept.

Please post an image of your update operation or the xbasic that is generated from it.

WokingJon
09-24-2014, 02:45 AM
Michael,

Doesn't look like a bug to me. AA is treating the '.' as a delimiter, the same as it does a ',' ';' or any other punctuation.

Would it not be more appropriate in this case to store the product size in a separate field (or even two - one for quantity and one for units of measurement) so that you can perform calculations or sorts?

Stan Mathews
09-24-2014, 08:12 AM
So why would Alpha treat the period as a delimiter when the default is " " (a space) and why would specifying a space as the delimiter yield different results than accepting the default?


Delimiter
Optional. Default = " ". The delimiter that separates the words or entries.

Al Buchholz
09-24-2014, 09:43 AM
So why would Alpha treat the period as a delimiter when the default is " " (a space) and why would specifying a space as the delimiter yield different results than accepting the default?

Regardless of the docs, I've found that the 'word' functions default to most special characters as a delimiter of each word. Hence a period delimits an end of sentence and start of a new word.

WokingJon
09-25-2014, 02:11 AM
If you think of this logically ALL non alpha-numerics SHOULD be treated as delimiters for a function that operates on words (some would argue that all non alpha characters should be). The only exceptions I can think of are the apostrophe and the hyphen, both of which are 'correctly' managed by Alpha.