[Home] [Downloads] [Search] [Help/forum]

GetLineInfo

Script function

world.GetLineInfo

Read about scripting

Type

Method

Summary

Gets details about a specified line in the output window

Prototype

VARIANT GetLineInfo(long LineNumber, short InfoType);

View list of data type meanings

Description

Returns details about any line in the output buffer (window).

The line number can be from 1 (the first line) to the number of lines in the output window. You can use "world.GetLinesInBufferCount" to find how many lines are currently in the output window. This number is different from the sequential number of the line since the world opened. For example, if your buffer size is 5000 lines, and you have received 8000 lines, then the last line will be line around 5000 in the buffer but "actual line number" (selector 10 below) will return 8000.

Note that when the buffer fills up lines are discarded in batches of 100, so the last line will probably not be 5000, even if your buffer size is 5000 and you have been connected for a while. It is likely to be in the range 4900 to 4999.

Also, the last line may be blank (empty) as MUSHclient creates a new, empty, line as soon as a newline is received for the previous line from the MUD.

You can obtain one of 12 "types" of information about the line by specifying an "InfoType". The possible InfoTypes are:

1: text of line (string)
2: length of text (short)
3: true if newline, false if not (boolean)
4: true if world.note (boolean)
5: true if player input (boolean)
6: true if line logged (boolean)
7: true if bookmarked (boolean)
8: true if MXP horizontal rule (<hr>) (boolean)
9: date/time line arrived (date)
10: actual line number (not line number in buffer) (long)
11: count of style runs (long)
12: ticks - exact value from the high-performance timer (double)
13: elapsed time in seconds from when the world was started (opened) (high precision)

The text of the line is the actual text you see on the screen.

If "newline" is true then this line is the end of a paragraph (ie. had a newline at the end of it). You can reassemble paragraphs by concatenating lines as found, and then adding a newline (carriage-return, linefeed) whenever "newline" is true. MUSHclient automatically preserves the space at the end of each line, so it is unnecessary to add another of your own. If "indent paragraphs" option is set in MUSHclient the space will be at the start of the next line, rather than the end of the previous line.

If "world.note" is true this is a "note" line, not MUD output.

If "player input" is true, then this line is an echoed command, not MUD output.

The count of styles runs can be used in conjunction with GetStyleInfo to further break up individual lines into style runs (eg. colour changes, bold, underline, etc.).

The "ticks" value is obtained by querying the "high performance timer" provided by Windows. This gives a time interval to a high degree of precision, however it is not related to the time-of-day in any meaningful way. The intention here is that you can use it to find the precise time difference between various lines as they arrive from the MUD.


Available in MUSHclient version 3.18 onwards.



VBscript example

dim line, total_lines

total_lines = world.GetLinesInBufferCount

'
'  Example showing the last 10 lines in the output buffer
'   Shown is text of line, date/time received, count of style runs
'

for line = total_lines - 10 to total_lines

  world.note "Line " & line & " = " & world.GetLineInfo (line, 1)
  world.tell "Received " & world.GetLineInfo (line, 9)
  world.note " - Style runs = " & world.GetLineInfo (line, 11)

next


Jscript example

var line, total_lines;

total_lines = world.GetLinesInBufferCount ();

//
//  Example showing the last 10 lines in the output buffer
//   Shown is text of line, date/time received, count of style runs
//

for (line = total_lines - 10; line <= total_lines; line++)
  {
  world.note ("Line " + line + " = " + world.GetLineInfo (line, 1));
  world.tell ("Received " + world.GetLineInfo (line, 9));
  world.note (" - Style runs = " + world.GetLineInfo (line, 11));
  }


PerlScript example

my $line, $total_lines;

$total_lines = $world->GetLinesInBufferCount ();

#
#  Example showing the last 10 lines in the output buffer
#   Shown is text of line, date/time received, count of style runs
#

for ($line = $total_lines - 10; $line <= $total_lines; $line++)
  {
  $world->note ("Line " . $line . " = " . $world->GetLineInfo ($line, 1));
  $world->tell ("Received " . $world->GetLineInfo ($line, 9));
  $world->note (" - Style runs = " . $world->GetLineInfo ($line, 11));
  }


Python example

total_lines = world.GetLinesInBufferCount 

#
#  Example showing the last 10 lines in the output buffer
#   Shown is text of line, date/time received, count of style runs
#

for line in range (total_lines - 10, total_lines):
  world.note ("Line " + str(line) + " = " + world.GetLineInfo (line, 1))
  world.tell ("Received " + str (world.GetLineInfo (line, 9)))
  world.note (" - Style runs = " + str (world.GetLineInfo (line, 11)))


Lua example

local line, total_lines

total_lines = GetLinesInBufferCount ()

--
--  Example showing the last 10 lines in the output buffer
--   Shown is text of line, date/time received, count of style runs
--

for line = total_lines - 10, total_lines do
  Note ("Line ", line, " = ", GetLineInfo (line, 1))
  Tell ("Received ", GetLineInfo (line, 9))
  Note (" - Style runs = ", GetLineInfo (line, 11))
  end


-- Lua extension - returns all information in a table:

for line = total_lines - 10, total_lines do
  table.foreach (GetLineInfo (line), print)  
end


Lua notes

The InfoType is optional, and defaults to zero.

As an extension, if the InfoType is omitted or zero, then all types of information
for the nominated line are returned in a table, keyed by type:

 text:     text of line (string)                                   
 length:   length of text (number)                                 
 newline:  true if newline, false if not  (boolean)                 
 note:     true if world.note  (boolean)                            
 user:     true if player input (boolean)                           
 log:      true if line logged  (boolean)                           
 bookmark: true if bookmarked  (boolean)                            
 hr:       true if MXP horizontal rule (<hr>)  (boolean)                
 time:     date/time line arrived  (date - number)                        
 timestr:  date/time line arrived  (date - string)
 line:     actual line number (not line number in buffer)  (number)
 styles:   count of style runs  (number)  
 ticks:    exact value from the high-performance timer 
(number)                          
 elapsed:  exact elapsed time (number) since world started (opened)

Thus, to print the text of line 5 you might do this:

  print (GetLineInfo (5).text)

If the line does not exist, or the InfoType is invalid, Lua will return nil.


Return value

The specified information about the line, as described above.
An EMPTY variant, if the line does not exist.
A NULL variant if the InfoType is not a valid type.


See Also ...

Topic

Information

Functions

(Debug) Displays debugging information about the world
(EchoInput) A flag to indicate whether we are echoing command input to the output window
(GetConnectDuration) Returns the number of seconds this world has been connected.
(GetEntity) Retrieves the value of an MXP server-defined entity
(GetHostAddress) Returns a list of IP addresses that correspond to a host name on the Internet
(GetHostName) Returns the host name that corresponds to an IP address on the Internet
(GetInfo) Gets information about the current world
(GetInternalCommandsList) Returns a list of the internal MUSHclient command names
(GetLineCount) Gets count of lines received
(GetLinesInBufferCount) Returns the number of lines in the output window
(GetMainWindowPosition) Returns the position and size of the main MUSHclient window
(GetNotepadWindowPosition) Returns the position and size of the specified notepad window
(GetNotes) Gets the world's notes
(GetQueue) Returns a variant array which is a list of queued commands
(GetReceivedBytes) Returns the number of bytes received from the world
(GetRecentLines) Assembles a block of text from recent MUD output
(GetSelectionEndColumn) Returns the endling column of the selection in the output window
(GetSelectionEndLine) Returns the last line of the selection in the output window
(GetSelectionStartColumn) Returns the starting column of the selection in the output window
(GetSelectionStartLine) Returns the starting line of the selection in the output window
(GetSentBytes) Returns the number of bytes sent to the world
(GetStyleInfo) Gets details about a specified style run for a specified line in the output window
(GetSysColor) Gets the colour of various windows items
(GetSystemMetrics) Returns selected system information from Windows
(GetWorldID) Returns the 24-character ID of the current world
(GetWorldWindowPosition) Returns the position and size of the current world window
(GetWorldWindowPositionX) Returns the position and size of a specific world window
(GetXMLEntity) Retrieves the value of a standard entity
(IsConnected) Tests to see if the world is connected to the MUD server
(SetChanged) Sets or clears the "document has changed" flag
(SetEntity) Sets the value of an MXP entity
(UdpPortList) Returns an array of all the UDP ports in use by this world
(Version) Gets the MUSHclient version string.
(WorldAddress) Returns the TCP/IP address of the current world.
(WorldName) Gets the world's name
(WorldPort) Returns the port number of the current world.

(Help topic: function=GetLineInfo)

Documentation contents page


Search ...

Enter a search string to find matching documentation.

Search for:   

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at FutureQuest]