set_config_string(3alleg4)

πŸ’– set_config_string πŸ’–

okay bestie, so this is a page from the Allegro manual β€” the Allegro game programming library, if you didn't already know, and we're talking about set_config_string, which is literally the girl who writes your strings into the config file. main character energy fr fr. ✨


🌸 SYNOPSIS 🌸

#include <allegro.h>

void set_config_string(const char *section, const char *name, const char *val);

like, that's the whole signature. she takes a section, a name, and a val and she does her thing. periodt. πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

So here's the tea: set_config_string writes a string variable to the current config file, replacing any existing value it may have. Just fully evicting the old value, no apology, iconic behaviour honestly. πŸ’–

And if val is NULL? Not me deleting the variable entirely 😭 β€” yep, passing NULL as val removes the variable. gone. bye. πŸŽ€

The section name is giving options:

  • Set it to NULL and the variable goes to the root of the file, no section, just vibes.
  • Or use it to control which section the variable is inserted into. very much your choice bestie. ✨
⚠️ okay so listen β€” the altered file gets cached in memory and is NOT actually written to disk until you call allegro_exit(). she's holding it in her head until you tell her to commit, lowkey relatable. 🫢

Also, important: you can only write to files this way. So if the current config source was specified with set_config_data() rather than set_config_file(), this function will have no effect. literally nothing. zero. πŸ’€ not her fault, that's just how it is.

✨ the special case (iykyk) ✨

As a special case, variable or section names that begin with a # character are treated specially and will not be read from or written to the disk. So sneaky, so chic. 🌈

Addon packages can use this to store version info or other status information into the config module, from where it can be read with the get_config_string() function. cute little secret pocket, love that for them. πŸ“


πŸ‘‘ SEE ALSO πŸ‘‘

go read those too bestie, they're all in the same friend group fr fr. πŸ’œ


and that's the whole page!! written by Allegro, version 4.4.3, and dated right along with set_config_string(3alleg4) β€” mwah, slay, go write some strings. πŸ’…βœ¨πŸŽ€