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

Using a script variable in a field rule...

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

    Using a script variable in a field rule...

    Ok here is my problem. I need to use a global script variable ( called shp2a ) in the default value expression.

    The problem I am having is that the default value expression does not recongise where the variable (shp2a) is located and kicks and error about unrecognisable varaible error. I understand why its kicking the error but I dont know how to solve it.

    Here is the default value expression I am using:
    if(shp2 "" 'BRKR', "t", shp2a)


    How can I specify to A5v6 that shp2a is a global script variable?


    I will be glad to post any file or information needed. Just ask.


    Thanks for taking the time to look at this question.

    Mike Monk

    #2
    RE: Using a script variable in a field rule...

    Go back and define your table structure again. Click on the Variables icon on the toolbar and set the variable up there as well.

    - Steve
    -Steve
    sigpic

    Comment


      #3
      RE: Using a script variable in a field rule...

      Just for additional information, the script will always be ran before the user enters a new record into the table so shp2a should exist in memory even if its blank.

      Comment


        #4
        RE: Using a script variable in a field rule...

        Thank You Steve.

        Solved that problem in a rather quick fashion. Thank You Sir!

        I am still trying to get my balance in the A5 developement enviroment.

        Comment


          #5
          RE: Using a script variable in a field rule...

          I would dim that variable as part of the autoexec script.

          Bill Belanger

          Comment


            #6
            RE: Using a script variable in a field rule...

            Ok. I thought that solved my problem but it did not.

            I have attached an experimental table with 2 field and tried to define the field rule as stated above.

            not sure why its not working. Take a look at your leisure.

            Comment


              #7
              RE: Using a script variable in a field rule...

              I would prefer not to set it up in my autoexec. This variable wont always be used every session and there are about 12 variable I have to use like this.

              I just dont want to waste system resources if possible.

              Comment


                #8
                RE: Using a script variable in a field rule...

                I guess the question i now have is can you just put the global variable name in the default field expression?

                I created a globabl variable called shp2a.

                The default value expression i have:
                shp2a



                It says it evaluates to a character and it even shows the value I assinged to shp2a when I am in the "expression builder". But when I try to save the field rules, It says it can't find the field shp2a. Which is correct its not a field its a global variable.


                I am sorry to be spamming the board with this issue.

                Comment


                  #9
                  RE: Using a script variable in a field rule...

                  OK I FINAALLY got how to use the global variable.

                  In the "expression builder" you have to press F6 to bring up the Variables menu ( the option isnt shown on my expression builder ) but it does work if you hit F6.

                  This is how you specify variables not fields in the expression builder for field rules:
                  Var-"varaibleNameHere


                  Thanks for all the help guys :)

                  Comment


                    #10
                    RE: Using a script variable in a field rule...

                    Hello Mike,

                    ""This variable wont always be used every session and there are about 12 variable I have to use like this. ""

                    I'm jumping into this thread late, but have a couple of thoughts. First 12 variables would not be any overhead to be concerned about.

                    Another way to go about this that will give you much more flexibility would be to create a User Defined Function (UDF). A UDF can be used in almost all places that a regular built-in A5 function can be used. So you could create a UDF that first checks for the existance of your variable, and if it exists, returns the value, otherwise it could return "" or nothing. Then you just put a function call in the field rule. Now rather than being limited to building expressions, which can get messy if they are long, you now have all the power of Xbasic and or Action Scripting available to create your field rule expressions.

                    Good luck,
                    Jim

                    Comment


                      #11
                      RE: Using a script variable in a field rule...

                      That is a great idea. I think I will look into that as it will solve my problems in possibly the best way.


                      I took C++ programming classes and they just drilled into my head GLOBALS = BAD. So I try to avoid them at all times if possible. If the situation calls for a global I use them, but if I can get away without it I will.

                      Thanks for the idea and explination.

                      Comment


                        #12
                        RE: Using a script variable in a field rule...

                        Mike:
                        I am not following nor understanding your logic:
                        Stop and think about this for a minute:
                        1-If the default value of a field is the outcome of an expression, and
                        2-If the outcome of the expression depends on the value of a variable, then
                        One must wonder, what sets the value for that variable? The answer most likely would be: Some parameters, some other field value(s), or some user's input, right?
                        If the outcome of the expression depends on the variable and the variable depends on one or more of those parameters, wouldn't be logical to make the expression dependant on those parameters in the first place?
                        Can you outline how is the value of this variable determined??
                        Thanks
                        Gabe

                        Comment


                          #13
                          RE: Using a script variable in a field rule...

                          Hello Mike,

                          ""I took C++ programming classes and they just drilled into my head GLOBALS = BAD""

                          :-) I wouldn't phrase them as "BAD", but in general don't declare a variable as global unless it is really needed.

                          IMHO, the issue is not overhead, although I suppose if you were declaring 10's of thousands, it might become as issue. The issue is persistence of the values. For instance, Alpha has several built-in variables, specifically they have the:

                          query.*

                          dot variable family to pass info to the TablePointer.query_create() method. So if you do:

                          t1 = table.open("table1")
                          query.filter = "FieldName = 'My Data'"
                          t.query_create()

                          You have sucessfully executed a query on table one. Now in some other location you define:

                          t2 = table.open("table2")
                          t.query_create()

                          Forgetting to redefine the global query.filter for the second situation, the query on the second table will be in error.

                          Another common situation with globals is that you declare multiple variables in various places in the app. You forget that you have already dim'med a variable named: MyVariable, now later on you dim another variable with the same name. If they are globals, you second declaration and assigned value could effect the procedure you have in place using the first variable, etc, etc.

                          So in general, don't use globals unless it is appropriate to use them :-) ie: use them sparingly.

                          Good luck,
                          Jim

                          Comment


                            #14
                            Re: Using a script variable in a field rule...

                            Hello Jim-

                            The advice about setting up UDF and Action script is probably what I need. I am having the exact same problems except I have about 50 fields in which the possibility of the field name and value will not be present. Will I have to set this up for each field as well as the variables I create? Also I have another question. After my fields populate to my form with the correct values, I inted to export to an Excel file. The new variables I created on my form and setup Action scripting to will have to be included in the export since I intend to reference this file and all the fields (variables) to more than a dozen spreadsheets. Will my variables show when I export? You might have to talk me through this since I have only been using Alpha 5 database for 1 month.

                            I am updating my details above. I am setting my table to crosstab procedure to provide the date as the row, and 4 other field names concatenated together as my column name. I am summarizing on quantity. So far, so good and my tables are calculating correctly. I am establishing my crosstab table to a form and realize that not all of my fields are generated because it's based on the data entered. How do I go about setting my forms to the new variable names I am establishing for when these values are generated through my crosstab procedure, they will import the values to these variables. I need to understand the process of using Action scripting, xbasic, or UDF.

                            Sorry if I am redundant or long-winded. :)

                            Thanks-

                            Neecy
                            Last edited by neecy; 07-13-2009, 05:15 PM. Reason: Additional problems

                            Comment


                              #15
                              Re: Using a script variable in a field rule...

                              Will my variables show when I export?
                              No. The export methods only allow you to export table fields.
                              There can be only one.

                              Comment

                              Working...
                              X