PX_GET_DATA_BCD(3)

πŸ’– PX_GET_DATA_BCD πŸ’–

okay bestie, we're doing a manual page for PX_get_data_bcd, and yes it lives in the Library Functions Manual, section 3, right where all the library girlies hang out. this is your girl's guide to the bcd data field situation, let's GO πŸ¦‹


✨ NAME ✨

PX_get_data_bcd β€” get the bcd data field, that's literally it, that's the whole job πŸ’…


🌸 SYNOPSIS 🌸

#include <paradox.h>

int PX_get_data_bcd(pxdoc_t *pxdoc, char *data, int len, char **value)

look at that signature. iconic. no notes πŸ‘‘


πŸŽ€ DESCRIPTION πŸŽ€

so what this does: it takes a data field exactly the way it's stored in the database file and turns it into a bcd string for you. glow-up but for bytes, fr fr ✨

the string it hands back will not be longer than 20 chars including the final 0. and it contains only these characters: +, -, 0-9, and .. that's it, that's the whole guest list, nobody else gets in 🚫

you should use this function instead of accessing the data directly. like, please. don't rawdog the struct. this is the way. iykyk πŸ’–

now the deets on the args, because they matter:

  • data points to the start of the data field in the record. to get it, you gotta sum up all field length before the field to operate on and add that to the base pointer of the record. yes, it's a little math homework, but you got this bestie, i believe in you 🫢
  • len is the number of digits after the decimal point.

and here's the part that's giving responsibility: the function allocates memory for the string it returns in *value. that memory has to be freed by the application. so like, it's yours now. it's your baby. take care of it or it leaks. no cap 😭

Note: this function is deprecated and obsolete if PX_retrieve_record(3) is used. so if you're on the PX_retrieve_record(3) train, this one's lowkey retired, she's in her retirement era 🧚

⭐ RETURN VALUE ⭐

  • returns 0 if the value is NULL
  • returns -1 in case of an error πŸ’€
  • returns 1 otherwise β€” slay 🌈

πŸ¦‹ SEE ALSO πŸ¦‹

the whole friend group, go say hi:


πŸ‘‘ AUTHOR πŸ‘‘

this manual page was written by Uwe Steinmann uwe@steinmann.cx. thank you for your service, legend πŸ«‘πŸ’œ


okay that's the whole page bestie!! this one came out of the Library Functions Manual and it's filed under PX_GET_DATA_BCD(3) β€” go forth, handle your bcd data, and remember to free() that memory. mwah πŸ’‹πŸŽ€