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

Character Field Sorting

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

  • Character Field Sorting

    Hi all,

    I'm trying to sort a character field that is used as a drop-down lookup.
    This field holds part numbers and does sometimes contain letters.

    Here is the current result of the lookup list:
    11111
    22222
    33333-3
    33333-4
    33333

    This is the desired result:
    11111
    22222
    33333
    33333-3
    33333-4

    Is there a character function to help achieve this sorting?
    Thanks!

  • #2
    Re: Character Field Sorting

    Based on the data provided, I would be tempted to setup a "sort" column, based on the lookup column.
    I would replace the "-" with a period, then sort by val(sort)
    Gregg Schmidt

    Comment


    • #3
      Re: Character Field Sorting

      try loading the values into an array, then sort the array?

      This was obviously just using some text data elements, but you could initialize the array from a table as well.

      Code:
      DIM TXT[6] AS c
      TXT.initialize(<<%list% 
      11111
      22222
      33333-3
      33333-4
      33333
      %list%)
      txt.sort("A")
      results:sorted array.jpg

      Tom

      Comment


      • #4
        Re: Character Field Sorting

        thanks for the replies.
        Gregg I gave your's a shot first and although it seems like it should work, it works only partially.
        Here's what I put in the Display Order box in the lookup tab:
        sorting.JPG


        VAL(STRTRAN(PART_NUMBER,"-","."))
        Confirmed that the result is as follows: VAL(STRTRAN("11-2","-",".")) comes out to 11.2

        I then tested it as an equation: VAL(STRTRAN("11-2","-",".")) > VAL(STRTRAN("11","-",".")) the result yields True
        Opening the drop-down, it does sort in the correct order, HOWEVER, when typing "11" in the field it brings up the "11-2" number first even-though its listed as the second item...am I missing something?

        Comment


        • #5
          Re: Character Field Sorting

          John,

          I'm sorry. I thought you were building an x-dialog box for the lookup. Let me go a little further and see what I can come up with.

          Comment


          • #6
            Re: Character Field Sorting

            Hi John,

            I must be missing something.
            Please consider sharing your component along with some sample data.
            This will let us see what you're seeing.
            Gregg Schmidt

            Comment


            • #7
              Re: Character Field Sorting

              Hey John,

              Hopefully I understand what you are going for. This seemed to work for me with limited knowledge of your table:
              Code:
              Padr(Numbers,7,"-0")
              Table with numbers:
              data table.PNG

              The Lookup:
              lookup.PNG

              Result:
              Result.PNG

              **EDIT: It should be padr, not padl... It somehow still worked with padl, but we need to add the "-0" to the right of the string.**
              Last edited by Davidowicza; 09-27-2019, 12:07 PM. Reason: Syntax

              Comment


              • #8
                Re: Character Field Sorting

                Thanks Andrew, I'll give it a try later.
                Could you do me a favor and check also when typing in for example: "33" what is the suggestion that it brings up?
                The problem i was having was that the list was sorted correctly but it was suggesting the "-3" rather than "no dash" as the first entry.

                Comment


                • #9
                  Re: Character Field Sorting

                  Confirmed (with the correct Padr())

                  confirmed.PNG

                  Comment


                  • #10
                    Re: Character Field Sorting

                    my part numbers are varying lengths so I tried including the len() function.
                    It wasn't successful padr(PART_NUMBER,len(PART_NUMBER),"-0") did not even sort correctly. How would the padding function help to sort properly, I'm failing to understand the logic behind this.

                    Comment


                    • #11
                      Re: Character Field Sorting

                      Since your numbers do not have the save format, by adding the -0 to numbers that don't have that format makes the numbers consistent enough to sort them correctly.
                      Robin

                      Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

                      Comment


                      • #12
                        Re: Character Field Sorting

                        Hey John,

                        Sorry I was out for a couple of days.

                        Originally posted by hov333 View Post
                        my part numbers are varying lengths so I tried including the len() function.
                        It wasn't successful padr(PART_NUMBER,len(PART_NUMBER),"-0") did not even sort correctly. How would the padding function help to sort properly, I'm failing to understand the logic behind this.
                        Does that mean my ordering filter is not working for you? With the information you provided, it will work. You showed us that your table has numbers with a length of 5 or 7, so that is why we padr() with a length of 7 on them, which would add the "-0" to all the 5 length numbers making them a length of 7 while putting them as the smallest for the group (11111-0) so alpha can sort them accordingly. Can you please be more specific on what you mean by "varying lengths"? Maybe that is where I am losing you.
                        Last edited by Davidowicza; 10-01-2019, 08:49 AM.

                        Comment


                        • #13
                          Re: Character Field Sorting

                          Just taking a guess here, but by varying lengths, we might see:
                          A) the number to the right of the hyphen may increment above 9
                          B) 33333-XXX (as he mentions that it sometimes contains letters)

                          Comment


                          • #14
                            Re: Character Field Sorting

                            You are right Lonnie, I did miss that it sometimes includes letters...

                            But taking a stab at what you are saying about the right of the hyphen, I'll go for the max length of each is XXXXX-XXXXX (Again assuming since we don't have that info.)

                            This should work:

                            Code:
                            padl(word(Numbers,1,"-"),5,"0")+" "+padr(word(Numbers,2,"-"),5,"0")

                            Comment

                            Working...
                            X