Главная страница
    Top.Mail.Ru    Яндекс.Метрика
Форум: "Основная";
Текущий архив: 2003.07.24;
Скачать: [xml.tar.bz2];

Вниз

Invalid Pointer Operation   Найти похожие ветки 

 
Cr@zy-EyE   (2003-07-12 17:54) [0]

При работе программы выскакивает это сообщение. Возникает в процедуре обработки нажатия Button1(если надо, вот):
procedure TForm1.Button1Click(Sender: TObject);
var cs: ConvertedString;
s, r: integer;
begin
Memo1.Lines.Clear;
cs:=StringConvertFromDLL(Edit1.Text);
s:=Length(cs);
if (s=0) then Memo1.Lines.Add("Error")
else for r:=1 to s do
Memo1.Lines.Add(IntToStr(cs[r]));
end;


Вот функция из вызываемого DLL-ника:
function StringConvertFromDLL(const str: string):ConvertedString;
var l, c, err: integer;
begin
err:=2;
l:=Length(str);
if (l<3) or (l>30) then err:=0;
if (err=2) then begin
SetLength(Result, l);
for c:= 1 to l do begin
case str[c] of
"0" : Result[c]:=0;
"1" : Result[c]:=1;
"2" : Result[c]:=2;
"3" : Result[c]:=3;
"4" : Result[c]:=4;
"5" : Result[c]:=5;
"6" : Result[c]:=6;
"7" : Result[c]:=7;
"8" : Result[c]:=8;
"9" : Result[c]:=9;
"_" : Result[c]:=10;
"a" : Result[c]:=11;
"b" : Result[c]:=12;
"c" : Result[c]:=13;
"d" : Result[c]:=14;
"e" : Result[c]:=15;
"f" : Result[c]:=16;
"g" : Result[c]:=17;
"h" : Result[c]:=18;
"i" : Result[c]:=19;
"j" : Result[c]:=20;
"k" : Result[c]:=21;
"l" : Result[c]:=22;
"m" : Result[c]:=23;
"n" : Result[c]:=24;
"o" : Result[c]:=25;
"p" : Result[c]:=26;
"q" : Result[c]:=27;
"r" : Result[c]:=28;
"s" : Result[c]:=29;
"t" : Result[c]:=30;
"u" : Result[c]:=31;
"v" : Result[c]:=32;
"w" : Result[c]:=33;
"x" : Result[c]:=34;
"y" : Result[c]:=35;
"z" : Result[c]:=36;
else begin err:=1; Break; end;
end;
end;
end;
if err<>2 then begin
SetLength(Result,1);
Result[1]:=err;
end;
end;


Тип ConvertedString описан так:
type ConvertedString = Array of integer;

Не подскажете, в чем причина?


 
Palladin   (2003-07-12 18:05) [1]

case поменяй на


case str[c] of
"0".."9":result[c-1]:=byte(str[c])-48;
"-":result[c-1]:=10;
"a".."z":result[c-1]:=byte(str[c])-86
else
begin
err:=1;
break;
end;
end;

правда короче?

динамический массив, в отличии от строк, начинается с нуля...
и убедись что в приложении и в dll первым модулем прописан ShareMem


 
Cr@zy-EyE   (2003-07-12 19:10) [2]

Все поменял, оказалось, что забыл вписать ShareMem в прогу. Спасибо.



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

Форум: "Основная";
Текущий архив: 2003.07.24;
Скачать: [xml.tar.bz2];

Наверх





Память: 0.45 MB
Время: 0.013 c
1-77995
Юрий Федоров
2003-07-11 14:14
2003.07.24
Проверка, абстрактный ли метод


14-78138
Dmitriy O.
2003-07-09 07:55
2003.07.24
Ответственность за свой програмный продукт.


1-77997
Darrin
2003-07-11 16:46
2003.07.24
Как изменить цвет MainMenu ?


7-78163
Мфдукф
2003-05-15 19:29
2003.07.24
система


1-77921
Григорий Ситнин
2003-07-08 16:23
2003.07.24
Так каков приоритет у скобок?..





Afrikaans Albanian Arabic Armenian Azerbaijani Basque Belarusian Bulgarian Catalan Chinese (Simplified) Chinese (Traditional) Croatian Czech Danish Dutch English Estonian Filipino Finnish French
Galician Georgian German Greek Haitian Creole Hebrew Hindi Hungarian Icelandic Indonesian Irish Italian Japanese Korean Latvian Lithuanian Macedonian Malay Maltese Norwegian
Persian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swahili Swedish Thai Turkish Ukrainian Urdu Vietnamese Welsh Yiddish Bengali Bosnian
Cebuano Esperanto Gujarati Hausa Hmong Igbo Javanese Kannada Khmer Lao Latin Maori Marathi Mongolian Nepali Punjabi Somali Tamil Telugu Yoruba
Zulu
Английский Французский Немецкий Итальянский Португальский Русский Испанский