User:RhoSigma/Test

From QB64 Phoenix Edition Wiki
Revision as of 18:33, 22 May 2025 by RhoSigma (talk | contribs)
Jump to navigation Jump to search

ATTENTION

Keep Out - This is my all things MediaWiki Nuke Test Site ...

SeekBuf (function)

This function will set the current buffer position in the specified buffer using the given placement details. That position is important, as it is used as starting point for most buffer operations, which in any way read, write, copy or search data. The result of this function is the old position in the buffer, or negative if an error occurs. You specify the relative start position (origin) and a displacement, which may be positive or negative and which will be added to the origin. Eg. 20 from current is a position 20 bytes forward from current, -20 is 20 bytes back from current. You'll get an error, if you try to seek beyond the lower or upper bounds of the buffer data range.


SYNTAX:

<code>oldPos& = SeekBuf& (handle%, displace&, mode%)
</code>

INPUTS:

handle% (INTEGER)

  • This is the handle of any valid buffer, for which you wanna set the new position.

displace& (LONG)

  • This is any value which is added to the start position (origin) designated by the given seek mode, it may be negative, zero or positive.

mode% (INTEGER)

  • This is the desired seek mode, which designates the origin for the new position, it may be a regular seek mode as defined in the simplebuffer.bi file (see also below) or the ID number of any set bookmark, which its position shall be used as origin.

RESULT:

oldPos& (LONG)

  • On success (positive value) this is the old position in the buffer.
  • On failure (negative value) it is any of the error numbers defined in the simplebuffer.bi file (see <a href="Simplebuffer-Common.html">Common-Info</a>), the old position remains unchanged in this case.

SEEK MODES:

SBM_PosRestore

  • If you know the exact position, then this is the easiest mode, it will set any absolute position given in the displacement argument (valid values range from 1 to <a href="GetBufLen.html">GetBufLen()</a> + 1).

SBM_BufStart

  • Set a position relative to the buffer start (ie. 1 + displacement).

SBM_BufCurrent

  • Set a position relative to the current position (ie. <a href="GetBufPos.html">GetBufPos()</a> + displacement).

SBM_BufEnd

  • Set a position relative to the buffer end (ie. (<a href="GetBufLen.html">GetBufLen()</a> + 1) + displacement).

SBM_LineStart

  • Set a position relative to the start of the current line, ie. the line where the current buffer position is right now.
    • Start of line = first char of the line.
    • Ie. the set position is 1st char of line + displacement.

SBM_LineEnd

  • Set a position relative to the end of the current line, ie. the line where the current buffer position is right now.
    • End of line = last char of the line + 1 (ie. the 1st line break char, which is CHR$(13) for Windows or CHR$(10) for Linux/MacOSX).
    • Ie. the set position is current line's 1st line break char + displacement.

any Bookmark ID

  • Set a position relative to the bookmark position (ie. <a href="GetBufMark.html">GetBufMark()</a> + displacement).
    • If the displacement is zero, then this is equal to <a href="GotoBufMark.html">GotoBufMark()</a>.