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

Functions not working after latest release installed

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

    Functions not working after latest release installed

    Now as regular contributors know, I'm no coder. A kind member sent me this function and it worked fine up until I loaded the latest version of V9.

    It calculates monthly complaint totals from a particular site.

    Can anyone help with this as I'm stumped.
    Tried going into Design and re saving, still doesn't work.

    FUNCTION past_year_sum AS C ( )

    ' site variable from site_select()
    ' This function sums the number of complaints for each month spanning the past 12 months including the the current month
    ' this function is called from the "display last 12 months" button on the F_comp form

    ' dim the needed variables
    dim vtitle as C
    vtitle = "Past 12 Month Summary" + crlf() + "====================" + crlf()
    dim vfooter as C
    vfooter = "====================" + crlf() + "Total = "
    dim vSum as C = "" ' accumulating result variable
    dim vcMWname as C ' month name
    dim vnCount as N = 0 ' montly count
    dim vntotal as N = 0 ' monthly count total

    dim vfS as C ' filter start date variable
    dim vfE as C ' filter end date variable
    dim vfilter as C ' filter string

    ' define the filter's first month start and end point variable values
    vfS = dtoc(month_end(date()) - 365)
    vfE = dtoc(month_end(ctod(vfS)))

    ' start with the first month acquiring that month's count, adding it to the accumulaing result variable (blank at start) and
    ' then incrementing the month for the next cycle

    for i = 1 to 12
    ' name on the first month in the series
    vcMWname = cmonth(ctod(vfS))

    'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    ' get record counts for the month current in the script
    vfilter = between_date("Comp_Date",ctod(Var->vfS),ctod(Var->vfE)) + " .and. site_id = "+quote(vSID)
    'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    vncount = a5_get_records_in_query("comp",vfilter)

    ' add the month's count and month's name to the accumulating result variable
    vSum = vSum + vncount + space(2) + alltrim(vcMWname) + crlf()
    vntotal = vntotal + vnCount

    ' increment the month to the next month for the next cycle
    vfS = dtoc(addmonths(ctod(vfS),1))
    vfE = dtoc(month_end(ctod(vfS)))
    next i

    ' compile the tittle, accumulated variable, and footer into a single reporting results variable

    vSum = vtitle + alltrim(vSum) + crlf() + vfooter + vntotal

    ' display the result in the form text box
    parentform:text1.text = vsum

    END FUNCTION
    See our Hybrid Option here;
    https://hybridapps.example-software.com/


    Apologies to anyone I haven't managed to upset yet.
    You are held in a queue and I will get to you soon.

    #2
    Re: Functions not working after latest release installed

    Ted,

    Need the F_comp form and some data to test this

    Comment


      #3
      Re: Functions not working after latest release installed

      Hi Lance, attached is what I have been working with. It is the original.

      I had hoped to recalculate the complaints when the record changed and I though I was there, but it stopped altogether.

      The upload is a bit iffy today as well!

      Ted
      See our Hybrid Option here;
      https://hybridapps.example-software.com/


      Apologies to anyone I haven't managed to upset yet.
      You are held in a queue and I will get to you soon.

      Comment


        #4
        Re: Functions not working after latest release installed

        Ok Ted, got it

        You need to change the code to this
        Code:
        FUNCTION past_year_sum AS C ( )
            
        ' site variable from site_select()
        '  This function sums the number of complaints for each month spanning the past 12 months including the the current month 
        '  this function is called from the "display last 12 months" button on the F_comp form
        
        ' dim the needed variables 
        dim vtitle as C
            vtitle = "Past 12 Month Summary" + crlf() + "====================" + crlf()
        dim vfooter as C
            vfooter = "====================" + crlf() + "Total = " 
        dim vSum as C = ""            ' accumulating result variable
        dim vcMWname as C            ' month name
        dim vnCount as N = 0        ' montly count
        dim vntotal as N = 0        ' monthly count total
        
        dim vfS as C                ' filter start date variable
        dim vfE as C                ' filter end date variable
        dim vfilter as C            ' filter string
        
        ' define the filter's first month start and end point variable values 
           [COLOR=Red] vfS = dtoc(month_start(addyears(date(),-1)))[/COLOR]
            vfE = dtoc(month_end(ctod(vfS)))
            
        ' start with the first month acquiring that month's count, adding it to the accumulaing result variable (blank at start) and
        ' then incrementing the month for the next cycle
        
            for i = 1 to 12
                ' name on the first month in the series
                vcMWname = cmonth(ctod(vfS))
        
        'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx        
                ' get record counts for the month current in the script
                vfilter = between_date("Comp_Date",ctod(Var->vfS),ctod(Var->vfE)) + " .and. site_id = "+quote(vSID)
        'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
                
                
                vncount = a5_get_records_in_query("comp",vfilter)        
                
                ' add the month's count and month's name to the accumulating result variable
                vSum = vSum + vncount + space(2) + alltrim(vcMWname) + crlf()
                vntotal = vntotal + vnCount
            
                ' increment the month to the next month for the next cycle
                vfS = dtoc(addmonths(ctod(vfS),1))
                vfE = dtoc(month_end(ctod(vfS)))
            next i
        
        ' compile the tittle, accumulated variable, and footer into a single reporting results variable 
        
            vSum = vtitle + alltrim(vSum)  + crlf() +  vfooter  + vntotal
        
        ' display the result in the form text box
            parentform:text1.text = vsum
        
        END FUNCTION
        the problem was in the definition of the vfS for the filters date, it was taking 365 days off today's value and looking at the month end. with the above you will always get the first and last day of a month a year ago as the base date to start from. In your code you only need to change the line in red to make it work.

        Comment


          #5
          Re: Functions not working after latest release installed

          You are truly a star!
          I'd never have found that in a million years!

          Many thanks Lance.
          See our Hybrid Option here;
          https://hybridapps.example-software.com/


          Apologies to anyone I haven't managed to upset yet.
          You are held in a queue and I will get to you soon.

          Comment


            #6
            Re: Functions not working after latest release installed

            Lance, I don't want to pester you, but where would I put the code to show only the unique sites? In the tables I am using I cannot have just a single occurrence, and it would be nice to show just the unique items. I had a look at the List function and ran away scared!

            Ted
            See our Hybrid Option here;
            https://hybridapps.example-software.com/


            Apologies to anyone I haven't managed to upset yet.
            You are held in a queue and I will get to you soon.

            Comment


              #7
              Re: Functions not working after latest release installed

              Not sure what you are trying to achieve Ted, do you want the browse on the F_comp form to only show 1 entry for each site instead of the 8 it shows now?

              Comment


                #8
                Re: Functions not working after latest release installed

                Ted,
                I am with Lance. I am not certain what your goal is with your last post. Describe your endpoint goal and I am sure we can help.
                Mike W
                __________________________
                "I rebel in at least small things to express to the world that I have not completely surrendered"

                Comment


                  #9
                  Re: Functions not working after latest release installed

                  Thanks guys,

                  The application I have developed has complaints logged against a site.
                  In the example you have seen, there is a master table which contains unique occurrences of the Site.

                  I cannot do it that way (well I could but it would screw up a whole lot of other functionality)

                  Plese see attached. I'm trying to display unique site names.
                  You will see "1&2 The Hedger" etc appears twice, and presumably as many times as it has a complaint against it.
                  I'd like to display it only once so that the selection is easier.

                  Regards, Ted
                  See our Hybrid Option here;
                  https://hybridapps.example-software.com/


                  Apologies to anyone I haven't managed to upset yet.
                  You are held in a queue and I will get to you soon.

                  Comment


                    #10
                    Re: Functions not working after latest release installed

                    Try adding a line to the site_select() function.


                    Code:
                    'Create an XDialog dialog box to prompt for parameters.
                    DIM shared vSID as C
                    DIM SHARED vresult as C
                    vSID = "kl=site,{keylist_build(\"H=.05,1:10[Site_Id],2:16[Site_Name]\",''+Site_id,left(''+Site_id,10),left(''+Site_name,16))}{}"
                    [COLOR="Red"]vSID = *remove_duplicates(vSID,crlf())[/COLOR]
                    There can be only one.

                    Comment


                      #11
                      Re: Functions not working after latest release installed

                      ...or. you can also use a filter in the 'keylist' line.
                      Code:
                      vSID = "kl=site,{keylist_build(\"H=.05,1:10[Site_Id],2:16[Site_Name]\",''+Site_id,left(''+Site_id,10),left(''+Site_name,16))}{[COLOR=Red].t. .and. unique_key_value()[/COLOR]}"
                      When setting up the record-list list box in the genie you can specify a filter. In the filter builder go to the last tab, 'Query options' and check the box for Unique records only.
                      Tim Kiebert
                      Eagle Creek Citrus
                      A complex system that does not work is invariably found to have evolved from a simpler system that worked just fine.

                      Comment


                        #12
                        Re: Functions not working after latest release installed

                        Tim,
                        I have found the unique_key_value() within a filter expresssion for key list build and table.external_record_content_get() to be completely unreliable. I typically second line it with word_unique() or *remove_duplicates() as Stan suggested.
                        Mike W
                        __________________________
                        "I rebel in at least small things to express to the world that I have not completely surrendered"

                        Comment


                          #13
                          Re: Functions not working after latest release installed

                          Hi Mike,

                          The trick with unique_key_value() is that the records need to be sorted (manually, by xbasic, or using an index) on the same key that you want to be unique. The field specified as the sort becomes the key that is tested for uniqueness.

                          In the case of record-list boxes the sort is performed on the first column. So if the first column in your list box was say the record id (which should always be unique) then you would still get all the records. Even though you may actually be interested in the second column.

                          For table.external_record_content_get() you can specify the sort order.

                          Using the 'Unique records only' in the query genie you need to specify the field/s to sort on for it to have any affect. (for example if using a default browse.)

                          I am not saying that unique_key_value() is the the/my preferred way, just that it is a possible way. (I got it to work fine in the sample provided in this thread.) I have used the methods you mentioned as well when unique_key_value() was not suitable.
                          Tim Kiebert
                          Eagle Creek Citrus
                          A complex system that does not work is invariably found to have evolved from a simpler system that worked just fine.

                          Comment


                            #14
                            Re: Functions not working after latest release installed

                            Just a note for Ted, and further to what has been said by Stan, Mike and Tim, the *remove_duplicates() needs to be sorted ascending first as well.

                            Comment


                              #15
                              Re: Functions not working after latest release installed

                              Originally posted by Lance Gurd View Post
                              Just a note for Ted, and further to what has been said by Stan, Mike and Tim, the *remove_duplicates() needs to be sorted ascending first as well.
                              For this reason, I tend to use word_unique()

                              Code:
                              dim L1 as C
                              L1 = <<%a%
                              cats
                              dogs
                              hogs
                              cows
                              horses
                              cows
                              cats
                              %a%
                              
                              ? *remove_duplicates(L1,crlf())
                              = cats
                              dogs
                              hogs
                              cows
                              horses
                              cows
                              cats
                              
                              
                              ? word_unique(L1,crlf())
                              = cats
                              dogs
                              hogs
                              cows
                              horses
                              Mike W
                              __________________________
                              "I rebel in at least small things to express to the world that I have not completely surrendered"

                              Comment

                              Working...
                              X