GetLine (return line of text)

Top  Previous  Next

 

GetLine( line number ), PROC

GetLine

Returns a line of text.

line number

An integer constant, variable, EQUATE or expression that contains the offset or position of the line of text to return.

The GetLine method returns the line of text specified by line number.

Implementation:

The GetLine method gets a line at position line number from the ASCII file, extending the index queue if needed. If the index queue already contains the requested line number then the file is read using the existing offset, otherwise the index is extended. If the requested line number does not exist in the file, the text line is cleared and ERRORCODE() set.

Return Data Type:     STRING

Example:

MyViewer.DisplayPage PROCEDURE(LONG LineNo)

LineOffset USHORT,AUTO

CODE

IF LineNo > 0                              !line specified?

 SELF.ListBoxItems=SELF.ListBox{PROP:Items} !note size of list box

 FREE(SELF.DisplayQueue)                    !free the display queue

 SELF.GetLine(LineNo+SELF.ListBoxItems-1)   !index to end of page

 LOOP LineOffset=0 TO SELF.ListBoxItems-1   !for each listbox line

 !read ASCII file record:

  SELF.DisplayQueue.Line=SELF.GetLine(LineNo+LineOffset)

  IF ERRORCODE()                            !on end of file

   BREAK                                    !stop reading

  END

  ADD(SELF.DisplayQueue)                    !add to display queue

 END

 SELF.TopLine=LineNo                        !note 1st line displayed

 DISPLAY(SELF.ListBox)                      !redraw the list box

END

See Also:     GetLine