GetLineInfo
Script function

world.GetLineInfo

DOC_scripting Read about scripting

Type

Method

Summary

Gets details about a specified line in the output window

Prototype

VARIANT GetLineInfo(long LineNumber, short InfoType);

DOC_data_types 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)

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.



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)                          

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

DOC_info Information

Functions

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

(Help topic: function=GetLineInfo)

DOC_contents Documentation contents page