Announcement

Collapse
No announcement yet.

Finding the Value of an Equate

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

  • Finding the Value of an Equate

    Givens:
    Code:
    %Equate1 = 123
    %Equate2 = 456
    The names of the equates are read from a text file. Is it possible to retrieve the value of an equate when only its name is known?

    Example:
    Read from file: Equate1 or %Equate1

    Needed:
    The value assigned to Equate1

  • #2
    No, the equate names are only known in source code and lost when compiling (the actual values are used, so var = %TRUE becomes var = 1). You would need a translation table or other method to match up the names with the values.
    kgpsoftware.com | Slam DBMS | PrpT Control | Other Downloads | Contact Me

    Comment


    • #3
      Thanks Kev!

      I'll now move on to plan B.

      Comment


      • #4
        Walter,
        On the off chance I am wrong
        Are you looking at possibly scripting your code and need to know what the equate equals?

        I could be WAYYYYyyyyy off or maybe too close for comfort, but the answer is most likely what Kev said.

        Just thought I would ask.
        Engineer's Motto: If it aint broke take it apart and fix it

        "If at 1st you don't succeed... call it version 1.0"

        "Half of Programming is coding"....."The other 90% is DEBUGGING"

        "Document my code????" .... "WHYYY??? do you think they call it CODE? "

        Comment


        • #5
          > I'll now move on to plan B.

          You know, there are some tables and code to use them pre-built for you, specifically for Windows' WM_xxxxx notification messages.

          Look in source code forum, sorry don't know quite what to use for keywords.

          OR....
          in the samples\util\WinMsg folder there is a DLL with that table pre-built as a STRINGTABLE resource, with code to use it.

          OR..
          You can parse your source code with something like....
          File Convertor: resource.H to resource.EQU February 3 2001... and from that build a table of all equates in your data source with their values and a manufactured name.

          I'm having difficulty imagining what you are trying to accomplish.. specifically in what type of data source you would have 'names' of equates and from that you want to get the value. (I can see going the other way).

          Perhaps if you shed a little extra light on your application, someone will suggest plans "C" and "D" for your consideration.
          Michael Mattias
          Tal Systems Inc. (retired)
          Racine WI USA
          [email protected]
          http://www.talsystems.com

          Comment


          • #6
            I'm not sure if this is what are looking for but this compiles and runs just fine in CC5. Should work in PB/win.
            Code:
            #COMPILE EXE
            #DIM ALL
                %test = 3
            FUNCTION PBMAIN () AS LONG
                LOCAL a AS LONG
                a = %test
                PRINT;a
                WAITKEY$
            END FUNCTION
            There are no atheists in a fox hole or the morning of a math test.
            If my flag offends you, I'll help you pack.

            Comment


            • #7
              Originally posted by Michael Mattias View Post
              >

              I'm having difficulty imagining what you are trying to accomplish.. specifically in what type of data source you would have 'names' of equates and from that you want to get the value. (I can see going the other way).
              I use this approach in a script engine.

              James

              Comment


              • #8
                Thanks for the answers.

                Apparently, I didn't make my self as clear as I should have. So, I'll give it another go.

                The equates in the .inc file are device register names and their numerical equivalents.

                Code:
                %RegisterA = &h00
                %RegisterB = &h01
                '...
                %RegisterZ = &1A
                The data to be placed in the registers is read from a text file that is structured as follows:
                Code:
                RegisterA, 1D
                RegisterB, AA
                '...
                RegisterZ, 3F
                The data in the file may appear in any order as long as the register to data relationship is maintained.

                FWIW the solution was to create a DATA table with all of the register names.
                and READ$ the data into a string array indexed to the .inc file.
                Code:
                STATIC RegTable AS STRING
                
                DIM RegTable(%RegisterA TO %RegisterZ)
                
                FOR i = %RegisterA TO %RegisterZ
                       RegTable(i) = READ$(i)
                NEXT i
                As each data block is read from the file, it is parsed and RegTable is searched for a match. When a match is found the index of the match becomes the register number.

                It's amazing what a few cups of coffee will do for you. :coffee4:

                Comment


                • #9
                  Good solution. Funny I often overlook using DATA statements!
                  kgpsoftware.com | Slam DBMS | PrpT Control | Other Downloads | Contact Me

                  Comment


                  • #10
                    Scratch it. Just reread the thread.
                    It's a pretty day. I hope you enjoy it.

                    Gösta

                    JWAM: (Quit Smoking): http://www.SwedesDock.com/smoking
                    LDN - A Miracle Drug: http://www.SwedesDock.com/LDN/

                    Comment

                    Working...
                    X