Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 2 of 2 total
Thread Why do some functions only accept a contant expression and not a variable?
Fri, Jan 31 2014 6:20 PMPermanent Link

Barry

Why do some functions like Trim() and QuotedStr() only accept a constant expression for <CharacterExpression>?

Example:

SCRIPT
BEGIN

Declare _Str VarChar(100) Default 'ABC,';
Declare _Char Char Default ',';

set _Str = Trim(Trailing _Char from _Str);

END

The Trim() function produces a syntax error:
"ElevateDB Error #700 An error was found in the script at line 7 and column 26 (Expected constant value expression but instead found _Char)"

But the function in the manual says:
"TRIM(LEADING|TRAILING|BOTH <CharacterExpression> FROM <StringExpression>)"

1) So why can't <CharacterExpression> be a Char variable? Why does it have to be a constant?
A <StringExpression> can be a variable, why not <CharacterExpression>?

Same with:
set _Str = QuotedStr(_Str, _Char);
It produces the same error:
"ElevateDB Error #700 An error was found in the script at line 7 and column 28 (Expected constant value expression but instead found _Char)"

2) I don't see why these functions are using "<CharacterExpression>". Why limit these 2 functions to a single Character when a <StringExpression> will work just as well. Maybe I want a string quoted with '\"' or a string trimmed of "//" from the start of the string.

Barry
Mon, Feb 3 2014 7:34 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Barry,

<< Why do some functions like Trim() and QuotedStr() only accept a constant
expression for <CharacterExpression>?  >>

Just an oversight.  I'll have a fix for this in the next build.

<< 2) I don't see why these functions are using "<CharacterExpression>". Why
limit these 2 functions to a single Character when a <StringExpression> will
work just as well. Maybe I want a string quoted with '\"' or a string
trimmed of "//" from the start of the string. >>

These functions only work with characters at this time.  This is an engine
design, so I'll have to rewrite them to handle strings instead, so this
won't be in the the next immediate build.

Tim Young
Elevate Software
www.elevatesoft.com
Image