Creating your own custom constants file
Posted: Sun Jan 22, 2006 12:42 pm
If you use your own custom constants in a lot of your apps, and don't want to
have to declare them in each source, then just create your own "Residents"
file of them. Here's how:
(1) Create a new PureBasic source, called something like MyResidents.pb, and
put all your desired custom constants inside it, such as:
You'll note one drawback: you can't use existing constants to declare your
new ones... which is why I've had to use "1 | 13107200" above, in place of
"#PB_Window_ScreenCentered | #PB_Window_SystemMenu".
Oh well.
(2) Create a new batch file, in the same folder as your MyResidents.pb, called
MyResidents.bat, with its contents like this (not forgetting to change the paths
to your PureBasic installation folder as required):
(3) Double-click the batch file and that's it -- all your custom constants are
now instantly usable in all your sources! When you want to add more such
constants, just edit MyResidents.pb, save it, and run the batch file again.
have to declare them in each source, then just create your own "Residents"
file of them. Here's how:
(1) Create a new PureBasic source, called something like MyResidents.pb, and
put all your desired custom constants inside it, such as:
Code: Select all
#NetWork_Event_Failed = 0
#NetWork_Event_Success = 1
#PB_Window_Standard = 1 | 13107200 ; #PB_Window_ScreenCentered | #PB_Window_SystemMenu
new ones... which is why I've had to use "1 | 13107200" above, in place of
"#PB_Window_ScreenCentered | #PB_Window_SystemMenu".

(2) Create a new batch file, in the same folder as your MyResidents.pb, called
MyResidents.bat, with its contents like this (not forgetting to change the paths
to your PureBasic installation folder as required):
Code: Select all
"C:\Program Files\PureBasic\Compilers\pbcompiler.exe" MyResidents.pb /resident MyResidents.res
move MyResidents.res "C:\Program Files\PureBasic\Residents\"
pause
now instantly usable in all your sources! When you want to add more such
constants, just edit MyResidents.pb, save it, and run the batch file again.
