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

Explanation of fname as v (vars as P) & with

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

    Explanation of fname as v (vars as P) & with

    Hi folks,

    Please could someone explain to me...

    function functionname as v (vars as p)
    with vars


    I have read and read the manual & message boards and I understand...
    - namespaces,
    - local vs gobal etc. scope
    - dot variables
    - functions with "normal" variable types (n, c, d etc.)

    ...but...
    1. What is "v" as in "as v"? It is not one of the designated variable types. Does this mean we are just setting values for variables?


    2. Now that we have multi-level dot variables, are namespaces pretty much obsolete? If not, when/why would you use which?


    3. In script such as this one...
    http://msgboard.alphasoftware.com/alphaphorum/read.php3?sortby=lastreply&direction=desc&num=15&id=13053&thread=13053#MSG13094

    ... "vars" points to the local variables only...

    dim lv as p
    lv = local_variables()
    functionname(lv)
    ...
    function functionname as v (vars as p)
    with vars

    ...What if I wanted the function to access a local variable AND one in a different namespace as well?


    4. Why do you even have "with vars" in a function? Is the function not effectively a child script of the calling script and thus would have access to all variables in the calling script anyway?


    5. How would you convert a script such as this to take variables as p instead of as c?
    http://msgboard.alphasoftware.com/alphaphorum/files/200411/a5v6/07/6107/script1.txt

    It's clearly more than just
    lv = local_variables()
    tempstate_expanded = get_state_data(lv)
    and
    function get_state_data as V (vars as p )



    Thanks in advance.

    Regards,
    Trevor

    #2
    RE: Explanation of fname as v (vars as P) & w

    1. What is "v" as in "as v"? It is not one of the designated variable types. Does this mean we are just setting values for variables?

    V is VOID, meaning this function does not return anything

    Lenny Forziati
    Vice President, Internet Products and Technical Services
    Alpha Software Corporation

    Comment


      #3
      RE: Explanation of fname as v (vars as P) & w

      2. Now that we have multi-level dot variables, are namespaces pretty much obsolete? If not, when/why would you use which?

      Namespaces, as defined in the Alpha Five documenation, each have a different scopt, or lifetime. Your dot variables live within one of these namespaces

      Lenny Forziati
      Vice President, Internet Products and Technical Services
      Alpha Software Corporation

      Comment


        #4
        RE: Explanation of fname as v (vars as P) & w

        3. In script such as this one...
        http://msgboard.alphasoftware.com/alphaphorum/read.php3?sortby=lastreply&direction=desc&num=15&id=13053&thread=13053#MSG13094

        ... "vars" points to the local variables only...

        dim lv as p
        lv = local_variables()
        functionname(lv)
        ...
        function functionname as v (vars as p)
        with vars


        dim lv as p = local_variables()
        dim ov as p =
        functionname(lv,ov)
        ...
        function functionname as v (vars as p, vars2 as p)
        with vars
        vars2.variable

        Lenny Forziati
        Vice President, Internet Products and Technical Services
        Alpha Software Corporation

        Comment


          #5
          RE: Explanation of fname as v (vars as P) & w

          4. Why do you even have "with vars" in a function? Is the function not effectively a child script of the calling script and thus would have access to all variables in the calling script anyway?

          No, a function call is not a child script, it runs in it's own variable frame. If you don't pass variables in, your function can't get to them unless they are global or shared.

          Even with a script, you would need to use script_play_local() instead of script_play() if you want to run it in the same variable frame.

          Lenny Forziati
          Vice President, Internet Products and Technical Services
          Alpha Software Corporation

          Comment


            #6
            RE: Explanation of fname as v (vars as P) & w

            5. How would you convert a script such as this to take variables as p instead of as c?
            http://msgboard.alphasoftware.com/alphaphorum/files/200411/a5v6/07/6107/script1.txt

            It's clearly more than just
            ...


            Actually that will do it if you do the with...end with. You'll also need to use tempstate instead of state as that is the variable name used outside the function. Or you can skip the with...end with and use vars.tempstate

            But why would you wnat to do this? Unless your function is going to manipulate a whole bunch of stuff, you should really just pass in what you need.

            Lenny Forziati
            Vice President, Internet Products and Technical Services
            Alpha Software Corporation

            Comment


              #7
              RE: Explanation of fname as v (vars as P) & w

              Wow. Look at that you folks just checking out Alpha Five

              Try and get that kind of service from Filemaker or the illegal monopolists! That's just a part of the reason the folks here LOVE Alpha Five.


              Thanks so much, Lenny.

              Just two quick follow-up questions for the record:

              1. In the line...
              function functionname as v (vars as p, vars2 as p)
              ...is "vars" some kind of special or reserved word? i.e. do we have to use the word "vars" or can we use any non-reserved words e.g.
              function functionname as v (localvars as p, globalvars as p)


              2. From the lines...
              dim lv as p = local_variables()
              dim ov as p =
              functionname(lv,ov)
              ...
              function functionname as v (vars as p, vars2 as p)
              with vars
              vars2.variable

              ...where "vars2.variable" is inside "with vars" it looks like "vars2" might be subordinate to "vars", as if it were further down the chain of a dot.variable
              e.g.
              var.some-local-variable01
              var.some-local-variable02
              var.var2.some-variable-in-a-different-namespace01

              Is that correct? If so, do we need to pass the variables lv,ov etc to the function in any particular order e.g. local variables first, then global, then...?


              Thanks again.

              Regards
              Trevor




              Comment


                #8
                RE: Explanation of fname as v (vars as P) & w

                1) There is nothing special about "vars"

                2) vars2.variable is not a subordinate of vars. What happens is when you reference a variable within a with..end with block, the interpreter first looks for it within vars. If it is not found, it then looks up the stack outside of the with.

                I personally almost never use with. I'd rather explicitely reference a variable as vars.variable - that way i know exactly what variable I am working with, particularly a few weeks down the road when I revisit the code I wrote

                Lenny Forziati
                Vice President, Internet Products and Technical Services
                Alpha Software Corporation

                Comment


                  #9
                  RE: Explanation of fname as v (vars as P) & w

                  You will find that over time passing the whole local variable frame is not a very good way to approach coding. It causes you to take shortcuts by not examining your design ahead of time. Basically, if a function requires use of more than a few passed variables, you need to reevaluate the design and probably break that function up into multiple functions. Essentially, passing local variables removes the abstraction and encapsulation parts of the design. Essentially, the fucntion now becomes a glorified macro.

                  On top of that, they become very difficult to manage over time because it is unclear where variables are coming from. Are you modifying a variable that is changed somewhere else? If you change it here, will it have an unseen effect? What if you are calling this function in a for loop? Now you have a for loop inside the function. You now have to worry about the name of your iterator variable otherwise everything will get all messed up. The function is no longer a function, it's just become a shorthand.

                  Instead, if there are a large number of variables that you know need to be used inside several functions, I would create a dot-variable structure specifically for those variables to be passed around rather than using local_variables().
                  Aaron Brown
                  Alpha Software Development Team

                  Comment


                    #10
                    RE: Explanation of fname as v (vars as P) & w

                    That's pretty much the conclusion I had come to i.e. that using "with vars" adds a extra layer of complication/abstraction for little apparent gain and thought I was missing something. Apparently not.

                    When you're (both) talking about referencing the variables directly and using dot variables, am I correct in thinking taht the structure you're talking about is as follows & no "with" statement?


                    dim a.x as c
                    dim a.y as n
                    dim a.z as p

                    functionname(a.x,c.z,b.y)
                    ...
                    function functionname as v (var1 as c, var2 as p, var3 as n)
                    someothervar = a.x
                    a.y = someothervar2
                    end function


                    Thanks again.

                    Regards,
                    Trevor

                    Comment


                      #11
                      RE: Explanation of fname as v (vars as P) & w

                      Not quite. Once you are inside the function, there is no more a.x and a.y. Instead your function has var1, var2 and var3 available to it.

                      Lenny Forziati
                      Vice President, Internet Products and Technical Services
                      Alpha Software Corporation

                      Comment

                      Working...
                      X