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

For..Next..For What?

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

    #31
    Re: For..Next..For What?

    Clear.

    Factoring in the Brodie story comes close the "common expression removal".
    Marcel

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

    Comment


      #32
      Re: For..Next..For What?

      This is very good discussion any "developer" should read.

      I THINK, but am not sure, the two questions I posted earlier could be easily answered knowing (or in this case guessing) how alpha performs these commands:

      Alpha loads those command & their execution in cache.
      In the first case, with For..Next, alpha loads the command, generates the counter, runs the loop once, then runs the repeated loops from cache. Hence the first run is slower but not by much

      In the second scenario, alpha loads all 4000 lines of commands to cache, hence the first run is a lot slower, but once loaded and run from cache, the second scenario, the "Unlooped" one runs faster than For..next each and every time because it does not have the added overhead of incrementing and testing the counter.

      All of that make sense if the assumption is correct.

      Comment


        #33
        Re: For..Next..For What?

        Gabe,

        It makes no difference in speed of the cache. The cache load times are almost identical for both cases (you're not measuring this cache load time in your code though. All you could potentially measure the way you have the code is the load of the form (which includes the code).

        To measure cache overhead, you would need to put the code in a UDF/Global Script, subtract out the calling overhead, and then measure a 1st time number that is probably unmeasureable based on the timer inaccuracies. If you had 2000 scripts, you might be able to get a meaningful result as to the caching overhead by running each once.

        The point is, ignore the cache time, it is totally irrelavant.
        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


          #34
          Re: For..Next..For What?

          I actually find this discussion very interesting from a theoretical standpoint but I find it rather useless from a realistic standpoint.

          First, if the routine itself is 100 lines long and I need to run it 100 times, that's 10,000 lines that need to be copied!!! (And, yes, I have built quite a number of FOR / NEXT loops that are in this range.)

          Second, although there are occasions where I might build a FOR...NEXT loop with a fixed number of loops (and in those cases I could just copy the code the appropriate number of times) that's actually very rare. In the vast majority of cases my FOR...NEXT loop is based on the number of "things" I want to check. A common "things to check" might be the lines in a crlf string based on choices made by the user. (Or, as I did recently, from an HTML page downloaded from the internet.) In that case, the FOR statement would be something like:

          line_cnt = w_count( TheCrlfStrg, crlf() )
          FOR qx = 1 to line_cnt

          I suppose I could do a series of IF or SELECT statements where each successive choice has one more copy of the routine than the previous choice but I think everyone would agree that something like that would be a bit ridiculous to say the least.

          FYI:
          - Since we were talking about speed here, I used the W_Count() function. This function actually runs MUCH faster than the Line_Count() function but both are so fast that, as a practical matter, it really isn't important UNLESS the function itself is used within a loop.
          - Setting the variable ("line_cnt" in the example above) before the "FOR" line makes the loop run faster. Otherwise it has to re-evaluate the w_count() function for each loop. After all, it is possible (and I've done it but don't recall why) to modify the variable that is being evaluated within the loop itself thus changing the end point of the loop. Of course, in that case it would be necessary to re-evaluate the result for each loop.
          Last edited by CALocklin; 12-10-2006, 11:39 PM.

          Comment


            #35
            Re: For..Next..For What?

            I'll add one additional comment:

            The loop takes .1358333 seconds
            The loop unrolled by a factor of 10 takes .0923148 seconds
            The loop unrolled by a factor of 20 takes .0892857 seconds
            The loop unrolled by a factor of 40 takes .0881607 seconds
            The loop totally unrolled takes .09743137 seconds


            As you can see the totally unrolled loop and the factor of 10 unrolled loop take approximately the same time. But the totally unrolled loop took a bit longer, because my testing method forces a "recompile" of the code, and the longer code takes longer to "compile". At some point (say a factor of 10 or 20), unrolling the loop any further doesn't make any sense, and in fact could take longer with the load and/or compilation of the code.
            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


              #36
              Re: For..Next..For What?

              Cal:
              alpha is the interface between the users, us, and Windows (or any OS system you use).

              Knowing how alpha does things, will allow you and me to build better, more efficient and faster scripts.

              I do not think any of this is of theoretical value. Unfortunately, short of some insight from the alpha designers, one cannot make plans on top of plans all of which based on assumptions.

              1-Does alpha load the entire form in cache?
              2-What happens when cache gets full?
              3-Does it only load the script? expression? what?
              4-Why is the discrepancy in the speed? why is it more profound in the "unlooped" script?

              I have few reports that I had to abandon because they take too long. Try to build a report and use calc fields for averages for example. It's utterly slow.

              I developed a pretty custom function that's lacking in alpha, one that calculates the cumulative paid balance/ interest on a term loan within a period of time, unfortunately, I had to abandon it. Why: it's ridiculously slow.

              In the vast majority of cases my FOR...NEXT loop is based on the number of "things"
              wouldn't you like to know how alpha does that?
              For instance, suppose you run a For loop capped with the number of records in a query. How does alpha run that loop? does it first evaluate the end point, save it and in the subsequent loops utilizes the output value? or does it evaluate the end point each loop? maybe it would be a better idea if you evaluate the end point first and write a script:
              n= ...records number...

              for i= 1 to n
              instead of:

              for i= 1 to ...number of records...

              I, for one, am completely oblivious to what goes on behind the scenes, but I don't think I am alone in this and rather than guessing, it would be very helpful to know how alpha carries out these and other commands. Maybe, the new doc guy will shed some light on that.

              Comment


                #37
                Re: For..Next..For What?

                Originally posted by G Gabriel View Post
                Cal:
                Knowing how alpha does things, will allow you and me to build better, more efficient and faster scripts.
                True....Well I know Cal will.

                I do not think any of this is of theoretical value.
                False. Almost all discussion of XBasic caching above has no relavance for Alpha 5. XBasic Cache is virtually unlimited

                Unfortunately, short of some insight from the alpha designers, one cannot make plans on top of plans all of which based on assumptions.
                False. I don't have any inside info that anyone else has. What I know is all based upon unstanding of software, hardware & compiler design combined with a small bit of testing.

                1-Does alpha load the entire form in cache?
                2-What happens when cache gets full?
                3-Does it only load the script? expression? what?
                4-Why is the discrepancy in the speed? why is it more profound in the "unlooped" script?
                1. Irrelavant
                2. Answered already
                3. Answered already
                4. Answered already - "Compile" time

                I have few reports that I had to abandon because they take too long. Try to build a report and use calc fields for averages for example. It's utterly slow.
                Change your techniques. I took a form and a report from a very competent A5 developer that took 30 seconds to run through it's calc fields for each record access and made it run in less than .25 seconds. That cost their client $1000 in development. I'd be happy to help you too at my current rates. If you really want to understand real speeds of code via testing, buy my utility. It probably represents 3 months developing speed testing methodology in A5.

                I developed a pretty custom function that's lacking in alpha, one that calculates the cumulative paid balance/ interest on a term loan within a period of time, unfortunately, I had to abandon it. Why: it's ridiculously slow.
                Mine don't, and I know others that don't have any problems. It's your code or techniques. I also provide training at current hourly rates.

                wouldn't you like to know how alpha does that?
                For instance, suppose you run a For loop capped with the number of records in a query. How does alpha run that loop? does it first evaluate the end point, save it and in the subsequent loops utilizes the output value? or does it evaluate the end point each loop?
                Cal already answered this. My utility shows this

                maybe it would be a better idea if you evaluate the end point first and write a script:
                n= ...records number...

                for i= 1 to n
                instead of:

                for i= 1 to ...number of records...
                Cal already answered this. My utility shows this

                I, for one, am completely oblivious to what goes on behind the scenes, but I don't think I am alone in this and rather than guessing, it would be very helpful to know how alpha carries out these and other commands.
                Buy my utility. Do some testing.

                Maybe, the new doc guy will shed some light on that.
                Doc guy *new or old" knows nothing of speed. Alpha developers know little of speed except for critical underlying code or those that stand out as being unbearably slow or just good techniques in writing the underlying code. If you find an operation that is key, used repetitvely and is slow, report it and they will repair it.

                The Alpha 5 conference 2005 I have spoke on issues of speed and gave attendees many tips of how to improve their code speed, a few I have listed above. And in most of my talks at other A5 conference years, I have addressed these speed issues as sidepoints. I would suggest that you
                1. Study up on compiler/language/algorithm design.
                2. Take the coding suggestions I have made to heart
                3. Attend the Alpha 5 conferences
                4. Buy my utility.
                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


                  #38
                  Re: For..Next..For What?

                  Ira, I guess your response comes across as a lightly disguised promotion for CSDA. ;)

                  However, I have read your documentation on and in fact everything I can find about your utility and I have to admit to being left confused. Let me say just this, the documentation may be technically complete and accurate, but it tells me little about what CSDA will actually do for me. I see features for saving and restoring desktops, also backing up dictionaries. I have little need for these features and if I want a backup, which I do daily anyway, CSDA appears irrelevant to me. There is, however, a feature on code timing that interests me but little information on the detail and how.

                  Please take this as constructive criticism, for that is what is intended.

                  Comment


                    #39
                    Re: For..Next..For What?

                    Originally posted by brett s View Post
                    Ira, I guess your response comes across as a lightly disguised promotion for CSDA. ;)
                    Actually, it was meant to show my annoyance with the thread. I've said everything (as well as others) and some were not listening. If tools are available, e.g. my tool or Cal's design tool for properties etc, either use them or write your own if you are able. But don't keep hashing the same retoric.

                    However, I have read your documentation on and in fact everything I can find about your utility and I have to admit to being left confused. Let me say just this, the documentation may be technically complete and accurate, but it tells me little about what CSDA will actually do for me. I see features for saving and restoring desktops, also backing up dictionaries. I have little need for these features and if I want a backup, which I do daily anyway, CSDA appears irrelevant to me. There is, however, a feature on code timing that interests me but little information on the detail and how.

                    Please take this as constructive criticism, for that is what is intended.
                    I appreciate the critisism for the documentation. Yes it could be better, but it is at least complete. If you've read the current pdf, it has some documentation, but it's better seeing and doing than explaining. I hav been working on a Camtasia video so that will help explain more. However, it basically comes down to for the timing, is open a script or UDF or an event code in the Code Editor (can be Xbasdic or Action Script). Select the code tab of that item, then click the timing button. That code will be tested for speed and the results reported back on the status bar. You can also use it in your own timing test by making calls to the underlying UDF.

                    Alternatively, select some code in the interactive window (highlight it) and press the timing button, and again that selected code will be tested for speed.

                    Best way to see the product's use it to run the beta or get a trial version. You won't be sorry. It really does save you a lot of time.
                    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