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

alltrim in function help

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

    alltrim in function help

    I created a function to clean up lists, as follows:

    Code:
     
    function list_cleanup as c(vList as C)
     vList=comma_to_crlf(vList)
     *for_each(X,alltrim(X),vList)
     vList=remove_blank_lines(vList)
     if vList=""
      goto Endit
     end if
     vList=crlf_to_comma(vList)
     vList=sortsubstr(vList,",")
     vList=*remove_duplicates(vList,",")
     endit:
     list_cleanup=vlist
    end function
    This works fine in all the cases I've tested, except that alltrimming the individual elements doesn't seem to work. That is

    list_cleanup("abc, def,abc")
    yields
    "abc, def"
    It doesn't strip the leading blank off the second element.

    Anyone see what I'm doing wrong?

    Pat
    Pat Bremkamp
    MindKicks Consulting

    #2
    Re: alltrim in fuction help

    Pat

    Replace your *for_each line with this. That'll tell it to replace vlist with the processed list.

    vlist=*for_each(X2,alltrim(X2),vList)

    help reference:
    Character Result = *FOR_EACH( Tag as A, Each as A, List as C )



    It was nice to see you at the conference this year. Hope it was as helpful to you as it was to me.
    regards.
    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


      #3
      Re: alltrim in function help

      Thanks, Al. Only thing is, my head hurts where I slapped it and yelled "OF COURSE!"

      Yes, it was great to meet you at the conference. I learned a lot, and really feel like I made some new friends.

      Pat
      Pat Bremkamp
      MindKicks Consulting

      Comment


        #4
        Re: alltrim in function help

        Pat

        I hear you. It was coincidence that I was working on a list processing function at the same time. I'm not going to mention if I did the same thing.....

        Reminds me of the old commercial - 'Wow, I could've had a V8!'
        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: alltrim in function help

          Originally posted by Al Buchholz View Post
          Pat

          I hear you. It was coincidence that I was working on a list processing function at the same time. I'm not going to mention if I did the same thing.....

          Reminds me of the old commercial - 'Wow, I could've had a V8!'
          Just for fun....

          Code:
          FUNCTION list_cleanup as c(vList as C)
          	list_cleanup=stritran(*remove_duplicates(sortsubstr(remove_blank_lines(*for_each(X,alltrim(X),comma_to_crlf(vList))),crlf())),crlf(),",")
          END FUNCTION
          At least I think it is equivalent.
          There can be only one.

          Comment


            #6
            Re: alltrim in function help

            Stan

            Interesting. I'm wondering of there is a performance difference between those two approaches.

            There is a readability issue for me with single line, but....

            Maybe Pat will try both of them and let us know....
            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


              #7
              Re: alltrim in function help

              Stan,
              Would you mind breaking down that function for us? I would like to be able to understand how you came up with it and how it would be used.
              Robin

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

              Comment


                #8
                Re: alltrim in function help

                Robin

                It's the same logic as Pat had in the first post of the thread, just put together on one line.

                The only variations are the check for an empty list after the de-blank and the assignment of the list in the *for_each().

                It's a nice example of functions within a function. But I find it hard to sight read. I prefer the listing that Pat had for read ability, but if there is a speed improvement, then I'd add the documentation to it so it made sense.

                As far as where it should be used.... it may be as simple as taking user input that allows duplicates to find if there are duplicates. It may be an custom import of a file where duplicates are not wanted.

                It also reminds me of the request for a linear listing of child records that was asked recently. The function that was put together resulted in a comma seperated list. This would allow a de-duping and de-blanking of that list (if needed).

                Yes I'm rambling... it's late here..

                Robin - you should have come to the conference, or at least shown up in Vegas. So close is LA, yet so far away... Isn't that a short drive?

                Pat is right - meeting people is one of the best parts of the conference. It's something that we can't emulate with all of the technology that we have.
                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


                  #9
                  Re: alltrim in function help

                  Hi Al,

                  Originally posted by Al Buchholz View Post
                  It's a nice example of functions within a function. But I find it hard to sight read.
                  Yes it is hard to read, but I can tell you without even testing, that the 1 line version is significantly faster. Each assignment line in Alpha 5 has a fairly high overhead, compared to expression evaluation (although it shouldn't really IMHO - this could change in future versions), something discussed in my talk on code speed 2 years ago at the Alpha 5 Conference.

                  Better yet would be to use WORD_EVALUATE() instead of *for_each(). This is almost identical, except the expression is in quotes and you can specify a delimiter, saving extra processing steps and running it even faster.

                  Of course, if you had a timing utility, I don't know, maybe the CSDA Code Utility for Alpha 5 (Shameless plug;) ), you could get accurate timing measurements. I'll try to run some tests later today to give you real number differences.
                  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


                    #10
                    Re: alltrim in function help

                    *for_each() will run much faster than word_evaluate() as word_evaluate() is written in xbasic. Both do essentially the same thing, but *for_each() effectively replaces word_evaluate().

                    Stan's one line expression is slightly faster, but more difficult to construct and maintain. *for_each() runs slightly faster when run on a crlf() delimited list than it does on a comma delimited.

                    Here are some example times on a 3060 line list built of very long elements on each line (each line over 100 characters). The list was created with filefind.get_recurse().

                    (all times in seconds)

                    Original function: 3.952277
                    Stan's expression: 3.724890
                    Word_evaluate: 5.002599

                    These were repeated with *for_each() run on the crlf() delimited list and the result converted to comma delimited.
                    Code:
                    vList=comma_to_crlf(vList)
                    vlist = *for_each(X,alltrim(X),vList)
                    vList=remove_blank_lines(vList)
                    
                    vList=sortsubstr(vList,crlf())
                    vList=*remove_duplicates(vList,crlf())
                    vList=crlf_to_comma(vList)
                    Time to run above: 3.760223
                    Time when converted to single expression: 3.762531

                    If the elements are much shorter, and the list shorter, the times are much faster. In that case, there is virtually no difference between the multi line code and the single expression, or between running *for_each() on crlf() delimited or comma delimited

                    Example: 411 lines with the longest line under 50 characters

                    Original function: .018460
                    Stan's expression: .018699
                    Word_evaluate: .166426

                    *for_each() on crlf() delimited

                    Time to run multi line: .019079
                    Time when converted to single expression: .018281

                    Incidentally, the biggest speed hit comes from converting from comma to crlf() and vice versa and sorting the list. If the original list is crlf() and the output is crlf(), the speed drops to

                    .012187
                    Last edited by JerryBrightbill; 05-16-2007, 09:06 AM.

                    Comment


                      #11
                      Re: alltrim in function help

                      Hi Jerry,

                      Originally posted by JerryBrightbill View Post
                      *for_each() will run much faster than word_evaluate() as word_evaluate() is written in xbasic. Both do essentially the same thing, but *for_each() effectively replaces word_evaluate().
                      After testing speed of word_evaluate, this becomes obvious.

                      Originally posted by JerryBrightbill View Post
                      Stan's one line expression is slightly faster, but more difficult to construct and maintain.
                      That's why we have comment lines, to explain difficult code. I would seldom trade speed for clarity (but you can show the expanded case in the comments)

                      Originally posted by JerryBrightbill View Post
                      *for_each() runs slightly faster when run on a crlf() delimited list than it does on a comma delimited.
                      Is there a new version of *for_each() that allows specifying the delimiter? I'm not aware of it, although, it would be a nice feature.

                      After testing, I found most of the time is spent in the *for_each() and sortsubstr() functions (about a half each). The assignments are such a small part of the overall processing, it ends up in the noise unless you have small lists, so I'm not surprised Stan's version did not seem any faster

                      The fastest expanded code was;
                      Code:
                      'vList=comma_to_crlf(vList)    ' A little slower than stritran equivalent
                      vList=stritran(vList,",",chr(13)+chr(10))
                      vlist = *for_each(X,alltrim(X),vList)
                      vList=remove_blank_lines(vList)
                      
                      vList=sortsubstr(vList,crlf())
                      vList=*remove_duplicates(vList,crlf())
                      'list_cleanup=crlf_to_comma(vList)    ' Much slower (factor of about 2) than stritran equivalent
                      list_cleanup=stritran(vList,",",chr(13)+chr(10))
                      Note the significant difference between
                      STRITRAN() and CRLF_TO_COMMA()
                      versus
                      STRITRAN() and COMMA_TO_CRLF()
                      And CHR(13)+CHR(10) is faster than CRLF() by a small amount.
                      Last edited by csda1; 05-16-2007, 11:27 AM.
                      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