Форум: "Основная";
Текущий архив: 2004.06.13;
Скачать: [xml.tar.bz2];
ВнизЕсть код, только при попытке компиляции, орёт, что какая-то там о Найти похожие ветки
← →
Delphin © (2004-05-31 21:22) [0]Есть код, только при попытке компиляции, орёт, что какая-то там ошибка...
Const
RA:Array[0..65]Of String=("А","Б","В","Г","Д","Е","Ё","Ж","З","И","Й","К","Л","М","Н","О","П","Р","С","Т","У","Ф","Х","Ц","Ч","Ш","Щ","Ы", "Ъ","Э","Ь","Ю","Я","а","б","в","г","д","е","ё","ж","з","и","й","к","л","м","н","о","п","р","с","т","у","ф","х","ц","ч", "ш","щ","ы","ъ","э","ь","ю","я");
LA:Array[0..65]Of String=("A","B","V","G","D","E","Jo","Zh","Z","I","J","K","L","M","N","O","P","R","S","T","U","F","H","C","Ch","Sh","sh" ,"I","","E","J","Ju","Ja","a","b","v","g","d","je","jo","zh","z","i","j","k","l","m","n","o","p","r","s","t","u","f","h" ,"c","ch","sh","sh","i","","e","j","ju","ja");
Procedure Trans(var Input:String);
Var
I,Z:Integer;
S,Output:String;
Begin
For I:=1 To Length(Input) Do Begin
S:=Copy(Input,1,1);
For Z:=0 to 65 Do
IF S=RA[z] Then Begin
S:=La[z];
End;
IF Z>e Then
Output:=Output+S;
Delete(Input,1,1);
S:=EmptyStr;
End;
End;
{$R *.dfm}
........
procedure TForm1.Button1Click(Sender: TObject);
begin
Edit2.Text:=Trans(Edit1.Text); //говорит ошибку :((
end;
end.
Народ, Кто знает почему он орёт, что там ошибка? Как это устранить ?
← →
Verg © (2004-05-31 21:36) [1]Зря орет. Я бы вообще матерился на его месте :))
← →
Anatoly Podgoretsky © (2004-05-31 21:43) [2]Это секрет.
← →
Delphin © (2004-05-31 21:55) [3]Да я понимаю, что это секрет ;)
Мастера, подскажите хотябы в каком направлении копать, а то уже замучался
← →
uny (2004-05-31 22:07) [4]проседура поработала, где результат её работы?
← →
YurikGL © (2004-05-31 22:08) [5]А какая ошибка, и в какой строке функции?
← →
Verg © (2004-05-31 22:09) [6]Пациент, вы хотя бы понимаете в чем единственная и принципиальная разница между процедурой (procedure) и функцией (function)?
Это раз...
← →
rrew (2004-05-31 22:12) [7]процедуру на функцию поменяй
← →
Anatoly Podgoretsky © (2004-05-31 22:13) [8]Нет сообщение об ошибке для нас секрет, тогда какой смысл смотреть твой код, вникать в него.
← →
Delphin © (2004-05-31 22:15) [9]>>uny (31.05.04 22:07) [4]
разве процедура выполнилась ?
у меня проблема состоит в том, что я не знаю, как запустить данную процеДУРУ на выполнение
← →
rrew (2004-05-31 22:17) [10]begin
....
Trans(Edit1.Text);
....
end;
← →
YurikGL © (2004-05-31 22:18) [11]Verg © (31.05.04 22:09) [6]
Мндаа... прочитал код поподробнее... такой ошибки не ожидал, поэтому и не заметил... думаю у >>uny (31.05.04 22:07) [4] та же проблема...
← →
uny (2004-05-31 22:19) [12]может необъявленная переменная глобальная. так тоже бывает
← →
YurikGL © (2004-05-31 22:20) [13]> Function Trans(var Input:String):string;> Var
> I,Z:Integer;
> S,Output:String;
> Begin
> For I:=1 To Length(Input) Do Begin
> S:=Copy(Input,1,1);
> For Z:=0 to 65 Do
> IF S=RA[z] Then Begin
> S:=La[z];
> End;
> IF Z>e Then
> Output:=Output+S;
> Delete(Input,1,1);
> S:=EmptyStr;
> Trans:=OutPut //если правильно понял
> End;
> End;
← →
Delphin © (2004-05-31 22:22) [14]Anatoly Podgoretsky © (31.05.04 22:13) [8]
Говорит, чтио ошибка такая: Types of actual and formal var parameters must be identical
rrew (31.05.04 22:12) [7]
если пишу что-то вроде этого
function Trans(var Input:String);
то начинает орать: function needs resuilt type
← →
rrew (2004-05-31 22:23) [15]Const
RA:Array[0..65]Of String=("А","Б","В","Г","Д","Е","Ё","Ж","З","И","Й","К","Л","М","Н","О","П","Р","С","Т","У","Ф","Х","Ц","Ч","Ш","Щ","Ы", "Ъ","Э","Ь","Ю","Я","а","б","в","г","д","е","ё","ж","з","и","й","к","л","м","н","о","п","р","с","т","у","ф","х","ц","ч", "ш","щ","ы","ъ","э","ь","ю","я");
LA:Array[0..65]Of String=("A","B","V","G","D","E","Jo","Zh","Z","I","J","K","L","M","N","O","P","R","S","T","U","F","H","C","Ch","Sh","sh" ,"I","","E","J","Ju","Ja","a","b","v","g","d","je","jo","zh","z","i","j","k","l","m","n","o","p","r","s","t","u","f","h" ,"c","ch","sh","sh","i","","e","j","ju","ja");
function Trans(var Input:String): string;
Var
I,Z:Integer;
S,Output:String;
Begin
For I:=1 To Length(Input) Do Begin
S:=Copy(Input,1,1);
For Z:=0 to 65 Do
IF S=RA[z] Then Begin
S:=La[z];
End;
IF Z>e Then
result:=Output+S;
Delete(Input,1,1);
S:=EmptyStr;
End;
End;
{$R *.dfm}
........
procedure TForm1.Button1Click(Sender: TObject);
begin
Edit2.Text:=Trans(Edit1.Text);
end;
end.
← →
Delphin © (2004-05-31 22:30) [16]rrew (31.05.04 22:23) [15]
так только что попробовал, орёт:
Types of actual and formal var parameters must be identical
← →
YurikGL © (2004-05-31 22:32) [17]На YurikGL © (31.05.04 22:20) [13] что говорит?
← →
rrew (2004-05-31 22:32) [18]function Trans(Input:String): string;
← →
uny (2004-05-31 22:33) [19]Delphin © , а где объявлена эта "е"?
IF Z>e Then <-?
result:=Output+S;
← →
Delphin © (2004-05-31 22:36) [20]>>YurikGL © (31.05.04 22:32) [17]
Всё тоже саме
>>uny (31.05.04 22:33) [19]
Это при перепечатке так получилось, на самом деле вместо e стоит 65
← →
YurikGL © (2004-05-31 22:37) [21]Перенеси через буфер полученный код снова.
← →
Delphin © (2004-05-31 22:41) [22]<<YurikGL © (31.05.04 22:37) [21]
То, что было:
Const
RA:Array[0..65]Of String=("А","Б","В","Г","Д","Е","Ё","Ж","З","И","Й","К","Л","М","Н","О","П","Р","С","Т","У","Ф","Х","Ц","Ч","Ш","Щ","Ы", "Ъ","Э","Ь","Ю","Я","а","б","в","г","д","е","ё","ж","з","и","й","к","л","м","н","о","п","р","с","т","у","ф","х","ц","ч", "ш","щ","ы","ъ","э","ь","ю","я");
LA:Array[0..65]Of String=("A","B","V","G","D","E","Jo","Zh","Z","I","J","K","L","M","N","O","P","R","S","T","U","F","H","C","Ch","Sh","sh" ,"I","","E","J","Ju","Ja","a","b","v","g","d","je","jo","zh","z","i","j","k","l","m","n","o","p","r","s","t","u","f","h" ,"c","ch","sh","sh","i","","e","j","ju","ja");
Procedure Trans(var Input:String);
Var
I,Z:Integer;
S,Output:String;
Begin
For I:=1 To Length(Input) Do Begin
S:=Copy(Input,1,1);
For Z:=0 to 65 Do
IF S=RA[z] Then Begin
S:=La[z];
End;
IF Z>=65 Then
Output:=Output+S;
Delete(Input,1,1);
S:=EmptyStr;
End;
End;
{$R *.dfm}
То, что советовали:
Function Trans(var Input:String):string;
Var
I,Z:Integer;
S,Output:String;
Begin
For I:=1 To Length(Input) Do Begin
S:=Copy(Input,1,1);
For Z:=0 to 65 Do
IF S=RA[z] Then Begin
S:=La[z];
End;
IF Z>65 Then
Output:=Output+S;
Delete(Input,1,1);
S:=EmptyStr;
Trans:=OutPut
End;
end;
← →
uny (2004-05-31 22:44) [23]function Trans(var Input:String):string; <-изменить
....
S:=EmptyStr;
End;
result:=Output; <-добавить
End;
procedure TForm1.Button1Click(Sender: TObject);
var s:string;
begin
s:=Edit1.Text;
Edit2.Text:=Trans(s); //не говорит ошибку :))
end;
← →
rrew (2004-05-31 22:47) [24]Народ че вы подняли шум, тут явная ошибка каторая говорит
что человек не очень то понимает что такое процедура, а что функция!
Для тех кто в танке:
процедура не возвращает РЕЗУЛЬТАТ!
функция возвращает!
function Trans(Input:String): string;
begin
...
result:=output;
end;
begin
...
Edit2.Text:=Trans(Edit1.text);
...
end;
← →
YurikGL © (2004-05-31 22:47) [25]Delphin © (31.05.04 22:41) [22]
А у тебя до этого эта функция объявлена?
← →
YurikGL © (2004-05-31 22:48) [26]
> result:=output;
можно
> Trans:=OutPut
← →
uny (2004-05-31 22:48) [27]rrew
Ваша дельфя чё говорит на Ваш пример?
← →
Verg © (2004-05-31 22:51) [28]
> Types of actual and formal var parameters must be identical
... про функцию-то хоть понятно? А теперь - property - это НЕ переменная - это property. Его нельзя "ссылать", т.е. подсовывать в качестве var параметра процедуры или ф-ции...
Text - это property класса TEdit:))
var в объявлении ф-ции убери.
← →
YurikGL © (2004-05-31 22:51) [29]
> function Trans(var Input:String):string; <-изменить
попробуй
> function Trans(Input:String):string; <-изменить
← →
Verg © (2004-05-31 22:51) [30]...это два...
← →
YurikGL © (2004-05-31 22:52) [31]Все работает с
function Trans(Input:String):string;
Мндаааа... туплю к вечеру...
← →
uny (2004-05-31 22:55) [32]без вара лучше)) а заставить работать в любом виде - интереснее, имхо
← →
YurikGL © (2004-05-31 22:57) [33]Delphin ©
Хоть бы спасибо сказал...Столько народу тебе помагало...Эх, молодежь, вот в наше время....
← →
Delphin © (2004-05-31 23:11) [34]Всем спасибо, наконец-то разобрался :)))
Страницы: 1 вся ветка
Форум: "Основная";
Текущий архив: 2004.06.13;
Скачать: [xml.tar.bz2];
Память: 0.53 MB
Время: 0.03 c