Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

What is the difference in these two for accessing table fields

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

    What is the difference in these two for accessing table fields

    I was looking at some code I have on a button onpush event and I was wanting to know what the difference was between these two approaches as I only need to access one field of the table in this case.

    Option 1

    dim vOptr as p
    vOptr = table.get("order")
    vID = vOptr.ID


    Option 2

    vID - order->ID

    Thanks,
    Jeff Ryder

    #2
    Re: What is the difference in these two for accessing table fields

    Option 1

    dim vOptr Variable field name as p Pointer(table indicator)
    vOptr = table.get("order") Pointer = open(get) a table which is "order"
    vID = vOptr.ID a Variable field equals the "ID" field value from "order" table which mentioned above. It will get a current record field value.

    Code:
    Option 2
    
    vID - order->ID [COLOR="Blue"]I guessed. A Variable Field minus order table Id field [/COLOR]
    More detail, please check with the Alpha Help.

    Comment


      #3
      Re: What is the difference in these two for accessing table fields

      John,

      The second option was a typo. It should have been

      vID = order->ID


      I should have been clearer on my question. Both pieces of code return that same result. Is one solution better than the other to do simple access to a table field. The first option takes 2 or three lines of code including a function call to get the table pointer so is option 2 better in that case when all I need it to access one field of a table?
      Jeff Ryder

      Comment


        #4
        Re: What is the difference in these two for accessing table fields

        Jeff,
        so is option 2 better in that case when all I need it to access one field of a table?
        I think, No because Alpha will not understand your scrip simple as "variable field = table field name".

        The script is not that simple. I wish that Alpha has this simple as you hop.

        You have to think about the LEVEL of events when you write the scripts on the EVENTS

        There are Table's Events and other than table (Form, a field, object, browse...report) Events.

        Comment


          #5
          Re: What is the difference in these two for accessing table fields

          The 1st is explicit, the 2nd is implicit (variable assignment). The 2nd method uses a much older form of syntax, the 1st method uses the more modern (more flexible) dot variables.
          Peter
          AlphaBase Solutions, LLC

          [email protected]
          https://www.alphabasesolutions.com


          Comment


            #6
            Re: What is the difference in these two for accessing table fields

            profiler_begin()
            Originally posted by jaryder View Post
            I was looking at some code I have on a button onpush event and I was wanting to know what the difference was between these two approaches as I only need to access one field of the table in this case.

            Option 1

            dim vOptr as p
            vOptr = table.get("order")
            vID = vOptr.ID


            Option 2

            vID = order->ID

            Thanks,
            Virtually no difference.

            You may possibly run into issues with one or the other if there are table alias names involved but, other than that possibility (maybe), they are just different ways of getting the same thing.

            Similarly,
            parentform:tables:order.ID
            and
            tp = table.current(N) (N is the table number in a set)
            tp.order = ....
            would also give the same result.

            Most people probably don't know for sure which table number they are referring to unless it's the parent table in the set. As a result, you probably won't see the table.current(N) method used very often except as plain table.current() which refers to either the current table or the parent table in a set - whichever is applicable. (FYI: table.current(0) is the same as table.current().)

            As far as I'm concerned, the choice is mostly a matter of what seems best at the moment....

            - If I'm writing code in a table event (CanSave etc.), I'll use tc = table.current() because I know that will always refer to the table the event is associated with - regardless of any alias names.

            - Most of the time I create a pointer to the table - especially if I will be referencing a lot of fields (or a small number of fields many times). I prefer one of the 'pointer' methods because it keeps typing to a minimum. My typical table pointer is just "tp" if only one table will be referenced in the script or something like "tpa" for the Agents table if multiple tables are referenced.

            - I seldom use the order->ID format just because it's too difficult to type. The table name is longer than my pointer names and the "dash / greater than" arrow is a bit awkward to type. ALSO, I've run into problems in the past with table alias names when using this method.
            (In certain situations A5 creates an alias name even if you didn't specify one. This is when it's an issue. Disclaimer: I don't use this method very often so don't know if it is still as much of an issue or not. Some of my coding experiences go back to A5v1. Once I find something that fixes a problem, I tend to stick with it unless another problem comes up. This is one of those "it used to cause me a problem so now I stay away from it" issues.)

            - I use the parentform:tables:order.ID method more often now than I did in the past. Not a lot but more often. In particular, I like this when the needed field is not on the parent form. The same thing could be probably be accomplished with order->ID BUT, one thing you can't do with the order->ID method is get the record number. Occasionally I've needed the current record number and that can be retrieved with something like parentform:tables:order.recno(). You could also get the same thing with table.get("order") but that would require an extra line of code to set the table pointer first. (Sometimes you can use just table.get("order").field_name if you don't want to set a separate pointer but I've also found that this method doesn't always work so I never do that anymore - I like reliability. This is also another of those "it used to cause me a problem so now I stay away from it" issues. Maybe it works reliably now; maybe it doesn't. I don't care; I won't use it.)

            NOW, if you were asking about table.open() - that would be another story completely. That is NOT the same as any of the above. I presume you already figured that out.

            Final comment: Some of my "easier to type" comments may not make sense at first. One of the factors in my "easy to type" requirements is my use of keyboard macros. Something like parentform:tables: is very easy for me to type - I just press "jjpt". (I find "shortcut keys" easier to remember than hot keys and all my shortcut keys begin with "jj" because it's both fast and unique.)

            Comment


              #7
              Re: What is the difference in these two for accessing table fields

              Cal,

              Thank you for all your insights. I was going through existing event code and converting code say over 5 lines long to function calls as suggested in a prior thread along with cleaning up code that was written when I was new to Alpha. So I was analyzing the code and all I really need to do is set a global variable to the current customer ID and then zoom to a form.

              Here is something I had not tried before before but seems to work.

              gID = table.get("arcustomer").ID (later I guess I won't use this method. Missed it the first time I read your response)

              I am still partial to

              gID = arcustomer->ID

              Up to this point I have always used a table pointer to access my fields but just thought to look at other options when I only need to access a single table field and do no other manipulation to the table withing my code block.
              Last edited by jaryder; 09-24-2009, 10:41 PM. Reason: added notes
              Jeff Ryder

              Comment


                #8
                Re: What is the difference in these two for accessing table fields

                jaryder,

                If it's worth anything, a good while ago I sent in a error report to A5. Mr. Slewyn Rabins was kind enought to reply it was fixed-would be in next release. He also made the comment that he noticed I was using the "var = table->field" technique to assign variables quite alot. He commented "never use this technique. it may work, but was not designed for this and can cause problems. use instead the table pointer technique." I wrote him to comment further on what he meant by - "was not designed for and can cause problems." But, he's a busy fellow so I took it at face value and never use it. I've never run across a thread here that deals with problems or reliability of "var = table->field," but I have'nt really taken the time to research it.

                Comment


                  #9
                  Re: What is the difference in these two for accessing table fields

                  Originally posted by jaryder View Post
                  .... Here is something I had not tried before but seems to work.

                  gID = table.get("arcustomer").ID (later I guess I won't use this method. Missed it the first time I read your response)
                  I won't say you should never use it but just be aware that sometimes it may not work. If you do use it, test it before distributing the app/update. I think this is one of those where it either works or doesn't work. That is to say, if it works in your testing, it should work for your users. As best I can recall, the few times it didn't work for me, I found the problem during initial testing. (I've always wondered if it was some kind of 'timing' issue???)

                  As I implied in my previous post, many of these issues I've seen may have been just something I ran into in a specific version or build of A5. So, take my warnings with a grain of salt - be aware of them but I encourage you to verify them for yourself and use what works for you.

                  Comment


                    #10
                    Re: What is the difference in these two for accessing table fields

                    Cal,
                    Thanks for this insight.
                    I use the parentform:tables:order.ID method more often now than I did in the past..... In particular, I like this when the needed field is not on the parent form.
                    I am assuming this would preclude having to put multiple fields (hidden) on a form????
                    Ernie
                    PS Don't know why that smiley face is showing up.

                    Comment


                      #11
                      Re: What is the difference in these two for accessing table fields

                      Originally posted by enstorms View Post
                      Cal,
                      Thanks for this insight.

                      I am assuming this would preclude having to put multiple fields (hidden) on a form????
                      Ernie
                      PS Don't know why that smiley face is showing up.
                      Yup!

                      (The smiley face is showing up because you have a combination of colon, semi-colon, parenthesis, etc. that represents that smiley face. To stop that in any specific message, scroll down to the Additional Options section and check the Disable smilies in text option.)

                      Comment


                        #12
                        Re: What is the difference in these two for accessing table fields

                        Good morning

                        I had the errors on here.

                        Comment


                          #13
                          Re: What is the difference in these two for accessing table fields

                          Change

                          table.get("trans_head")

                          to

                          table.current()

                          or attach a sample table so we can see what is happening. Just duplicate the table and zap it if you have sensitive data.
                          Last edited by Stan Mathews; 09-25-2009, 10:31 AM.
                          There can be only one.

                          Comment

                          Working...
                          X