Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Manual Content: buffer_read() page does not explain the requirement for moving the seek position first #3503

Closed
YYDan opened this issue Jan 9, 2024 · 0 comments
Assignees
Labels
docs-bug GameMaker Manual Bugs

Comments

@YYDan
Copy link
Collaborator

YYDan commented Jan 9, 2024

Description

The page for buffer_read() does not really impress/clarify just how important the seek position is before you start reading from the buffer, and accordingly the sample lower down on the page does not really show anything useful.

Currently, the only mention to the seek position comes at the very top of the page and so is very easy to skim past:
image

And the sample is just one line:
image

Expected Change

We extend the wording at the top to clarify the importance of the seek position:

This function can be used to read data from a previously-created buffer. Be aware that it will only read the contents starting from at the buffer's current seek position, so you must ensure this is set correctly before calling the function - otherwise, you will get either incorrect results or nothing at all being returned,

And we make the sample code block an end-to-end example which shows the need for controlling the seek position:

testBuffer = buffer_create(10240, buffer_grow, 1);

//buffer_seek(testBuffer, buffer_seek_start, 0);   // This one is optional, as the buffer has only just been created, so the seek IS 0 already
buffer_write(testBuffer, buffer_string, "Hello World");

buffer_seek(testBuffer, buffer_seek_start, 0);    // This line is required, as we have since written data to the buffer and so moved the seek
myResult = buffer_read(testBuffer, buffer_string);

show_debug_message("Result = " + myResult);

ManualBufferExample.zip

Manual Link

https://manual.gamemaker.io/monthly/en/#t=GameMaker_Language%2FGML_Reference%2FBuffers%2Fbuffer_read.htm

@YYDan YYDan added the docs-bug GameMaker Manual Bugs label Jan 9, 2024
YYBartT added a commit to YoYoGames/GameMaker-Manual that referenced this issue Jan 9, 2024
…irement for moving the seek position first

YoYoGames/GameMaker-Bugs#3503
* Reworded the function description a bit
* Added a paragraph explaining that buffer_read advances the seek position
* Added paragraph explaining that you must set the seek position correctly to get correct results
* Linked buffer_peek function page for the alternative where you don't use the seek position
* Updated the example, added extensive description
@YYBartT YYBartT closed this as completed Jan 16, 2024
gurpreetsinghmatharoo pushed a commit to YoYoGames/GameMaker-Manual that referenced this issue Aug 8, 2024
…irement for moving the seek position first

YoYoGames/GameMaker-Bugs#3503
* Reworded the function description a bit
* Added a paragraph explaining that buffer_read advances the seek position
* Added paragraph explaining that you must set the seek position correctly to get correct results
* Linked buffer_peek function page for the alternative where you don't use the seek position
* Updated the example, added extensive description

(cherry picked from commit 2fbde3c)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs-bug GameMaker Manual Bugs
Projects
None yet
Development

No branches or pull requests

3 participants