Z
zhpwan
Unregistered / Unconfirmed
GUEST, unregistred user!
在一Procedure中声明一个类型为String变量
但在Case语句中对其赋值,但是编译时提示
Constant expression expected错误
请问为什么会发生此类错误?
源代码如下:
procedure TFrm_Stakelog.BB_ShwClick(Sender: TObject);
var
ls_title :string;
ls_log_sql : string;
.........
Begin
.........
case rg_log.ItemIndex of
0 :
ls_title := 'Prep';
{The Following statement is error :Constant expression expected}
ls_log_sql := 'select sum(cdrnum), sum(normcdrnum), sum(errcdrnum) from log_prep ';
li_series_count := 3;
1 :
ls_title := 'Charge';
{The Following statement is error :Constant expression expected}
ls_log_sql := 'select sum(cdrnum),sum(cr_cdrnum),'
+ 'sum(trashcdrnum),sum(errcdrnum) from log_rate';
li_series_count := 4;
2 :
ls_title := 'Settle';
{The Following statement is error :Constant expression expected}
ls_log_sql := 'select sum(cdrnum),sum(settcdrnum),sum(trashcdrnum),sum(errcdrnum) from log_settle';
li_series_count := 4;
end;
同样的操作ls_title 不会出现这类错误,而ls_log_sql 会出现。
为什么会这样?
但在Case语句中对其赋值,但是编译时提示
Constant expression expected错误
请问为什么会发生此类错误?
源代码如下:
procedure TFrm_Stakelog.BB_ShwClick(Sender: TObject);
var
ls_title :string;
ls_log_sql : string;
.........
Begin
.........
case rg_log.ItemIndex of
0 :
ls_title := 'Prep';
{The Following statement is error :Constant expression expected}
ls_log_sql := 'select sum(cdrnum), sum(normcdrnum), sum(errcdrnum) from log_prep ';
li_series_count := 3;
1 :
ls_title := 'Charge';
{The Following statement is error :Constant expression expected}
ls_log_sql := 'select sum(cdrnum),sum(cr_cdrnum),'
+ 'sum(trashcdrnum),sum(errcdrnum) from log_rate';
li_series_count := 4;
2 :
ls_title := 'Settle';
{The Following statement is error :Constant expression expected}
ls_log_sql := 'select sum(cdrnum),sum(settcdrnum),sum(trashcdrnum),sum(errcdrnum) from log_settle';
li_series_count := 4;
end;
同样的操作ls_title 不会出现这类错误,而ls_log_sql 会出现。
为什么会这样?