Possible to implement something like Get Last Li - WeOnlyDo Discussion board

Possible to implement something like Get Last Li (wodTelnetDLX)

by enaiman, Thursday, October 18, 2007, 02:57 (6244 days ago)

Been researching $Telnet1.Text() with its options and I am pretty familiar with.
I wonder if it is possible to implement (or maybe it is already an easy way) something to return the most recent line received.
Usually when the screen is full that line can be retrieved by addressing the line number equal to $Telnet1.Rows value but ... when I have only a few lines of text (begining of Telnet session) it would be difficult to know how many lines are there so I can guess the index.

There is a workaround and I already figured a way to do it but it takes a dozen code lines (getting all the buffer, splitting it by CRLF, retrieving the last element).

This is not a must have and not so important, however, if you guys decide to implement it in the future you will have one more happy user [:wink:]

Thanks for reading this,

Re: Possible to implement something like

by wodDamir, Thursday, October 18, 2007, 08:53 (6244 days ago) @ enaiman

Hi,

Did you check ReceiveLine method?

Perhaps this would help?

Regards,
Damba

Re: Possible to implement something like

by enaiman, Friday, October 19, 2007, 00:19 (6244 days ago) @ wodDamir

Hi,

Did you check ReceiveLine method?

Perhaps this would help?

Regards,
Damba

Thanks Damba,
Haven't think to try that ... I will give it a go and see how it will work :)

Re: Possible to implement something like

by enaiman, Friday, November 23, 2007, 01:38 (6208 days ago) @ enaiman

Hi,

Did you check ReceiveLine method?

Perhaps this would help?

Regards,
Damba

I tried ReceiveLine and it returns nothing :(
the way I did: I've put ReceiveLine inside the _Receive function. The _Receive function works and it returns the number of bytes to be received.
I'm not sure how Handled works, I tried to assign True or False outside _Receive function but it doesn't change the behaviour (I'm using the GUI version)

Here is a bit of my code:
[code]Func Telnet1_Received($bytes, $handled)
ConsoleWrite($bytes&@CRLF) ;debuging
ConsoleWrite($handled&@CRLF) ;debuging
$recvd = $Telnet1.ReceiveLine ()
ConsoleWrite($recvd&@CRLF) ;debuging
EndFunc[/code]

while $bytes value changes everytime according to what is to be received, ReceiveLine returns nothing and Handled has no effect when set True or False.
I know I may be doing something wrong ... could you tell me please?
Thank you,

Re: Possible to implement something like

by wodDamir, Friday, November 23, 2007, 02:55 (6208 days ago) @ enaiman

Hi,

The empty string usually means that there was an empty line received.
In that case, there is more lines retrieved, so you should call the ReceiveLine method again.

However, if you only need the last line, it would perhaps be easier to call the receive method, and parse the result (start from the end). I believe that the result should contain CR/LF sequences, which should make it much easier to parse the result.

Hope I helped.

Regards,
Damba

Re: Possible to implement something like

by enaiman, Friday, November 23, 2007, 04:00 (6208 days ago) @ wodDamir

I don't know if it is supposed to be this way or I am missing something.
When using the GUI mode none of Receive, ReceiveLine, Peek, PeekLine returns anything at all, and they should return something since the GUI show everything received.
I tried the COM mode and all these function have the proper return. Been reading the Help and haven't found any specification for these function being available/not available in GUI/COM modes.

Are they available in any mode?

Re: Possible to implement something like

by wodDamir, Friday, November 23, 2007, 08:49 (6208 days ago) @ enaiman

Hi,

In order to use the Received Event in GUI mode(.ocx), you should set Handled parameter of the event to True. This will cause wodTelnetDLX not to remove the data from the buffer.

Since the component needs to display the received data on the screen, the Receive method is already being called internally, so unless Handled parameter is set, the data won't be shown in.

Hope this helps.

Regards,
Damba