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

Parameters for scripts?

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

    #16
    Re: Parameters for scripts?

    Hi Finian,

    Originally posted by Finian Lennon View Post
    And I'm pretty sure that Ira recommends functions over scripts everywhere!
    You may be right about that.:D

    Hi John,

    Almost all my tips are based upon posts I've made here on the message board, and are a compilation of many answers. I got tired of re-posting and re-phrasing the answers multiple times. Also, if you are looking for message board search tips, you can look at the similar threads listed at the bottom of a thread listing, use google to search the message board site, or just ask in a message for links or search terms that you need for something, then follow up when you can't find it.

    Hi Steve,
    Originally posted by Steve T View Post
    It's ironic, as a result of this thread I've spent the last couple of hours reading this thread...
    Sorry that you had to put in time reading, but the time will be well invested.
    Regards,

    Ira J. Perlow
    Computer Systems Design


    CSDA A5 Products
    New - Free CSDA DiagInfo - v1.39, 30 Apr 2013
    CSDA Barcode Functions

    CSDA Code Utility
    CSDA Screen Capture


    Comment


      #17
      Re: Parameters for scripts?

      Originally posted by csda1 View Post
      Hi Finian,


      You may be right about that.:D

      Hi John,

      Almost all my tips are based upon posts I've made here on the message board, and are a compilation of many answers. I got tired of re-posting and re-phrasing the answers multiple times. Also, if you are looking for message board search tips, you can look at the similar threads listed at the bottom of a thread listing, use google to search the message board site, or just ask in a message for links or search terms that you need for something, then follow up when you can't find it.

      Hi Steve,

      Sorry that you had to put in time reading, but the time will be well invested.
      Hi Ira

      Thank you for your reply. I found your Code Utility Tips quite some time ago... before I really got into A5. As I began to develop an application, I kept trying to remember something in your "tips" regarding scripts and functions, but just couldn't recall it.

      I've already re-read your article but there is so much in there to absorb that I'm going to spend a little more time making some notes. This time I was smart enough to bookmark it so I can get back to it.

      Right now, I'm stumbling through developing an application just to get my feet wet. The most difficult thing about learning A5 is knowing where to look for answers. The help file - based on it's current organization - is very difficult to use.

      It appears that some people think of this message board, but where I'm coming of, a forum such as this was thought of more as a sounding board. Since there is always more than one way to accomplish a task, it's nice to ask "specific" questions and see what comes back. I'm getting the impression that some people might feel differently.

      Thanks again for your reply.
      John J. Fatte', CPA
      PRO-WARE, LLC
      Omaha, NE 68137

      Comment


        #18
        Re: Parameters for scripts?

        Sorry to be a "Contrarian" but the answer is not one size fits all wherein a function is superior to a script.

        Not.

        1-A script could be "better" than a function in certain situations while a function is "better" than a script in others.

        2-Yet in other situations the comparison is moot wherein you cannot use a script but only a function.

        Therefore, the question in the thread is not redundant nor has ever been fully answered. UDF's certainly serve a great purpose, but to turn every snippet of code into a UDF borders on obsession.

        Ira:
        just read your article. You use as an example:
        Code:
        dim shared woy as n
        woy=-5
        ?woy
        = -5
        ?week(date())
        = 16
        ?woy
        = 16
        Try your example but instead of WOY use any other name for the variable.
        Code:
        dim shared ira as n
        ira=-5
        ?ira
        = -5
        ?week(date())
        = 52
        ?ira
        = -5
        For some reason WOY doesn't work. A reserved word? not documented but does not seem to be either. In any case, it warrants a bug report but it is not a reason to believe that a function (UDF) is always superior to a script as the function is not in any way immune to such a bug.

        Comment


          #19
          Re: Parameters for scripts?

          Originally posted by G Gabriel View Post
          Sorry to be a "Contrarian" but the answer is not one size fits all wherein a function is superior to a script.

          Not.

          1-A script could be "better" than a function in certain situations while a function is "better" than a script in others.

          2-Yet in other situations the comparison is moot wherein you cannot use a script but only a function.

          Therefore, the question in the thread is not redundant nor has ever been fully answered.
          I don't believe anyone can find an example where a script ever is more useable than a function, the exception being an Alpha selection of some setting (e.g. field rule, layout, etc) that only allows choosing a script to execute. In almost every case, there is alternatve that allows putting in one or more lines of code, which could be the function call.

          Originally posted by G Gabriel View Post
          UDF's certainly serve a great purpose, but to turn every snippet of code into a UDF borders on obsession.
          Yes, it does border on obession, but the reason is to make code as "bullet-proof" as possible and isolate pieces of code into "islands of stability". I have major code 15000 lines + that was written in A5v6 and has, and continues to work all the way up to A5v10.

          Some people have signed onto the function train (Jeff K. for one), and the process works.

          The CSDA Code Utility is 4 external functions, and made up of probably 100+ internal functions. It hooks into many other built-in functions and scripts of Alpha with not one variable conflict. A miracle, no. Hard Work, yes. It took probably two man-weeks to dimension every variable in those lines of code, and it was worth the time. Had I done it during initial development, it would have been much easier. But now I don't have to worry about any built-in Alpha code ever changing a variable value without my knowledge. The Undimmed Variable tool in the CSDA Code Utility is an improved one over Alpha's built-in one, created for the above work.

          Alpha has over 1 million lines of XBasic code in their system library. I'm guessing it would probably be a 6 month project to fix every single piece of code to be "dimensionally perfect", and it would probably have many mistakes for long after that until fixed.

          Originally posted by G Gabriel View Post
          For some reason WOY doesn't work. A reserved word? not documented but does not seem to be either. In any case, it warrants a bug report but it is not a reason to believe that a function (UDF) is always superior to a script as the function is not in any way immune to such a bug.
          WOY is not dimensioned in Alpha's code, and thus assumes the value and changes the value of the shared variable.

          Actually, a user created function is 100% immune to any dimensioning bug (which this is the case of), if and only if, you dimension the same variable name inside your function as local. Dimensioning every variable inside your function as local, (except as needed to be of a different scope), and using a unique name (that no one else would ever use) for those of high scope, eliminates this issue entirely.

          Reporting this example as a bug, is not useful as this is just one simple example that shows that the name was not explicitly dimensioned in Alpha's system code. Changing the system functions en masse, would probably introduce more problems than they solved.

          But, I would never depend on Alpha or anyone else to have perfect code, so if you can defend against the problem by dimensioning, it's not a hard solution and is good programming practice anyway.

          In all my current code, I have 1 Addin Variable, 1 Global Variable, 1 Session Variable (all pointers) and exactly 1 script (Autoexec). Any other "scripts" are just stubs that call functions, and typically are embedded in the layout events. The higher scope variables are just pointer variables with properties that I create.

          They are used only when Alpha requires a script name, rather than an expression.

          Good programming technique always tends towards isolating code into their own islands and not having side effects.
          Regards,

          Ira J. Perlow
          Computer Systems Design


          CSDA A5 Products
          New - Free CSDA DiagInfo - v1.39, 30 Apr 2013
          CSDA Barcode Functions

          CSDA Code Utility
          CSDA Screen Capture


          Comment


            #20
            Re: Parameters for scripts?

            I suggest someone with v10 report this woy as a bug. Bug reports from v8 get less attention. I'd like to get to the bottom of this. Doesn't seem to happen with any other names I tried. And it only happens when dimmed as shared or global:
            Code:
            dim woy as n
            woy=-5
            ?woy
            ?week(date())
            = 52
            ?woy
            = -5
            I have to believe that woy is used internally by alpha with week(), here is why:
            Code:
            dim shared woy as n
            woy=-5
            ?woy
            = -5
            [B]?day(date())[/B]
            = 24
            ?woy
            = -5
            In fact, I am willing to bet the goat on it.
            Last edited by G Gabriel; 12-24-2009, 05:29 AM.

            Comment


              #21
              Re: Parameters for scripts?

              I wonder if woy is used internally somewhere by Alpha. Maybe it stands for week of year. When dimmed as shared or global it is being affected by an internal Alpha declaration.

              Comment


                #22
                Re: Parameters for scripts?

                Originally posted by G Gabriel View Post
                I have to believe that woy is used internally by alpha with week(), here is why:
                I know for a fact. "woy" is an internal variable used in week() function that Alpha did not dimension. It does stand for week of year. It fails in current V10 and all the earlier versions. As I said, this is just one example I gave. I chose it as it was one of the more straight forward examples using a very simple function.

                I wouldn't worry much about "woy", when there are variables with names like "temp" that have much more usage, and have a potential conflict issue.

                Add to that all user code generated by action scripts that generate codes that does not have every variable dimension'ed. Each one of those are a dimension issue.

                And add to that, any time you pass code to Alpha in a function to execute (which is in a lot of functions, explicitly or implicitly), that code is a wildcard that is 100% unpredictable. I spent a week in my CSDA code Utility making an execute function that totally isolates the code being run from the code running it. It is not easy.

                But you can be stubborn and continue to not dimension as I say, or choose to "bullet-proof" your code. Defensive measures are best when it is within your power to do so, even if not absolutely required.

                And just to give another simple example - a5_WebProjectFile(), used to take short WAS names and turn them into real names does not dimension variable "real_file_to_open". While few would use this function directly, it is used by many other functions that people might use. Probably less likely that someone would pick that name for a variable, as opposed to woy which could easily be chosen by someone using week() in their code, e.g.
                Code:
                delete woy ' this is only used to start clean each time for testing
                dim shared woy as n
                woy=16
                newwoy=week(date())
                ?woy
                = 52
                Last edited by csda1; 12-24-2009, 10:51 AM.
                Regards,

                Ira J. Perlow
                Computer Systems Design


                CSDA A5 Products
                New - Free CSDA DiagInfo - v1.39, 30 Apr 2013
                CSDA Barcode Functions

                CSDA Code Utility
                CSDA Screen Capture


                Comment


                  #23
                  Re: Parameters for scripts?

                  It is dim'd within the week() function.
                  Incidentally, delete() will not delete woy.
                  This is a documentation bug. WOY should be added to reserved words.

                  Comment


                    #24
                    Re: Parameters for scripts?

                    Originally posted by G Gabriel View Post
                    Sorry to be a "Contrarian" but the answer is not one size fits all wherein a function is superior to a script.

                    Not.

                    1-A script could be "better" than a function in certain situations...
                    G

                    I'm still looking for an example where a script is better...

                    Perhaps easier.... not by much. making a function is simple - converting a script to a function is easy.

                    But functionally (pun intended), where is a script better than a function?

                    In this case a single example is sufficient, but I still haven't found one.
                    Al Buchholz
                    Bookwood Systems, LTD
                    Weekly QReportBuilder Webinars Thursday 1 pm CST

                    Occam's Razor - KISS
                    Normalize till it hurts - De-normalize till it works.
                    Advice offered and questions asked in the spirit of learning how to fish is better than someone giving you a fish.
                    When we triage a problem it is much easier to read sample systems than to read a mind.
                    "Make it as simple as possible, but not simpler."
                    Albert Einstein

                    http://www.iadn.com/images/media/iadn_member.png

                    Comment


                      #25
                      Re: Parameters for scripts?

                      I quoted "better" in my response.
                      If you are going to the gym to work out once in a lifetime, get the visitor's pass (script) but if you are going there on a regular basis, get the membership (UDF). It makes no sense to get membership to work out once.

                      But if you want to crowd your files with UDF's for every snippet of code, then by all means go for it. In fact, you could make every snippet of code a global script if you want.

                      What's the difference? There is no difference but perhaps for few nanoseconds where alpha calls the function and the function runs its script.

                      It simply makes no sense. If it did, you would have seen the entire world of software, desktop or web, written strictly in functions instead of scripts. It is not.

                      Comment


                        #26
                        Re: Parameters for scripts?

                        Originally posted by G Gabriel View Post
                        It is dim'd within the week() function.
                        The week() function was added in A5V6 and hasn't changed a single byte through the current version. I can speak with 100% authority that that function does not DIM woy, so I have no idea of how you can come to that wrong conclusion.

                        Originally posted by G Gabriel View Post
                        Incidentally, delete() will not delete woy.
                        Delete() is not a function, but Delete is a reserved word for an operation

                        Delete() woy ' will never work
                        delete(woy) 'will never work
                        delete("woy") 'will never work
                        delete woy 'will delete woy at the lowest level it is currently dimensioned (implicitly or explicitly) at (which can be 1 or more levels)

                        Originally posted by G Gabriel View Post
                        This is a documentation bug. WOY should be added to reserved words.
                        It is not a documentation bug. If anything, it is a programming error. And while this 1 infinitesimal item could be fixed, there are others that might have even greater impact (e.g. "temp").

                        So you are telling Alpha to dimension every variable of theirs so you don't have to?

                        And even if Alpha did, one's own code can do exactly the same thing (and I've seen it 100's of time with other people's code) if you don't dimension every variable!
                        Regards,

                        Ira J. Perlow
                        Computer Systems Design


                        CSDA A5 Products
                        New - Free CSDA DiagInfo - v1.39, 30 Apr 2013
                        CSDA Barcode Functions

                        CSDA Code Utility
                        CSDA Screen Capture


                        Comment


                          #27
                          Re: Parameters for scripts?

                          delete() was a typo, I meant delete.
                          No problem with temp:
                          Code:
                          dim shared temp as n
                          temp=-5
                          ?temp
                          = -5
                          ?week(date())
                          = 52
                          ?temp
                          = -5

                          Comment


                            #28
                            Re: Parameters for scripts?

                            Just received a very quick response from Selwyn. Thanks Selwyn.
                            As you can see, WOY IS dim'd in weeek() but as shared instead of local and hence the problem with WOY.
                            Code:
                            Selwyn's response:
                            thanks
                            
                            it is a bug
                            
                            the week() function was not dimming 'woy' as a local variable, as it should have
                            
                            
                            i have fixed it in v10.
                            
                            we are no longer releasing patches for v8
                            
                            thank you for bringing this to my attention.
                            
                            the week() function is a trivial function.
                            
                            if you want, you could paste this into your database and a5 will use your local version of the function
                            
                            
                            FUNCTION week AS N ( Date AS D )
                            'DESCRIPTION: Get the calendar week number of a date
                            'LIMITATIONS: I
                                    DIM year AS N
                                    DIM dow_NewYear AS N
                                    DIM dow_Date AS N
                                    DIM dNewYearsDay AS D
                                    DIM doy AS N
                                    dim woy as n
                            
                                    year = year(date)
                            
                                    ' get the day of the week of the first day of the year
                                    dNewYearsDay = date_value(year, 1, 1)
                                    dow_NewYear = dow(dNewYearsDay)
                                    dow_Date = dow(Date)
                            
                                    ' get the day of the year
                                    doy = Date - dNewYearsDay + 1
                                    ' week of year
                                    woy = ceiling(doy/7)
                            
                                    IF dow_NewYear > dow_Date
                                            woy = woy + 1
                                    END IF
                            
                                    week = woy
                            END FUNCTION

                            Comment


                              #29
                              Re: Parameters for scripts?

                              Originally posted by G Gabriel View Post
                              delete() was a typo, I meant delete.
                              No problem with temp:
                              Code:
                              dim shared temp as n
                              temp=-5
                              ?temp
                              = -5
                              ?week(date())
                              = 52
                              ?temp
                              = -5
                              Of course there is no problem with "temp" with that function. It's only "woy" that is not dimensioned in that function. But the issue is always hanging there like a chandelier hanging be a thread.

                              You never know when you pick a function to use, that Alpha did not dimension a specific variable, that just happens to correspond with one of yours.

                              And in a similar vein, Alpha uses the Delete to remove variables. Sure enough, specific variable names will disappear after you run a function (or an action script code - many generated do) that does that.

                              The problem is 100% understood, and there is a 100% solution. Read my tips and pay attention, or don't, and suffer the consequences!
                              Regards,

                              Ira J. Perlow
                              Computer Systems Design


                              CSDA A5 Products
                              New - Free CSDA DiagInfo - v1.39, 30 Apr 2013
                              CSDA Barcode Functions

                              CSDA Code Utility
                              CSDA Screen Capture


                              Comment


                                #30
                                Re: Parameters for scripts?

                                Originally posted by G Gabriel View Post
                                Just received a very quick response from Selwyn. Thanks Selwyn.
                                As you can see, WOY IS dim'd in weeek() but as shared instead of local and hence the problem with WOY.
                                Big whoop. Selwyn said the week() function is a trivial function, and I agree. It was an example to show the process, not all cases where it happens.

                                1st, for Week(), it is now dimensioned local, not shared by Selwyn's change, as it should be.

                                2nd, even if it is fixed in Week(), I could generate 1000's of examples that are identical failure types. There are time bombs like these in the email client code that I would not consider trivial. I know a user that ran into it. Just lucky (NOT!) that he used the same name as an un-dimensioned variable in it.

                                But resolving every coding issue with Alpha Five is not my job. And for this specific problem type, is not reasonable to expect Alpha to do.

                                Producing "bullet-proof" code, however, is my (and should be every developer's) job. The method I've outlined is there, it is not hard to do, and it works, is the proper programming method, and even works when you step on your own variables.
                                Regards,

                                Ira J. Perlow
                                Computer Systems Design


                                CSDA A5 Products
                                New - Free CSDA DiagInfo - v1.39, 30 Apr 2013
                                CSDA Barcode Functions

                                CSDA Code Utility
                                CSDA Screen Capture


                                Comment

                                Working...
                                X