Top.Mail.Ru
Мастера DELPHI, Delphi programming community Титульная страница Поиск, карта сайта Написать письмо 
| Новости | Поиск | FAQ | Статьи | Книги | Новости VCL |
| Форумы ЧАТ | Орешник | KOL и MCK |
Форумы -» Основная («Начинающим»)/ Базы / WinAPI / Компоненты / Сети / Media / Игры / Corba и COM / KOL / FreePascal / .Net / Прочее / RSDN.ORG

« предыдущая ветвь | форум | следующая ветвь »

Using Synapse with KOL [Delphi, Windows]


Jon ©   (2004-12-09 15:06:00) 

Hello - please excuse my Engish, I do not speak Russian :-(

I am using KOL with the SynaSer component of Synapse (www.ararat.cz/synapse) with Delphi 7 and Windows XP. I am not using MCK.

I find that if I create a TBlockSerial object within a function or procedure, it only exists in that procedure. If I try to access the object later, it fails. To fix this I have to create TBlockSerial within the main block of code. This is an example:

var
SerialPort: TBlockSerial;

// can be a function or a procedure
function SerialStuff(Port: String); Boolean;
begin
Result := True
SerialPort := TBlockSerial.Create;   // This line does not work!
SerialPort.Connect(Port);
If SerialPort.LastError <> 0 then Result := False;
end;

// create only works correctly in this main block
begin
SerialPort := TBlockSerial.Create;  // Create only works here!
if SerialStuff('Com1') then
begin
 // ..rest of program..
end;
end.

This is not convenient for me as I will have an unknown amount of objects to create from an array or list. Is the problem the parent of the object? Can I work around this?

I have contacted the developer of Synapse and he recommends asking you.

Any help would be appreciated.

Many thanks in advance.


thaddy   (2004-12-14 03:12:00) [1]

http://members.chello.nl/t.koning8/kolindex.htm


thaddy   (2004-12-14 03:11:00) [2]

Shure you should not use NewBlockSerial??
I will have a look at the synapse for kol code and see what I can do.

Thaddy
http://members.chello.nl/kolindex.htm


Jon   (2004-12-13 17:07:00) [3]

The create line itself does not cause an error message.

When I try to use the port (connect to it) the program crashes, because the object was not created.

If you require the exact message I shall have to look at my computer later when I am near it. Probably tomorrow :-(


alekc   (2004-12-13 12:14:00) [4]


> Result := True
> SerialPort := TBlockSerial.Create;   // This line does not work!> SerialPort.Connect(Port);


What it (compiler) says ?


Jon   (2004-12-12 14:04:00) [5]

Sorry, maybe I was not clear. I only use one of the create lines. I included both in my example to show where it did and did not work.

I do not want to create in the main body, I want to create it in my procedure. There will be more code there to check if it really is needed and how many.

I find that if I create it in the procedure, it is not valid.

Sorry for the confusion :-)


stranger_2004   (2004-12-09 18:34:00) [6]

var
SerialPort: TBlockSerial;

begin
SerialPort := TBlockSerial.Create;  // Create only works here!
if SerialStuff('Com1') then
begin
// ..rest of program..
end;
Do not create Serialport in serialstuff proc,
port already created on boldedline, if SerialPort - it`s global variable on your unit.


Наверх

Титульная страница Поиск, карта сайта Написать письмо