PX_GET_RECORD2(3)

πŸ’– PX_get_record2 β€” the record-fetching glow-up πŸ’–

okay bestie, listen up, because we're in the Library Functions Manual today and the vibe is records from Paradox files. this one's a classic, she's a little extra, and honestly? she's kind of deprecated. we'll get to that. no cap. πŸ¦‹


✨ SYNOPSIS ✨

#include <paradox.h>

int PX_get_record2(pxdoc_t *pxdoc, int recno, char *data, int *deleted,
pxdatablockinfo_t *pxdbinfo)

🌸 DESCRIPTION 🌸

so this function is literally the sister of PX_get_record(3) β€” same energy, except she takes two extra parameters. she said "let me give you more". πŸ’…

  • if *deleted is set to 1, she will consider any record in the database, even the deleted ones. she's inclusive like that.
  • if *pxdbinfo is not NULL, she'll hand you back some info about the data block the record got read from.
⚠️ heads up queen: you have to allocate the memory for pxdbinfo before you call PX_get_record2. she does not do it for you. not her job.

on return, *deleted gets set to 1 if the record you asked for is deleted, or 0 if it isn't. simple as that. ✨


πŸŽ€ the pxdatablockinfo_t struct πŸŽ€

here's what's inside, bestie, field by field:

  • blockpos (long) β€” the file position where the block starts. the first six bytes of the block are the header, and the record data comes right after.
  • recordpos (long) β€” the file position where the record you asked for actually starts.
  • size (int) β€” the size of the data block, not counting the six bytes of header.
  • recno (int) β€” the record number within the data block. the first record in the block is number 0.
  • numrecords (int) β€” how many records live in this block.
  • number (int) β€” the number of the data block itself.

😭 the messy part (read this, fr fr)

this function may return records with invalid data. why? because records aren't explicitly marked as deleted β€” instead, the size of a valid data block gets modified. that's the whole trick. πŸ’€

a data block is a fixed-size area in the file that holds a certain number of records. so if for some reason a data block has never been completely filled with records, the algorithm anticipates deleted records in that block… which aren't actually there. plot twist. πŸ™ˆ

this happens a lot with the last data block in a file, because it's likely to not be fully filled with records.

also, if you're accessing several records, do it in ascending order β€” that's the most efficient way. trust. 🫢

🚨 Note: this function is deprecated. use PX_retrieve_record(3) instead. she's the newer model, the main character now. periodt.

πŸ’« RETURN VALUE πŸ’«

  • 0 on success πŸŽ‰
  • -1 on failure 😭

πŸ‘€ SEE ALSO πŸ‘€


πŸ‘‘ AUTHOR πŸ‘‘

this manual page was written by Uwe Steinmann uwe@steinmann.cx. iconic of him honestly.


and that's the whole page, bestie!! this one comes to you straight from the Library Functions Manual, and ngl there's no date stamp on it, so we're just vibing timelessly. πŸ’–βœ¨πŸŽ€ go call PX_retrieve_record(3) instead, i'm begging. πŸ¦‹