Writeln and my own procedure

  • 1
  • 2
  • Page 2 of 2
Merlin
Administrator
Avatar
Gender:
Age: 24
Posts: 1374
Registered: 03 / 2005
Subject:

Re: Writeln and my own procedure

 · 
Posted: 16.07.2010 - 10:16  ·  #9
Hi Cusko.

I suspect that your problem is that there is a WriteLn within your driver. I doubt if WriteLn is designed to be recursive in this way.

User written functions are able to be recursive because they use the frame for parameters and local variables, but internal procedures tend to use more direct and efficient mechanisms like passing parameters within registers. Normally that is not an issue but in this case it is.

Regards

Merlin.
Avra
Schreiberling
Avatar
Gender:
Location: Belgrade, Serbia
Age: 53
Homepage: rs.linkedin.com/in…
Posts: 653
Registered: 07 / 2002
Subject:

Re: Writeln and my own procedure

 · 
Posted: 18.07.2010 - 01:19  ·  #10
Quote
TelnetTXBuffer:= TelnetTXBuffer+Letter;

This is not very efficient. Just imagine how many bytes are copied every time until string becomes for example 200 characters long. It is better to put just single character and increment index. If you use string instead of an array then you can modify length before sending to ethernet.
Cusko
 
Avatar
 
Subject:

Re: Writeln and my own procedure

 · 
Posted: 19.07.2010 - 11:23  ·  #11
Thanks guys,

I successfully get the right results. As suggested I used an array instead of a string. The right code:
Code

var 
  TelnetTXBuffer  : Array[ 0..99] of Byte;
  TxBufferIndex   : byte;

{$DEVICE}
procedure EthOut( Letter:char);
begin
  TelnetTXBuffer[ TxBufferIndex]:= byte( Letter);
  inc( TxBufferIndex);
  if ( Letter = #10) or ( TxBufferIndex = 100) then
     TinaSendPacket( sTelnet, @TelnetTXBuffer, Word( TxBufferIndex));
     TxBufferIndex:= 0;
  endif;
end;


Again, Thanks for help.
Cusko
  • 1
  • 2
  • Page 2 of 2
Selected quotes for multi-quoting:   0

Registered users in this topic

Currently no registered users in this section

The statistic shows who was online during the last 5 minutes. Updated every 90 seconds.
MySQL Queries: 8 · Cache Hits: 14   61   75 · Page-Gen-Time: 0.014955s · Memory Usage: 2 MB · GZIP: on · Viewport: SMXL-HiDPI