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

Sorting numbers in a text field

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

    Sorting numbers in a text field

    I am hoping someone can enlighten me on how Alpha does sorts of numbers with letters attached in a text field.
    I am sending along a sample file and a photo of what I would like to do. The database on the right shows the sequence I would like. I am able to get this by right justifying the Performance field and doing a descending sort. When I try this in Alpha, I get the order as shown in the left Alpha database sample.

    Input as shown is required as there are some races that use auto timing, accurate to a hundreth of a second, while other times are recorded by using hand times, as designated with the h after the hand time. Some times in an event will be less than 10 seconds, while other times will be greater than 10 seconds,thus the wide range of times.

    I have worked with the database on the right for many years, so I just expected Alpha to do sorts in a similar fashion, but I am finding this is not the case (or at least it is not working for me).

    Any suggestions would be helpful. (Please ignore the sort order field in the second database).

    Thanks....
    "Ollie, remember how dumb I used to be? Well, I'm much better now."

    Pete

    #2
    Re: Sorting numbers in a text field

    Alpha sorts any character field from left to right by character ascii value, no matter whether the field contains digits, no matter the length of any digit sequence. The ascii values can be investigated using ? a5_ascii_table() in the interactive editor. Digits have lower ascii values than "letters", capitalization is not considered.

    If you want to get the desired sort use an expression like

    padl(alltrim(performance),13,"0")

    padl(alltrim(performance),13," ")


    substituting the actual defined field width of the performance field in place of 13.

    (To be very technical, there are no numbers in a text field.)
    Last edited by Stan Mathews; 01-05-2009, 10:39 PM.
    There can be only one.

    Comment


      #3
      Re: Sorting numbers in a text field

      Hi Stan:
      I am trying to understand the process and why it is so difficult in Alpha compared to the other database I use. The help file info for padl() could be written in Latin and I wouldn't be able to follow the logic, unfortunately.

      Here is what I tried and I get back an error, saying too few parameters:
      Code:
      'Default comment text.
      DIM records_found as N
      records_found = topparent.queryrun("",padl(alltrim("Performance")),12,"0","","No","",.f.)
      I also tried it with " ", as in your second suggestion with the same results.

      I can see where the alltrim() gets rid of all the spaces, but I can't grasp what padl does. The rest of the expression I developed using the custom query Action Script.
      "Ollie, remember how dumb I used to be? Well, I'm much better now."

      Pete

      Comment


        #4
        Re: Sorting numbers in a text field

        Originally posted by trackmanpete View Post
        Hi Stan:
        I am trying to understand the process and why it is so difficult in Alpha compared to the other database I use. The help file info for padl() could be written in Latin and I wouldn't be able to follow the logic, unfortunately.

        Here is what I tried and I get back an error, saying too few parameters:
        Code:
        'Default comment text.
        DIM records_found as N
        records_found = topparent.queryrun("",padl(alltrim("Performance"[SIZE=4][COLOR=red][B]))[/B][/COLOR][/SIZE],12,"0","","No","",.f.)
        I also tried it with " ", as in your second suggestion with the same results.

        I can see where the alltrim() gets rid of all the spaces, but I can't grasp what padl does. The rest of the expression I developed using the custom query Action Script.
        Pete

        Try this instead.

        padl(alltrim("Performance"),12,"0")

        I suggest that you calculate a value like that into a variable and get the results, then use the variable in the function.. (In your case the topparent.queryrun..)

        As far as what the padl() does for you, consider this...
        Code:
         
         
        dim al as n
        al = 12
        ?str(al)
        = "        12"
        ?alltrim(str(al))
        = "12"
        ?padl(alltrim(str(al)),5,"0")
        = "00012"
        ?padl(alltrim(str(al)),5,"x")
        = "xxx12"
        ?padl(alltrim(str(al)),5,"-")
        = "---12"
        ?padl(alltrim(str(al)),11,"0")
        = "00000000012"
        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


          #5
          Re: Sorting numbers in a text field

          or try,

          "padl(alltrim(Performance),12,\"0\")"
          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


            #6
            Re: Sorting numbers in a text field

            Originally posted by trackmanpete View Post
            I can see where the alltrim() gets rid of all the spaces, but I can't grasp what padl does.
            Padl is shorthand for padleft which pads/fills a string with the specified character to specified length. This a physical right justify rather than a cosmetic right justify.


            Originally posted by trackmanpete View Post
            The rest of the expression I developed using the custom query Action Script.
            The rest of the expression is your issue which I think Tim solved. Any time you use a function which contains quote marks inside another function requiring a quoted expression, you have to manage the "interior" quotes.

            padl(alltrim(Performance),12,"0") would be proper to use for your sort order.

            Placed inside the
            topparent.queryrun() function where the order expression is indicated as Order_Expression as C, you must quote the original.

            "padl(alltrim(Performance),12,"0") " but that leaves us with the two interior quotes (in red). Not doing anything confuses Alpha because we would have two strings (orange and blue) with a character in between (green).

            "padl(alltrim(Performance),12,"0")"

            Alpha has the escape character \ to let us tell it that the next quote mark is an interior quote and that it should keep on interpreting the string rather than thinking the string has ended.

            "padl(alltrim(Performance),12,\"0\")"
            There can be only one.

            Comment


              #7
              Re: Sorting numbers in a text field

              Stan, Al and Tim:
              Thank you so much for this excellent lesson. the "L" in "padl" was confusing me, as I kept pronouncing it as "paddle"...

              I've been away so haven't tried the formula yet, but Stan's explanation gives me a very concrete and clear understanding of what is taking place.

              My other database doesn't use fixed size of fields, so the issue with sorting doesn't occur as it does with Alpha, one reason why I never thought in Alpha terms prior to this.

              This has been very helpful and useful knowledge. Thanks again.
              "Ollie, remember how dumb I used to be? Well, I'm much better now."

              Pete

              Comment

              Working...
              X