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 a character type field

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

    sorting a character type field

    Hello, I'm wondering if there is a way to soft a field that is defined as character, that only have numbers in it in numeric order , like 1, 2, 3 etc , instead of 1, 10, 100, 101 etc. I tried using the val function on the Order field on the Sort Records To Print dialog box, but the records still did not sort properly. Any help would be greatly appreciated.

    Thank you
    Tracy

    #2
    Re: sorting a character type field

    Try using val() and remspecial(), i.e., val(remspecial(your_field_name))

    Raymond Lyons

    Comment


      #3
      Re: sorting a character type field

      I generally force the sort with

      padl(alltrim(fieldname),n,"0")

      where n is the defined width of the field.
      There can be only one.

      Comment


        #4
        Re: sorting a character type field

        Originally posted by Stan Mathews View Post
        I generally force the sort with

        padl(alltrim(fieldname),n,"0")

        where n is the defined width of the field.
        Stan is "generally" far smarter than I am, but my method and his will give very different results if a field ever has something like "5g" in it instead of just "5". Test them and see. Then someone will probably show you how to strip out any "g"'s if something like that is likely, or keep them from getting into the field in the first place. Lots of ways to skin a cat in Alpha Five. For now, I have to go to dinner, which I hope won't include cat meat--or horse.

        Raymond Lyons

        Comment


          #5
          Re: sorting a character type field

          Hello,

          I tried added the remspecial function to my formula, and it didn't work
          I also tried the padl(alltrim suggestion and that didn't work either
          The numbers still sorted like the 1, 100, . . . . .2 etc

          I looked for a function to convert a character field to a numeric filed, but could not find one. Does such a function exist?

          Thank you
          Tracy

          Comment


            #6
            Re: sorting a character type field

            I looked for a function to convert a character field to a numeric filed, but could not find one. Does such a function exist?
            No. There is a function that that will convert a character value to a numeric value that was provided you in the first answer to your post.

            I tried added the remspecial function to my formula, and it didn't work
            I also tried the padl(alltrim suggestion and that didn't work either
            The numbers still sorted like the 1, 100, . . . . .2 etc
            Then you did something wrong in both attempts. Both will work if applied correctly.
            There can be only one.

            Comment


              #7
              Re: sorting a character type field

              Tracy,

              As Stan said, you have to be doing something wrong. Unzip and take a look at the sample I am attaching. The sorting is done in the report layouts (Report, Select Records in design mode for the layouts).

              Raymond Lyons
              Attached Files

              Comment


                #8
                Re: sorting a character type field

                Description

                VAL() converts a Character_String to a numeric value. If the Character_String contains leading non-numeric characters, then a value of 0 is returned.
                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


                  #9
                  Re: sorting a character type field

                  Originally posted by Ted Giles View Post
                  Description

                  VAL() converts a Character_String to a numeric value. If the Character_String contains leading non-numeric characters, then a value of 0 is returned.
                  Ted,

                  While what you say is true (I think!), it does not seem to apply to trailing non-numeric characters, and the 2 ways given to Tracy do result in different orders. Below I give one way of dealing with a single leading non-digit, but there must be other, better ways to deal with sorting of this kind. It's just beyond me at the moment.

                  Raymond Lyons
                  Attached Files

                  Comment


                    #10
                    Re: sorting a character type field

                    Hi Stan,

                    I went back and checked everything that I could think of.
                    The OrderNbr field is defined as character, width = 6

                    I typed the expression below on the Select Record to PRint dialog in the Order field.
                    padl(alltrim(OrderNbr),6,"0")

                    The rpt displays the records in this order 1, 10, 100, 101, 102

                    I was expecting to see this order 1, 2, 3,4 5, etc

                    I don't know what else to check to figure out why this isn't working for me.

                    Tracy


                    Originally posted by Stan Mathews View Post
                    I generally force the sort with

                    padl(alltrim(fieldname),n,"0")

                    where n is the defined width of the field.

                    Comment


                      #11
                      Re: sorting a character type field

                      Hi Raymond,

                      After looking at the reports that you created, I quickly realized that the reason it wasn't working for me is because the field I'm sorting on is the group field, not a field in the details section of the report. when I pasted the val(remspecial expression on the group break field, the sort worked as you said it would.

                      I went back and looked at my original message and saw that I left out that I was doing this at the group.
                      I am so sorry that I caused so much drama over this issue.
                      I truly appreciate and am thankful that you and everyone else that posted a reply to this thread did not give up on me.

                      Thank you to everyone that posted a reply.
                      Tracy



                      Originally posted by Raymond Lyons View Post
                      Tracy,

                      As Stan said, you have to be doing something wrong. Unzip and take a look at the sample I am attaching. The sorting is done in the report layouts (Report, Select Records in design mode for the layouts).

                      Raymond Lyons

                      Comment


                        #12
                        Re: sorting a character type field

                        Tracy

                        I haven't made a mistake since the last one and I vow not to make another one until the next 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


                          #13
                          Re: sorting a character type field

                          LOL Al,

                          After I figured out what was wrong, I was able to fix it, and all is well.
                          Thank you
                          Tracy

                          Originally posted by Al Buchholz View Post
                          Tracy

                          I haven't made a mistake since the last one and I vow not to make another one until the next one...

                          Comment

                          Working...
                          X