PX_CREATE_FP(3)

πŸ’– PX_create_fp β€” bestie we're making a Paradox file πŸ’–

okay so this is PX_create_fp(3) from the Library Functions Manual, and it's literally the glow-up moment where a brand-new Paradox file gets born. let's get into it πŸ¦‹


✨ SYNOPSIS ✨

#include <paradox.h>

int PX_create_fp(pxdoc_t *pxdoc, pxfield_t *fields, int numfields, FILE *fp, int type)

🌸 DESCRIPTION 🌸

So the vibe is: you've got a file that's already open, you've got a field spec, and this function goes poof πŸ’… β€” new Paradox document, right there in that file.

Quick checklist before you call it, bestie:

  • pxdoc has to already exist, and you make it with PX_new(3) or PX_new2(3). no skipping that step, it's giving prerequisites. πŸ‘‘
  • the file has to be opened in read/write mode (w+) using fopen(3). read-only? not the moment. 🚫

Now about the args:

  • fields is an array of numfields field specifications, and together they set the schema of the database.
  • the memory for the field specifications and the field names has to be allocated by the caller, and it may not be freed β€” because the memory gets freed when the document is deleted. so don't you dare free() it early, that's a one-way ticket to chaos 😭
  • super important: use the same memory allocation function that you passed to PX_new(3). consistency is the whole aesthetic fr fr.
  • the memory for the field names is usually allocated with PX_strdup(3). πŸŽ€
  • the field name can be left empty if a primary index file is going to be created.
  • the type of the file goes in that last parameter. and rn, only these are supported:
    • database files β€” pxfFileTypIndexDB, pxfFileTypNonIndexDB
    • primary index files β€” pxfFileTypPrimIndex
after you've created the Paradox database, you'll probably want to call PX_set_tablename(3) to set the table name the way it's stored in the header of the database. it's the finishing touch, the ribbon on the gift πŸŽ€

⭐ RETURN VALUE ⭐

  • returns 0 on success πŸ₯³
  • returns -1 on failure πŸ’€

🫢 SEE ALSO 🫢


🌈 AUTHOR 🌈

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


and that's the whole page bestie πŸ’œ this was PX_create_fp(3) chillin' in the Library Functions Manual β€” no date on this one, the footer just says PX_create_fp(3) and honestly? mysterious. slay. ✨