Announcement

Collapse
No announcement yet.

Macrohelp

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Macrohelp

    I have created and compiled a help file for MACROs for the PowerBASIC IDEs, one file for both PBWIN10 and PBCC6.

    This contains MACROs created by several members of the forum, but not all macro creators are represented in this first version. I stopped collecting when I had over 300 thinking that would be enough to see how this all worked for I'd never compiled a .chm file before. Not all are useful to everyone, but all are useful to someone or they would not have been made. All macro have been put through a compile via the IDE.

    This makes the macros available for the context-sensitive Help if the cursor is placed on a Macro in your code.


    Accompanying this help file is a file named "MACRO_HELP.PBKeys". Place it in the Bin subdirectory of PBWIN or PBCC. Put "QMACROHELP.chm" there too.

    Also accompanying the help file is are files named "MACRO_PB.inc" and "MACRO_SUPPORT.inc". Place these files in the WinAPI subdirectory of your compiler(s).

    The four above named files are included in the zip file.

    This is free of charge and is in the Third Party Forum so that all will realize that this is not an offering from Drake Enterprises, Ltd.Click image for larger version

Name:	macrohelp1.gif
Views:	82
Size:	45.7 KB
ID:	777643
    Attached Files
    Rod
    "To every unsung hero in the universe
    To those who roam the skies and those who roam the earth
    To all good men of reason may they never thirst " - from "Heaven Help the Devil" by G. Lightfoot

  • #2
    Nice job Rodney!

    I also use CHM for my system documentation (around 350 macros/functions). I like the alphabetical list of keywords, but that gets a little rough when you get to hundreds of items.

    If you see this growing significantly, my suggestion is a 'Chapter' above 'Keyword Reference' called 'Keywords By Function'. Under that chapter are pages for each type. For example: Graphics; Math - Trigonometry; Math - Currency; Number - Formatting. They could be nested chapters, but straight pages work too. Each page lists the matching functions linked to the page in the 'Alphabetic Keyword Reference'.

    Comment


    • #3
      Thanks Raymond!

      Well, there will be at least one more version of this but I don't think it will grow too much after that, unless folks start using a lot more Macros. This was just to find out how well the system worked with attaching it to the PB IDEs.

      I found I was spending quite a bit of time searching for bits and pieces and this is an attempt to start simplifying my search(and so I don't go off on tangents instead of focusing on my search ).

      I think there are a lot more Macros I can glean from the forum, and I wouldn't mind if others sent me their favorites in a private message or post them in this thread to include in the next version. I like the ones that are found in compilable code to link to as usage is readily apparent.

      As for grouping the Macros in chapters, I know there needs to be organization but whether by alphabetic, alpha-numeric, subject, author, complexity, or some other classification is something I've not yet come to terms with.

      I have to study the linking a bit more, since I could only get two to link the way I wanted them to.

      While I'm focusing on Macros for the time being, I've not forgot about functions and subs so I'm open to suggestions regarding all aspects of this endeavour.

      Thanks again, Raymond
      Rod
      "To every unsung hero in the universe
      To those who roam the skies and those who roam the earth
      To all good men of reason may they never thirst " - from "Heaven Help the Devil" by G. Lightfoot

      Comment


      • #4
        Not sure how you created the CHM. I use Help & Manual for all mine and you simply highlight the text, drag over the topic and all the linking is done for you. YMMV.

        Structured data (author, subject) is less well-defined. I typically put a horizontal rule at the bottom of each page, then include a set of tags that I can search on (see below). Since I don't generate the documents programmatically, I've never thought out how to track something like author and auto-generate pages and links. Interesting issue to ponder while I'm enjoying the 3 minutes of sun we will have today in Pittsburgh

        Tags: #backup #restore #systemstate #crash

        Comment


        • #5
          Your comment about 'three minutes of sun' made me get up and go look out the window, only to see a clear blue sky which means it's going to get colder here in Winnipeg.

          I'm using Help'n Doc, which on one hand is pretty straightforward, but has a learning curve to some of the finer aspects of documentation. Almost overburdened with options actually. Compiles in at least six different formats besides .chm. .HTML, Word, PDF, EPub, MobiPocket/Kindle and Qt. Currently I'm just focusing on the .chm variety although it appears that it uses the same data to compile all. A couple of the formats require a different compiler be present.

          So far, I've just copy/pasted the topics and that links them to the Table of contents but not to the Index of Keywords which it might do if I left it alone.
          The links to code in the forum are put there in a similar manner to links are posted in the forum.

          There's a few things I've missed in my first go round. Their own help file takes some getting used as it, like most, seems obtuse, but it could be me that's being obtuse.

          I will be gleaning more from the forum and adding more content to some of the existing topics. A little better organization is in order as well for the next go round.

          I must confess that I never tried to hand the header/footer features.

          Thanks for you interest.
          Rod
          "To every unsung hero in the universe
          To those who roam the skies and those who roam the earth
          To all good men of reason may they never thirst " - from "Heaven Help the Devil" by G. Lightfoot

          Comment


          • #6
            Hey Rodney - after I open up the CHM file, I cannot get Help to display topic content. Is there something special I should do?

            Comment


            • #7
              Make sure your CHM is unblocked Gary. Right-click, properties, unblock. That fixed it for me.

              Comment


              • #8
                I've discovered that some topics don't open, some do, and some if you double click the Index item it opens a message box listing the first topic and the double clicked topic and you can click on the topic in the message box and it will open. Working on it.

                There doesn't seem to be an issue if you click on an item in the Table of Contents.

                My response here assumes that you've attached to the IDE. Is the *.PBKeys in the \bin directory?
                Rod
                "To every unsung hero in the universe
                To those who roam the skies and those who roam the earth
                To all good men of reason may they never thirst " - from "Heaven Help the Devil" by G. Lightfoot

                Comment


                • #9
                  This is a great idea, thanks Rodney!
                  www.pluribasic.com

                  Comment


                  • #10
                    A great and very useful addition to the PB toolbox - thank you for this generous contribution, Rodney!

                    Comment


                    • #11
                      You have done some good work there Rod, compliments.
                      hutch at movsd dot com
                      The MASM Forum

                      www.masm32.com

                      Comment


                      • #12
                        Thanks for looking at this everyone. Hope to improve it down the road!

                        Hints, suggestions, guidance are all welcome, as are more macros.
                        Rod
                        "To every unsung hero in the universe
                        To those who roam the skies and those who roam the earth
                        To all good men of reason may they never thirst " - from "Heaven Help the Devil" by G. Lightfoot

                        Comment


                        • #13
                          Still weeks away from completion, still wanting suggestions and more MACROs, an image of the work-in-process to encourage those suggestions and code.

                          I find that when I wake up, that my 'beta tester' has been sleeping on the job.
                          Click image for larger version

Name:	MACROHELP_ver2.gif
Views:	76
Size:	27.1 KB
ID:	777946
                          Rod
                          "To every unsung hero in the universe
                          To those who roam the skies and those who roam the earth
                          To all good men of reason may they never thirst " - from "Heaven Help the Devil" by G. Lightfoot

                          Comment


                          • #14
                            I find that when I wake up, that my 'beta tester' has been sleeping on the job.
                            Ha Ha Rodney

                            Also Designer, Engineer, Graphic Artist, Accountant, Assembler Team, Inspector, Researcher, Proposal Developer and the list goes on and on...

                            Comment


                            • #15
                              Hi Rodney

                              One thing to make sure of with the macros is that they don't have a subtle bug when being passed a mathematical expression rather than a value.
                              To prevent this, judicious use of parentheses around the individual arguments will force the intended operator precedence.

                              For instance, the following macro has an unintended bug.
                              macro DoubleIt( x ) = x * 2

                              What happens when the above macro is used like this?
                              ? DoubleIt(25+2)

                              It prints out 29 because that's 25 + 2 * 2
                              But the programmer intended it to mean (25 + 2) * 2.

                              I noticed a few macros in the collection that shared this little flaw.

                              The fix is to define it like this:
                              macro DoubleIt(x) = (x) * 2

                              In fact, more correct would be...
                              macro DoubleIt(x) = ((x) * 2)

                              And then the macro is truly safe to be used inline in the middle of a bunch of surrounding expressions.

                              Thank you for the excellent utility. Its a keeper.








                              Comment


                              • #16
                                Thanks Ross!

                                I'd already included Parenthesis under 'Quirks and Kinks' to deal with what I believe to be a slightly different issue. I might have been looking at it backwards or sideways and it's the same issue but you've described it more clearly.

                                I put most of the macros through the compiler to be sure they compile before putting them in the collection but I haven't been checking to see that the result is what is meant, partly because some of them are pretty specific in areas that I know very little about. (Do you know how it hurts for a know-it-all like me to use the phrase 'I know very little about'? )

                                I had wanted to leave macros as untouched as possible but it makes no sense to put failing macros in so I will be making the change you suggested where obviously applicable, Ross.

                                Thanks again.
                                Rod
                                "To every unsung hero in the universe
                                To those who roam the skies and those who roam the earth
                                To all good men of reason may they never thirst " - from "Heaven Help the Devil" by G. Lightfoot

                                Comment


                                • #17
                                  Rod,

                                  These are worth including as well.

                                  Code:
                                    ' --------------------------
                                    ' allocate executable memory
                                    ' --------------------------
                                      MACRO FUNCTION exalloc(bcnt)
                                      END MACRO = Virtual_Alloc(0,bcnt,MEM_COMMIT or MEM_RESERVE,PAGE_EXECUTE_READWRITE)
                                  
                                      MACRO FUNCTION exfree(hmem)
                                      END MACRO = Virtual_Free(hmem,0,MEM_RELEASE)
                                    ' --------------------------
                                  
                                      MACRO memalign(mem,amem,align)
                                        ! mov eax, mem
                                        ! mov amem, eax
                                        ! add amem, align-1
                                        ! and amem, -align
                                      END MACRO
                                  hutch at movsd dot com
                                  The MASM Forum

                                  www.masm32.com

                                  Comment


                                  • #18
                                    These are worth including as well.
                                    Yes they are, thank you very much!
                                    Brings me to 1077 macros, out of which I've got 42 formatted, so I'll be a week or two or twelve getting this done.

                                    More content always welcome!
                                    Rod
                                    "To every unsung hero in the universe
                                    To those who roam the skies and those who roam the earth
                                    To all good men of reason may they never thirst " - from "Heaven Help the Devil" by G. Lightfoot

                                    Comment


                                    • #19
                                      Rod,

                                      The macros were incomplete, here is the rest of the data for the 2 macros. I use different prototyping to normal and do the equates as macros so they don't conflict with the supplied ones.
                                      Code:
                                        ' -------------------
                                        ' VirtualAlloc macros
                                        ' -------------------
                                          DECLARE FUNCTION Virtual_Alloc LIB "Kernel32.dll" ALIAS "VirtualAlloc"( _
                                                           BYVAL lpAddress AS DWORD, BYVAL dwSize AS DWORD, _
                                                           BYVAL flAllocationType AS DWORD, BYVAL flProtect AS DWORD) AS DWORD
                                      
                                          DECLARE FUNCTION Virtual_Free LIB "Kernel32.dll" ALIAS "VirtualFree"( _
                                                           BYVAL lpAddress AS DWORD, BYVAL dwSize AS DWORD, _
                                                           BYVAL dwFreeType AS DWORD) AS DWORD
                                      
                                          MACRO MEM_COMMIT  = &H00001000
                                          MACRO MEM_RESERVE = &H00002000
                                          MACRO MEM_RELEASE = &H00008000
                                          MACRO PAGE_EXECUTE_READWRITE = &H40
                                      
                                        ' --------------------------
                                        ' allocate executable memory
                                        ' --------------------------
                                          MACRO FUNCTION exalloc(bcnt)
                                          END MACRO = Virtual_Alloc(0,bcnt,MEM_COMMIT or MEM_RESERVE,PAGE_EXECUTE_READWRITE)
                                      
                                          MACRO FUNCTION exfree(hmem)
                                          END MACRO = Virtual_Free(hmem,0,MEM_RELEASE)
                                        ' --------------------------
                                      hutch at movsd dot com
                                      The MASM Forum

                                      www.masm32.com

                                      Comment


                                      • #20
                                        I use different prototyping to normal and do the equates as macros so they don't conflict with the supplied ones.
                                        This and other reasons for macros. I knew, yet I didn't realize just how varied the reasons are for using macros. Putting them all in one place has shown me some subtle differences.

                                        Thanks again!
                                        Rod
                                        "To every unsung hero in the universe
                                        To those who roam the skies and those who roam the earth
                                        To all good men of reason may they never thirst " - from "Heaven Help the Devil" by G. Lightfoot

                                        Comment

                                        Working...
                                        X