Difference between revisions of "QOTD"

From Lazarus wiki
m (Small change in code)
m (Fix heading levels)
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
==Quote of the Day==
+
== Summary ==
===Summary===
+
 
* Code example of using Synapse to query a public QOTD server
+
* Code example of using Synapse to query a public QOTD server.
===History===
+
 
 +
== History ==
 +
 
 
[http://en.wikipedia.org/wiki/QOTD A wiki article about QOTD]
 
[http://en.wikipedia.org/wiki/QOTD A wiki article about QOTD]
===Accessing a QOTD server via Lazarus===
+
 
* You need to download and compile the Synapse package
+
== Accessing a QOTD server with Lazarus ==
 +
 
 +
* You need to download and compile the [[Synapse|Synapse package]]
 
* Put '''tlntsend''' in your Implementation/Uses clause
 
* Put '''tlntsend''' in your Implementation/Uses clause
 
* You will be using the QOTD port #17
 
* You will be using the QOTD port #17
<syntaxhighlight>
+
 
 +
<syntaxhighlight lang=pascal>
 
procedure DisplayQOTD;
 
procedure DisplayQOTD;
 
Var  
 
Var  
Line 15: Line 20:
  
 
begin
 
begin
MyClient:=TTelNetSend.Create;
+
MyClient := TTelNetSend.Create;
 
With MyClient do
 
With MyClient do
 
begin
 
begin
   TargetPort:='17';
+
   TargetPort := '17';
 
   Timeout:=3000;
 
   Timeout:=3000;
   TargetHost:='alpha.mike-r.com';
+
   TargetHost := 'alpha.mike-r.com';
 
end;
 
end;
 
If MyClient.Login then
 
If MyClient.Login then
 
   begin
 
   begin
       szQuote:=MyClient.RecvString;
+
       szQuote := MyClient.RecvString;
 
       If szQuote = '' then
 
       If szQuote = '' then
 
       begin
 
       begin
 
           MyClient.Send(LineEnding + LineEnding);
 
           MyClient.Send(LineEnding + LineEnding);
           szQuote:=MyClient.RecvString;
+
           szQuote := MyClient.RecvString;
 
       end;
 
       end;
 
   end
 
   end
Line 38: Line 43:
 
end;                         
 
end;                         
 
</syntaxhighlight>
 
</syntaxhighlight>
===QOTD Servers===
 
* Here are some public QOTD servers:
 
qotd.nngn.net
 
  
qotd.atheistwisdom.com
+
== QOTD Servers ==
 +
 
 +
Here are some public QOTD servers:
 +
 
 +
* qotd.nngn.net
 +
* qotd.atheistwisdom.com
 +
* djxmmx.net
 +
* alpha.mike-r.com
  
djxmmx.net
+
Windows users can install the 'Simple TCPIP services' and activate the Windows built-in QOTD server (localhost)
  
alpha.mike-r.com
+
[[Category:Lazarus]]
* Windows users can install the 'Simple TCPIP services' and activate the Windows built-in QOTD server (localhost)
+
[[Category:Code Snippets]]
[[User:minesadorada]]
 
[[Category:Code]]
 

Latest revision as of 03:10, 10 August 2020

Summary

  • Code example of using Synapse to query a public QOTD server.

History

A wiki article about QOTD

Accessing a QOTD server with Lazarus

  • You need to download and compile the Synapse package
  • Put tlntsend in your Implementation/Uses clause
  • You will be using the QOTD port #17
procedure DisplayQOTD;
Var 
MyClient:TTelnetSend;
szQuote:String;

begin
MyClient := TTelNetSend.Create;
With MyClient do
begin
  TargetPort := '17';
  Timeout:=3000;
  TargetHost := 'alpha.mike-r.com';
end;
If MyClient.Login then
  begin
       szQuote := MyClient.RecvString;
       If szQuote = '' then
       begin
          MyClient.Send(LineEnding + LineEnding);
          szQuote := MyClient.RecvString;
       end;
  end
  else szQuote:='Could not retrieve quote';

MyClient.Logout;
ShowMessage(szQuote);
FreeAndNil(MyClient.);
end;

QOTD Servers

Here are some public QOTD servers:

  • qotd.nngn.net
  • qotd.atheistwisdom.com
  • djxmmx.net
  • alpha.mike-r.com

Windows users can install the 'Simple TCPIP services' and activate the Windows built-in QOTD server (localhost)