Extend the compiler with resident Macros
Extend the compiler with resident Macros
Sorry for the so-so topic title, but i'm not quite sure how to word what i want.
To make it simple, let me break it down in steps:
(1) i have a macro MsgBox() that i just can't live without... (yes, yes, i know; just take it as an example!)
(2) I use it in all my PB source code files and I would like to be able to call upon it without having to include it specifically in all source files.
(3) at present, I have the macro spelled out as as a template, which I can easily import in the source file when I remember to click on it.
Surely there is a way to call upon it as any other PB function or constant, without having to explicitly (and manually!) include it in all source files.
I'm under the impression that something like this is possible by using the \RESIDENTS folder in the PB setup, but i have no clue how to go about doing it practically. I remember coming acrosss a posting by NetMaestro alluding to such a possibility, but I haven't been able to find it again. Plus i didn't want to hijack the topic with my unrelated question.
Any suggestion, anyone ?
BTW: is there any documentation anywhere that explains in details the purpose of the many subfolders in the PB setup ? I've come across many tidbits here and there, but not any centralized explanation. I think that could be very useful to many PB users.
To make it simple, let me break it down in steps:
(1) i have a macro MsgBox() that i just can't live without... (yes, yes, i know; just take it as an example!)
(2) I use it in all my PB source code files and I would like to be able to call upon it without having to include it specifically in all source files.
(3) at present, I have the macro spelled out as as a template, which I can easily import in the source file when I remember to click on it.
Surely there is a way to call upon it as any other PB function or constant, without having to explicitly (and manually!) include it in all source files.
I'm under the impression that something like this is possible by using the \RESIDENTS folder in the PB setup, but i have no clue how to go about doing it practically. I remember coming acrosss a posting by NetMaestro alluding to such a possibility, but I haven't been able to find it again. Plus i didn't want to hijack the topic with my unrelated question.
Any suggestion, anyone ?
BTW: is there any documentation anywhere that explains in details the purpose of the many subfolders in the PB setup ? I've come across many tidbits here and there, but not any centralized explanation. I think that could be very useful to many PB users.
Last edited by Blue on Mon Jan 05, 2009 10:27 am, edited 3 times in total.
PB Forums : Proof positive that 2 heads (or more...) are better than one 

Yes, create a PB source file with just the macro in it and save it. Then use the command line to invoke the PB compiler with the RESIDENT switch to create a resident file (alternatively Tailbite can create a resident file for you). Place this resident file in the \Residents subfolder of your PB installation and then restart the IDE / compiler. At this point you can use your macro without any additional work.
I may look like a mule, but I'm not a complete ass.
WOW!!! So cool and so very easy to do.srod wrote:Yes [...] you can use your macro without any additional work.

Thanks, Srod.
I followed your suggestion and it works really well

I'm extremely impresssed by how easy PB makes it for the user to customize and extend the development environment.
It's amazingly smart and simple.
Too bad the documentation isn't more explicit on this and some other good things.
i think that such rich features should be easier to discover, understand and apply.
Clearly, the present documentation's one-liner on /RESIDENT is a bit short on the purpose and fabulous usefulness of this parameter and its name-sake subfolder... :roll:
Last edited by Blue on Sat Jan 03, 2009 9:28 am, edited 1 time in total.
PB Forums : Proof positive that 2 heads (or more...) are better than one 

just a example,
save the file in yourdirectory(named "Msgbox_Macro.pb" )
open a shell,
type in:
if you want to overwrite the Resident file, delete it first from the Residents directory
Code: Select all
Macro MsgBox(a)
MessageRequester("Info",a,0)
EndMacro
open a shell,
type in:
the restart the compiler from the IDE.pbcompiler yourdirectory/msgbox_macro.pb /resident ../Residents/msgbox.res
if you want to overwrite the Resident file, delete it first from the Residents directory
SPAMINATOR NR.1
Thanks for the input, Rings.
That's pretty close to what I actually did following srod's instructions and, indeed, it works perfectly.
But since you seem in the know as to the raison d'être of the [Residents] sub-folder, maybe you know of other good but lesser known purposes for this folder or for the similarly named switch ?
--------------------------------------------------
BTW:
I just noticed the Moderator title following your name.
So, maybe you have the ability to make the information in this thread stand out as a sticky subject at the top of the section (Sorry: I just can't remember the word for this action...
).
I'm convinced many users would greatly benefit from learning and making use of what is being offered here by you and Srod.
That's pretty close to what I actually did following srod's instructions and, indeed, it works perfectly.
But since you seem in the know as to the raison d'être of the [Residents] sub-folder, maybe you know of other good but lesser known purposes for this folder or for the similarly named switch ?
--------------------------------------------------
BTW:
I just noticed the Moderator title following your name.
So, maybe you have the ability to make the information in this thread stand out as a sticky subject at the top of the section (Sorry: I just can't remember the word for this action...

I'm convinced many users would greatly benefit from learning and making use of what is being offered here by you and Srod.
PB Forums : Proof positive that 2 heads (or more...) are better than one 

Yeah. Now that I've played with my new toy, I can see at least one reason to abstain from using it: if you want to share your code, you MUST remember to translate all your clever obscure hackssrod wrote:[...]Must admit that I no longer use these or user-libs; sticking firmly with source code includes only.

Is there a smart(er) way to automate the inclusion of a piece of code into new source files?
I've been using a one-line template (which works OK), but i'm thinking there must be a better way.
I'm beginning to think i should have opened this topic in the "PB Editor" section.
PB Forums : Proof positive that 2 heads (or more...) are better than one 

Right on, just as in MS Visual Basic (where you can even choose among a number of different template types!).Trond wrote:Maybe it's possible to create a tool that creates a new file with some predefined contents (instead of the default empty one)?
I have made, for myself, a tool that does what you suggest (creates a skeleton file, in a related folder, then opens the file in the IDE) ; it works, but its value is limited by the fact that it's not tied to the "New" command in the IDE.
Being able to do that would make the tool as practical (at least i think...) as the process used in VB. But i have not the slightest idea how to make the connection to that IDE command

Any idea on that ?
PB Forums : Proof positive that 2 heads (or more...) are better than one 

Hi,
I've found a trick to include procedures on a Resident file, and use it along all your programs.
The trick: include it on a macro.
1. Create a source file with this macro:
2. Compile it as Resident file:
3. Create a new source with this little program, compile and execute:
I've found a trick to include procedures on a Resident file, and use it along all your programs.
The trick: include it on a macro.
1. Create a source file with this macro:
Code: Select all
macro TestProc
Procedure Test_Proc()
pintn("Hello from proc")
EndProcedure
endmacro
Code: Select all
pbcompiler path\file.pb /RESIDENT .\Residents\testproc.res
Code: Select all
TestProc ; to include the procedure in your program
OpenConsole()
Test_Proc() ; to execute the procedure
input()
CloseConsole()
END
In jaPBe there is an possibility to include some file (more or less) automaically.
I suggested gnozal to make this option a bit more flexible so that I can just add a file to the specific folder and jaPBe registrate it so I can use it.
This would make it a bit easier and an lot more easy to change the "include"-files or add some code to them.
I suggested gnozal to make this option a bit more flexible so that I can just add a file to the specific folder and jaPBe registrate it so I can use it.
This would make it a bit easier and an lot more easy to change the "include"-files or add some code to them.