Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2003.11.27;
Скачать: CL | DM;

Вниз

IntToStr и Const   Найти похожие ветки 

 
Sandman25 ©   (2003-11-18 13:48) [0]

Почему компилятор ругается
"Constant expression expected"
на конструкцию
const
TreeType = 20;
sSelect = "select * from table where tree_type = " + IntToStr(TreeType);
Разве IntToStr(const) не есть константное выражение?
Может есть какая-то другая функция?
+ Chr(Ord("0") + TreeType div 10)
+ Chr(Ord("0") + TreeType mod 10)
берет, но тут жесткая привязка к двузначности, да и просто некрасиво.
Писать
+ Chr(Ord("0") + (TreeType div 100000) mod 10)
+ Chr(Ord("0") + (TreeType div 10000) mod 10)
+ Chr(Ord("0") + (TreeType div 1000) mod 10)
+ Chr(Ord("0") + (TreeType div 100) mod 10)
+ Chr(Ord("0") + (TreeType div 10) mod 10)
+ Chr(Ord("0") + TreeType mod 10)
не рекомендуется и не хочется.
Заводить еще одну константу sTreeType = "20"?


 
panov ©   (2003-11-18 13:51) [1]

const
TreeType:integer = 20;


 
Sandman25 ©   (2003-11-18 13:54) [2]

[1] panov © (18.11.03 13:51)

Не помогло :(


 
serge   (2003-11-18 14:00) [3]

The compiler expected a constant expression here, but the expression it found turned out not to be constant.

program Produce;
const
Message = "Hello World!";
WPosition = Pos("W", Message);
begin
end.

The call to Pos is not a constant expression to the compiler, even though its arguments are constants, and it could in principle be evaluated at compile time.

program Solve;
const
Message = "Hello World!";
WPosition = 7;
begin
end.

So in this case, we just have to calculate the right value for WPosition ourselves.


 
Sandman25 ©   (2003-11-18 14:04) [4]

[3] serge (18.11.03 14:00)

Спасибо. F1 я нажать не догадался :)


 
serge   (2003-11-18 14:05) [5]

:)



Страницы: 1 вся ветка

Текущий архив: 2003.11.27;
Скачать: CL | DM;

Наверх




Память: 0.47 MB
Время: 0.018 c
1-89837
td
2003-11-13 20:31
2003.11.27
WordApplication1.Selection.Collapse(Direction)


3-89780
IronHawk
2003-11-06 15:18
2003.11.27
Приветствую Мастеров! Как через ADO в Delphi работать с записями:


1-89907
mmmaloy
2003-11-18 15:35
2003.11.27
Проверка на коректность имени папки


11-89801
savva
2003-03-19 18:26
2003.11.27
Как в RunTime для уже существующего Memo (да и не только)......


14-90128
y-soft
2003-11-01 12:23
2003.11.27
Фотографии с последней встречи в Екатеринбурге