I have once again attempted to learn macros, and once again I find myself needing more information. I've read and re-read and studied the Help file, I've read over 30 threads from the forums having "macro" in the subject, and I've examined some 6 or 7 programs from the Source Code forum that use Macros. (I've tried to debug some of them to observe how the replacement works, but I've had limited success...) I also searched (unsuccessfully) the PB download and Quick Start areas for any instructional materials on "macros". (I thought that I had seen something there a long time ago, but I was mistaken.)
OK, so I understand that the macro capability in PB is a text-replacement capability. It involves the definition of some amount of text and giving it an identifier, so that later, that identifier is removed and the identified text takes its place.
My simplistic way of understanding macros is to use a word processor's "Search and Replace" function as my model. So far, so good.
I also understand that if the identifier is not in a "path of execution" (my own terminology), the replacement will not happen. And I also understand the differences in code size for macros vs subs/functions, and I understand the differences in speed for inline code vs overhead of calls to procedures. So, no problems on those points.
So, macros mostly make sense to me for both one-line macros and multi-line macros. I have no problems with simple replacements, and I understand why macro variables get uniquely numbered suffixes. (For this information, the Help file's detailed explanation of the substitution was, well, helpful!) But I'm sure I still have NOT fully grasped the significance of macro variables or the implications of using them. (I really haven't found any substantive explanation of this point yet.)
I also understand that there is a Macro "Function" aspect, but I have not been able to grasp that yet - at all!!
...It makes no sense to me! If macros are "text replacement", then where does this "procedural" quality come from? A Macro isn't "executable" in the way that a Sub or Function is. Subs and Functions are procedural code structures; macros are not, they're just "blocks of text", and they can contain ANY TEXT, not just code statements. How can a macro "return" anything?... What's doing the processing, and how? What "receives" the value returned? What's checking datatypes? For that matter, what the heck is going on with "passing parameters" to a macro?!?! How does a block of replacement text "use" a parameter?????? ...I just don't get it!
Also, I've read and mostly understand the various restrictions given in the Help for Macro/End Macro, with one notable exception: I'm confused that multi-line macros must be placed in the "statement", or first, position in a line, but an Example shows the multi-line "HowDidIGetHere" macro used in a different position. I'm presuming it has something to do with "HowDidIGetHere" being a macro Function, which as I mentioned, I don't yet understand at all...
I'd appreciate it if anyone can either point me to a "PB Macros 101 Tutorial" or similar reading/studying material, or actually shed some light on my macro Function questions.
Thanks,
-John
I also have questions about "point of placement" issues. For this topic, I'm going to start a different thread and show the code that I'm working on... but that won't be for a couple of days; maybe if I get more info from this thread, those concerns will be answered...
OK, so I understand that the macro capability in PB is a text-replacement capability. It involves the definition of some amount of text and giving it an identifier, so that later, that identifier is removed and the identified text takes its place.
My simplistic way of understanding macros is to use a word processor's "Search and Replace" function as my model. So far, so good.
I also understand that if the identifier is not in a "path of execution" (my own terminology), the replacement will not happen. And I also understand the differences in code size for macros vs subs/functions, and I understand the differences in speed for inline code vs overhead of calls to procedures. So, no problems on those points.
So, macros mostly make sense to me for both one-line macros and multi-line macros. I have no problems with simple replacements, and I understand why macro variables get uniquely numbered suffixes. (For this information, the Help file's detailed explanation of the substitution was, well, helpful!) But I'm sure I still have NOT fully grasped the significance of macro variables or the implications of using them. (I really haven't found any substantive explanation of this point yet.)
I also understand that there is a Macro "Function" aspect, but I have not been able to grasp that yet - at all!!
...It makes no sense to me! If macros are "text replacement", then where does this "procedural" quality come from? A Macro isn't "executable" in the way that a Sub or Function is. Subs and Functions are procedural code structures; macros are not, they're just "blocks of text", and they can contain ANY TEXT, not just code statements. How can a macro "return" anything?... What's doing the processing, and how? What "receives" the value returned? What's checking datatypes? For that matter, what the heck is going on with "passing parameters" to a macro?!?! How does a block of replacement text "use" a parameter?????? ...I just don't get it!
Also, I've read and mostly understand the various restrictions given in the Help for Macro/End Macro, with one notable exception: I'm confused that multi-line macros must be placed in the "statement", or first, position in a line, but an Example shows the multi-line "HowDidIGetHere" macro used in a different position. I'm presuming it has something to do with "HowDidIGetHere" being a macro Function, which as I mentioned, I don't yet understand at all...
I'd appreciate it if anyone can either point me to a "PB Macros 101 Tutorial" or similar reading/studying material, or actually shed some light on my macro Function questions.
Thanks,
-John
I also have questions about "point of placement" issues. For this topic, I'm going to start a different thread and show the code that I'm working on... but that won't be for a couple of days; maybe if I get more info from this thread, those concerns will be answered...
Comment