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

UDF Parameter Question

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

    UDF Parameter Question

    Hi All,

    I was just curious what the prevailing thought might be on the following when creating / using UDF's. If you have a global variable previously defined as say gvMyRefNum and it is populated with a value. Is there any difference one way or the other (better code isolation. stability, etc.) if you either pass or don't pass the global variable as a parameter to the UDF?

    For example:

    RunMyCode(gvMyRefNum)

    versus

    RunMyCode() <-and gvMyRefNum is just referenced inside the UDF


    Obviously, both ways work......just curious if there is a prevailing thought on best practice in this situation?


    Regards,

    Jeff

    #2
    Re: UDF Parameter Question

    Jeff,
    I can see where context can play a big part in this....many times I will have a variable dimensioned from a form that will later be used in a UDF.....other times, if its value can be set from within the function, then I dimension and set it there. Where a variable will be used and if the variable will be used multiple times determines much.
    Mike
    __________________________________________
    It is only when we forget all our learning that we begin to know.
    It's not what you look at that matters, it's what you see.
    Henry David Thoreau
    __________________________________________



    Comment


      #3
      Re: UDF Parameter Question

      ...many times I will have a variable dimensioned from a form that will later be used in a UDF.....other times, if its value can be set from within the function, then I dimension and set it there.
      Yep, that is what I do as well Mike.

      I just was wondering if there was any "under the hood" stuff that made one way better / more bulletproof than another?

      Ira...you out there? :):)

      Comment


        #4
        Re: UDF Parameter Question

        I would be interested as well in other's thoughts in case I am missing something or a way to better my code.

        One thing I always make sure of in functions is that if something can be dimensioned local I do that as then I am assured that when using the same function sometimes many times in a row, that the variables will not be stepping on each other.

        Regarding a global, once dimmed, it is there regardless until the database is closed....so whether it is dimmed on startup or when first used, it makes little difference IMO.
        Mike
        __________________________________________
        It is only when we forget all our learning that we begin to know.
        It's not what you look at that matters, it's what you see.
        Henry David Thoreau
        __________________________________________



        Comment


          #5
          Re: UDF Parameter Question

          Jeff,

          Always choose the smallest scope for your variables to get your app working and always pass variables by reference or value at a function. Don't use globals, thats a lazy habit. :)
          Marcel

          I hear and I forget. I see and I remember. I do and I understand.
          ---- Confusius ----

          Comment


            #6
            Re: UDF Parameter Question

            Originally posted by Marcel Kollenaar View Post
            Jeff,

            Always choose the smallest scope for your variables to get your app working and always pass variables by reference or value at a function. Don't use globals, thats a lazy habit. :)

            Hi Marcel,

            Thanks for your reply.

            Yes...that is what I do (choose smallest scope). In the instances where I need a global, I was just curious whether it was more "bulletproof" to pass the variable as a parameter (verus just using the global variable inside the UDF) and if anyone knew why that might be the case?

            The root of this question is that I had seen a few "bizarre" happenings in this area (i.e. the resultant action of the code in the UDF did not perform the intended action based on the "known" variable value). I changed a few UDF's to handle a parameter instead of just using a variable that existed. The variables were not global in some of these instances....but the UDF still used them (but not by being passed as a parameter). The weird behavior was very sporadic....by that I mean....I knew what the output of the UDF should have been based on the variable value....but it did not always work out that way. Once, I changed
            the UDF to take the same value(variable) as a parameter....things have seemed more reliable.

            I guess I just answered my own question! :) I don't fully understand why that has occured.....but I will be creating/changing all my UDF's to take these variables as parameters.

            Regards,

            Jeff

            Comment


              #7
              Re: UDF Parameter Question

              Jeff,

              During a A5 session all variables are trown in a big memory pool. Variables are "deleted" by the default behaviour of specific parts such as forms. After a form closes the variables local to the form are gone. But if somewhere in your program a variable is created by some code and given a value and not deleted it can become a hazardous item when in other parts a variable is used with the same name and not explicit dimensioned.
              Marcel

              I hear and I forget. I see and I remember. I do and I understand.
              ---- Confusius ----

              Comment


                #8
                Re: UDF Parameter Question

                Hi Marcel,

                Thanks....yeah...I fully understand how variables work in Alpha. I guess my example to start this thread was poor.

                My question really has nothing to do with variables. It is with UDF's and Parameters. Here is another example that more clearly defines what I was looking for. In any case, I have adopted the strategy to always pass my reference values as parameters now. I still would like to know what the "under the hood" differences (if any) exist between the code below. When running a UDF from a form, I have seen instances where Alpha did not ALWAYS evaluate the value correctly with the second example below....but if the value is passed as a parameter it did evaluate correctly.

                RunMyCode(parentform:myfieldname.value)

                versus

                RunMyCode() <-and parentform:myfieldname.value is just referenced inside the UDF


                Regards,

                Jeff

                Comment


                  #9
                  Re: UDF Parameter Question

                  Jeff,
                  Much more clear....I have always passed such arguments directly into the function as, like you, have found that the UDF cannot always "see" the form or its values.
                  Mike
                  __________________________________________
                  It is only when we forget all our learning that we begin to know.
                  It's not what you look at that matters, it's what you see.
                  Henry David Thoreau
                  __________________________________________



                  Comment


                    #10
                    Re: UDF Parameter Question

                    Clear, agree with Mike.
                    Marcel

                    I hear and I forget. I see and I remember. I do and I understand.
                    ---- Confusius ----

                    Comment

                    Working...
                    X