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

Getting Field Names/Types/and Current Table from Current Field

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

    Getting Field Names/Types/and Current Table from Current Field

    I am trying to write a Function so I can take many steps and reuse the code for dozens of other fields, however my knowledge is limited and I would like the syntax (if it can be done) to following question s:


    In an on arrive event of a field on a form based on a set:
    1. Set a pointer variable to the table in use of the field I am in (could be a child table)
    2. Put the field name in a variable of the field I am in
    3. Get the type of field i.e. C for a character field into a variable for the field I am in.
    4. Dim and set a variable to the current field value based on the type of field acquired above.
    Now
    In an on change event of the same form/field based on a set
    1. Dim and Set new variable to get the new value of the field (prior to saving)
    2. Compare the 2 variables with the original and unchanged and determine if they are the same or different. (would it matter what type of field this is, could you just use an = test say if it were a time field?)

    This is to create an audit function different from the built in one. I have it working using action scripting on one field, but I want to make it universal using variables. Thank you in advance.

    #2
    Re: Getting Field Names/Types/and Current Table from Current Field

    You may be re-inventing the wheel. Dr. Wayne presents an elegant and complete audit trail script in his book.

    Comment


      #3
      Re: Getting Field Names/Types/and Current Table from Current Field

      Tom,
      I have some unique requirements, one being use of a PIN code on each change. I purchased one of his books with v5 a long time ago and I'll be damned if I know where it is now. I'll take a look for it, but I would be interested in the syntax for some of the above as I cannot find it.

      Comment


        #4
        Re: Getting Field Names/Types/and Current Table from Current Field

        1. object.table_get()
        2. field_pointer.name_get()
        3. field_pointer.type_get()

        The rest should be easy.

        Perhaps if you spent some time with the documentation before you need to find something it might not be so difficult.
        There can be only one.

        Comment


          #5
          Re: Getting Field Names/Types/and Current Table from Current Field

          Originally posted by Tom Cone Jr View Post
          You may be re-inventing the wheel. Dr. Wayne presents an elegant and complete audit trail script in his book.
          Which one Tom?
          See our Hybrid Option here;
          https://hybridapps.example-software.com/


          Apologies to anyone I haven't managed to upset yet.
          You are held in a queue and I will get to you soon.

          Comment


            #6
            Re: Getting Field Names/Types/and Current Table from Current Field

            Hi, Ted.

            I first saw it in 2002 in "Application Programming in Alpha Five Version 5", and believe it has been carried forward and appears in all later editions.

            Last book I can recall is named something like "Xbasic for Everyone, 2008".

            == tom

            Comment


              #7
              Re: Getting Field Names/Types/and Current Table from Current Field

              Thank you Stan,
              In my defense, I have been a novice alpha user since the dos days. I have done 95% of what I do through action scripting. I just upgraded to v11 and the only help available was the wiki which is terminally confusing. I have been through several books over the years and the manuals which are very difficult. I scour this board. I wish there was a way to have an area for simple examples. Usually the examples are far to complicated for me to understand. I am a pilot normally and pickup alpha every year or so when I need something else and I am back in a learning curve each time. The number of functions is great, but knowing which one to use is difficult. Now with the wiki I do not even know how to find just a list of functions. I am sorry for asking very simple questions, but when I spend an entire day trying to figure out what you listed in seconds, it just shows my lack of knowelege here. I am sorry to annoy you, but I really am spending a lot of time trying to learn. The Peter Wayne example is so complicated to me. I can't wrap my head around how it works. I really appreciate all the help I have received over the years and I promise, I try to research before I post.

              Comment


                #8
                Re: Getting Field Names/Types/and Current Table from Current Field

                My point is that if you spend some time just looking through the wiki then you have a better understanding of how it is organized and how to find what you want. If you take the time to explore any of the sub topics, even better.

                Just wondering if you have seen...

                Functions and Methods by Type
                How Do I...
                How To
                There can be only one.

                Comment


                  #9
                  Re: Getting Field Names/Types/and Current Table from Current Field

                  Stan,

                  The problem with the above functions is you cannot get all the pieces of information without the other. To get the table name you have to specify a field name. To get a field name, you have to specify the table name. I would like to get all of this info based on the field the cursor is in.

                  I am at a road block, if I specify the field name myself in a variable, how can I use it in a function?
                  fname="water_status"
                  tbl = table.current()

                  fld = "tbl."+var->fname+".this"

                  If I want to set fld as a pointer and use the fname variable in the function, what is the syntax for this??
                  Last edited by johngtatp; 02-03-2012, 04:51 PM.

                  Comment


                    #10
                    Re: Getting Field Names/Types/and Current Table from Current Field

                    Originally posted by johngtatp View Post
                    ...In my defense, I have been a novice alpha user since the dos days. I have done 95% of what I do through action scripting. I just upgraded to v11 and the only help available was the wiki which is terminally confusing. I have been through several books over the years and the manuals which are very difficult. I scour this board. I wish there was a way to have an area for simple examples. Usually the examples are far to complicated for me to understand. I am a pilot normally and pickup alpha every year or so when I need something else and I am back in a learning curve each time.
                    I know exactly how you feel. My sentiments (and situation almost to a "T.") ~I did finally "get there though."
                    (FYI: My brother in law, happens to be a pilot also. In his previous job, he was piloting the fastest non military jets made. ~ Which were "de-tuned" to keep the sub-sonic, so I'm told!)

                    The wiki is better than it used to be. (or at least I'm finding out how to get to what I need).... Regardless, your suggestion for simple "CORE EXAMPLES" is outstanding. (IMHO) ~ The wiki does includes core functions, so how about "CORE CODE EXAMPLES" of how to do the basics? 6 lines of code to at least get you started. Just doing a "blind search" for something in the wiki honestly reminds me of those MS "Bing" commercials!

                    That being said, how did STARCS turn out?
                    Robert T. ~ "I enjoy manipulating data... just not my data."
                    It's all about the "framework." (I suppose an "a5-induced" hard drive crash is now in order?)
                    RELOADED: My current posting activity here merely represents a "Momentary Lapse Of Reason."

                    Comment


                      #11
                      Re: Getting Field Names/Types/and Current Table from Current Field

                      fld = eval("tbl."+var->fname+".this")
                      There can be only one.

                      Comment


                        #12
                        Re: Getting Field Names/Types/and Current Table from Current Field

                        Originally posted by Stan Mathews View Post
                        fld = eval("tbl."+var->fname+".this")
                        This gets you the value of the field, but then you have to use it.....
                        (If I'm understanding you correctly.)

                        Interestingly enough, I just was involved with a post that may be somewhat relevant. If you're curious, click here.

                        It revolved around the whole concept of record fields not being "an actual addressable collection using the FOR EACH construct" ~ (that you could directly reference by a pointer in a FOR EACH, which you apparently can't)..... The work around was to loop through the fields. (looking for a match in your case to the variable containing the field name)


                        BUT WAIT: Here's a way to get POINTER access to the field the way you want: <TBL>.FIELD_GET()

                        This table method returns a pointer to the field using either Numeric input (field number) or Character input (field name) ie: <TBL>.FIELD.GET(vc_FieldName) (Once you get the field name into a variable using Stan's code.)

                        More info is here: http://wiki.alphasoftware.com/Table+...ns+and+Methods


                        Now, what to do with a pointer pointing to a field? ~ I wonder if you can do something like this:
                        After using getting the field reference into pointer vp_TblField using <TBL>.FIELD_GET(fld)......

                        'open table, for changing records or whatever you want to do and then........
                        vp_TblField.this = "NewValue"
                        'close table.....


                        If this in fact works as anticipated, I hope someone else will confirm!!!!

                        PS: John, the way I figure this stuff out is to use the X-basic explorer. To get to the good stuff (with popup help) I:
                        1. Bring up the Interactive window
                        2. Navigate to Objects->System
                        3. Drag & drop the function/method or object into the IW. (Interactive Window)
                        4. Right click between the parenthesis for popup help.


                        NOTE: If you navigate to Objects->Window in the XbE and "drag and drop from there. (X-basic Explorer)... You don't always get the bubble help.
                        Last edited by SNusa; 02-03-2012, 07:36 PM.
                        Robert T. ~ "I enjoy manipulating data... just not my data."
                        It's all about the "framework." (I suppose an "a5-induced" hard drive crash is now in order?)
                        RELOADED: My current posting activity here merely represents a "Momentary Lapse Of Reason."

                        Comment


                          #13
                          Re: Getting Field Names/Types/and Current Table from Current Field

                          Stan,
                          Thanks for the syntax.

                          Robert,
                          StarCS is what I am still working on a year later. I put it on the shelf anticipating someone in my industry would create workable software. This has not come to fruition so I am again resurecting the dead, so to speak. I have the nuts and bolts but I need to assemble it all. The final major hurdle is the audit function which I was able to create using about 15 action scripting items and some xbasic for one field, however I want to make this into a function so I can use it for all fields. The big rub for me was that I have 4 tables in a set on the same screen for editing. and I needed a way that a user's changes can be tracked without logging someone in and out at a common workstation. I need to be able to determine the table that is being edited, so I can determine the field name and so my problems goes. using variable's in functions throws me. I cant see when to use " or ' or + or the eval function. I use trial and error which takes forever. I could not see any good help for this either, any ideas here? Thanks for your help to date, and I will get there, I just want it to be sooner than later.

                          Comment


                            #14
                            Re: Getting Field Names/Types/and Current Table from Current Field

                            Between quotes, you get text.
                            Outside quotes, you get calculations.
                            Using single quotes inside double quotes simulates "quoted regions inside of quotes." ~ There's another way too.
                            (Explained at bottom which applies to filters/queries.

                            In your example above, if fname="FirstName" and tbl is a pointer to table customers: fld = "tbl."+var->fname+".this" looks like this to Alpha:
                            fld = "customers.FirstName.this" which is a character field. ~Hence your original problem of how to get the field name, instead of creating a string variable.

                            Note: Since var->fname is equal to "variable pointing to fname", which in X-basic is actually fname.... It could optionally be written as: fld ="tbl." + fname + ".this") Even so, you still don't want a concatenated text string. You want to get what that text string represents / or stands for. So you evaluate it using eval()!

                            The eval() function turns a character based value into it's mathematical "equivalent." eval("000007") = 7 It can also evaluate "pointer references" ( -> ) into usable X-basic code. Example: eval(var->vc_LastName) is the same as vc_Lastname. (the expression builder also uses these ( -> ) "pointers" when pointing to record field values)

                            In Stans example: fld = eval("tbl."+var->fname+".this") is taking the string, and evaluating it into the value. or could have been written: eval("tbl."+fname+".this") Adding the ".this" (I'm pretty sure) results in the string representing the name of the field itself, as opposed to the value in the field.

                            Quotes are always read from left to right. (Every time you see a pair, the stuff in between is taken at character value.) ~Anything between the quotes is taken as literal. Anything outside of the quotes is processed.

                            Also: If vc_value = 7, then eval("var->vc_value") also returns the value of 7 (eval changes the pointer stuff to work in X-basic scripts too.)

                            Whenever you use var->something, it probably needs to be enclosed in eval("") in X-basic code. I don't like the -> pointers and try to do it directly.
                            Think of var->something (or anything else with the little -> pointer as: "this points to that" or in this case, var pointing to value in vc_value. & since X-basic doesn't understand the code expressed as "var points to vc_value variable" you have to either re-write it as =vc_value, or "evaluate" it like this eval("var->vc_value")

                            Note: There is a difference between variables dimmed as pointers which point to objects, and the "->" (which to means "points to").... Although now I'm second guessing myself..... Could the var->anyVariable, and the "form fields"->table data actually represent pointers pointing to objects??????? HMMMM.....

                            _______________________________________________________________

                            QUERIES (filters) are a bit more confusing to understand why and how to write them, but here goes:
                            If you want quotes inside quotes, (like for using filters) you can also use the backslash: query.filter = "STATE = "\"MA\"" - Alpha writes it this way. I don't like it. (which is also the same as query.filter ="STATE ='MA'"
                            When using a variable in a query, you would write it as: query.filter ="STATE='"+vc_State+"'"

                            FYI: The single quotes above designate a character field within the Query.


                            Since using quotes w/SQL queries (filters) can be difficult to understand, here's some additional help:
                            http://www.learn alpha.com/querysynt...axglossary.htm
                            Actually, all the articles here (some old) are still very useful: http://www.learn alpha.com/menubar.htm
                            A bunch of other great material is also available here: http://www.csda1.com/csda_codeutilit...lity_Tips.html
                            Advanced SQL (linked tables) here too: http://www.downloads.alphasoftware.c...SQLTables.html
                            Last edited by SNusa; 02-04-2012, 02:22 AM.
                            Robert T. ~ "I enjoy manipulating data... just not my data."
                            It's all about the "framework." (I suppose an "a5-induced" hard drive crash is now in order?)
                            RELOADED: My current posting activity here merely represents a "Momentary Lapse Of Reason."

                            Comment


                              #15
                              Re: Getting Field Names/Types/and Current Table from Current Field

                              John, could you take time to explain why the Audit Trail doesn't work for you?
                              Is the ID something that could be bundled into the security suite?
                              See our Hybrid Option here;
                              https://hybridapps.example-software.com/


                              Apologies to anyone I haven't managed to upset yet.
                              You are held in a queue and I will get to you soon.

                              Comment

                              Working...
                              X