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

Add "ALL" to Listbox

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

    Add "ALL" to Listbox

    This is probably very easy but I cannot seem to figure out how to do this. I want to create a listbox on a form that gets data from an employee database but includes "ALL" at the top of this list. A normal listbox populated by employees is easy with the genie, but adding the all is my issue.

    It seems the list box needs crlf expression to do this which is where I am not sure how to do this. I would like to put "ALL" at the top of the list and read in the data from the external database into a crlf list. Your help is greatly appreciated.

    #2
    Re: Add "ALL" to Listbox

    Suppose your list box already displays the lastnames of all customers in the customer table by using the built in genie choice setting ("Computed Automatically") to do that. Change the choice setting to Populated using xbasic.

    The code for the oninit event for the form would then be

    Code:
    my_list = table.external_record_content_get("customer","alltrim(lastname)","lastname")
    my_list = "All"+crlf()+my_list
    
    DIM pObj AS P
    
    pObj = topparent:DROPDOWN1.this
    pObj.settings.dynamic_list = my_list
    There can be only one.

    Comment


      #3
      Re: Add "ALL" to Listbox

      A related comment for whatever it's worth....

      I used to put "ALL" at the top of many of my lists and I still do it sometimes. However, sometimes I find it easier to just add a "Select All" and "Clear All" button. I do this in xdialogs a lot and just add something like this in the %code% section:
      Code:
       
      IF a_dlg_button = "Select All"
          <choice_var> = <original_list>
          a_dlg_button = ""
      ELSEIF a_dlg_button = "Clear All"
          <choice_var> = ""
          a_dlg_button = ""
      END IF
      The advantage of this method is that you don't have to do anything special when selecting "All". If you have a multi-select box the user can select other choices as well as "ALL" so then you have to decide whether or not to really do "ALL" or just the others that were selected. Of course, this makes it more confusing to the user as well. There are ways to clear everything else when "ALL" is selected but that takes more work. My simple solution to this problem was to just add the buttons and leave the "ALL" selection off the list.

      If you don't want to loop through every line when all choices are selected, simply check to see if the selected list is equal to the full list when the xdialog closes.

      On the other hand, if you don't have a multi-select list and the user can only select one choice - one of which is "ALL" - then this isn't an issue.
      Last edited by CALocklin; 01-15-2010, 04:08 PM.

      Comment


        #4
        Re: Add &quot;ALL&quot; to Listbox

        Cal,
        EXCEPT I have just submitted an issue to Selwyn in which my xdialogs have been changing since version 8 for "Select All" !! If you have not noticed it, most likely it is due to your not using formatting for the list box. That is what has changed.

        In fact it even influenced my variable that represents the names in one case. So currently I have to have 3 versions of the same list box (for v8,v9,v10) in order to maintain the clients which have this as part of their interface (quite a few).

        My point is that go ahead and use the "Select All" button as it does work as Cal indicated , but be wary if using formatting.

        To put it euphemistically, what a PITA!! :D
        Last edited by MikeC; 01-15-2010, 11:27 PM. Reason: spelling
        Mike
        __________________________________________
        It is only when we forget all our learning that we begin to know.
        It's not what you look at that matters, it's what you see.
        Henry David Thoreau
        __________________________________________



        Comment


          #5
          Re: Add &quot;ALL&quot; to Listbox

          Thanks for the info, Mike. I seldom use formatting - it's usually just a simple list - but I'll keep that in mind.

          I do sometimes add tabs but, so far, I've found that easy to deal with. If what you are talking about is the keylistbuild, I haven't used that in years. I found keylistbuild great at times but too often too complicated. I spent more time trying to get that to work than I did just doing it with my own tabs. (Keylistbuild is easy with action scripting. My problems came when I tried to modify an existing keylist. That was something I found myself doing far too often - so I quit.)

          I usually add tabs as part of an table.external_record_content_get() definition but I found this example first:
          Code:
          WHILE .not. tpp.fetch_eof()
               rplist = rplist + trim(tpp.Raw_matf) + "{T=1.75} -- {T=1.75}" + trim(tpp.Proc_namef) + crlf()
               tpp.fetch_next()
          END WHILE
          What I've found is that the selected text does not include the tab definitions - the {T=1.75} stuff - so take that into consideration when working with the results and/or setting default choices. In other words, if in the above example raw_matf = "Steel" and proc_namef = "Weld" and you wanted to set that value as the default, the default would be simply "Steel -- Weld".

          Side note/Hint: Note that the tab positions in this example are both the same. The result is that the user does NOT see the " -- " but it IS included the selected text. You might say that the second {T=1.75} "folds" the display to hide the " -- ". I find this to be a really cool way to use tabs - it makes the display very user friendly while still making it easy for the developer to parse out various parts of the line. (Of course, the " -- " can be anything you want to use as a "word" separator.)

          Later: I haven't used a "select all" button often with a tabbed list but did do it at least once. What I did was simply used a couple stritran() lines to create the "all" list without the tabs. In the example above, this would be:
          <choice_list_var> = stritran( rplist, "{T=1.75}", "" )
          If there are multiple tab settings you would need to use multiple lines or stritranmulti(). I suppose you could come up with a generic routine to find all possible {T=...} combinations in a list and remove them but there's seldom more than 2-3 tab settings so it's probably fast enough in most cases to just do it manually.
          Last edited by CALocklin; 01-16-2010, 12:12 AM.

          Comment


            #6
            Re: Add &quot;ALL&quot; to Listbox

            Hi Mike,

            Originally posted by MikeC View Post
            XCEPT I have just submitted an issue to Selwyn in which my xdialogs have been changing since version 8 for "Select All" !! If you have not noticed it, most likely it is due to your not using formatting for the list box. That is what has changed.

            In fact it even influenced my variable that represents the names in one case. So currently I have to have 3 versions of the same list box (for v8,v9,v10) in order to maintain the clients which have this as part of their interface (quite a few).
            Can you give me an example of your formatting issues for the versions? I have not seen any behavior like this, but perhaps it's because I am using dialog boxes that work from V5 all the way to V10, and only using a few version specific variations.

            Also, Cal's use of code separators are OK, but see my discussion in my tips here, for alternate delimiters, which I use almost exclusively internally in my code.
            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


              #7
              Re: Add &quot;ALL&quot; to Listbox

              Ira,
              I sent you an email with the function that uses the xdialog. As I stated to Selwyn, the changes could very well be something that was intended (not the side effects!) and just wanted to try to reduce the amount of maintenance that will be required if this keeps changing from version to version. Definitely interested in what you feel is the cause.
              Mike
              __________________________________________
              It is only when we forget all our learning that we begin to know.
              It's not what you look at that matters, it's what you see.
              Henry David Thoreau
              __________________________________________



              Comment


                #8
                Re: Add &quot;ALL&quot; to Listbox

                Originally posted by csda1 View Post
                ... Also, Cal's use of code separators are OK, but see my discussion in my tips here, for alternate delimiters, which I use almost exclusively internally in my code.
                As I was typing "Of course, the " -- " can be anything you want to use as a "word" separator" I was thinking about your comments and that I really should reference your tips but I didn't have the link and was too lazy to find it. My use of " -- " stems from before I figured out how to use the tabs to "fold" the display. It was something that was presentable for users but not likely to otherwise be found in text strings. I often use chr(28) now but still tend to use " -- " when I'm sure there won't be a conflict.

                Comment


                  #9
                  Re: Add &quot;ALL&quot; to Listbox

                  Hi Mike,

                  Originally posted by MikeC View Post
                  Ira,
                  I sent you an email with the function that uses the xdialog. As I stated to Selwyn, the changes could very well be something that was intended (not the side effects!) and just wanted to try to reduce the amount of maintenance that will be required if this keeps changing from version to version. Definitely interested in what you feel is the cause.
                  It may or may not be a "bug", depending upon whether it was intended that way, and what similar things do, but ideally, it should be as consistent as possible going forward, so it is probably good to bring it to Alpha's attention.

                  The problem you are experiencing is that apparently Alpha Five is returning selected records from an XDialog control with and without the owner draw formatting fields depending upon version. I would tend to favor without owner draw text, but I could also see where this could get you into trouble.

                  This is because if you had {T=} commands or similar that basically separated fields of a line, you could use that to recreate a field separator. Without them, you would be lost as to where fields begin and end.

                  I also don't know if there is a consistency with different type of list objects in XDialogs and their return values with different versions. Ideally, all should be consistent.

                  If you use the {DATA=} construct for each line, the value within is what is normally returned.

                  So, below is your problem highlighted with a generic sample, and how to strip the "junk", independent of what version you are using.

                  Code:
                  ' Set owner draw format
                  Dim format as p 
                  Format.tab_stops="2"
                  Format.odd_row_color="White"
                  Format.even_row_color="White"
                  Format.odd_selected_color="Dark Blue"
                  Format.even_selected_color="Dark Blue"
                  Format.font="Courier New,10"
                  Format.font_color_unselected="Black"
                  Format.font_color_selected="White"
                  Format.lastbutton="OK"
                  Format.group_size=1
                  Format.number_rows=.f.
                  Format.alternating_bands=.f.
                  
                  ' Create a sample list
                  dim Text as c
                  Text=a5.Color_Enum()
                  
                  'Apply 'owner draw' formatting information to the list for use in the xdialog
                  dim textfmttd as c
                  textfmttd=a5_owner_draw_list_fmt(text,Format)
                  
                  
                  ' This show what the lines look like for the Xdialog Owner draw display
                  ?textfmttd
                  {F=Courier New,10}{C=Black,White}Black
                  {F=Courier New,10}{C=Black,White}Dark Red
                  {F=Courier New,10}{C=Black,White}Red
                  '  etc.
                  
                  ' In the event code of the xdialog, process the code when needing stripped versions
                  ' This will get rid of any text within {}.  If no {}, then effectively does nothing
                  ' Do not include any { in actual text though
                  ?regex_merge(textfmttd,"(\{[^\}]*\})","","")
                  = Black
                  Dark Red
                  Red
                  '  etc.
                  This is one of the reasons for learning Regular Expressions. It does string processing that other code would have a hard time with. And it is used both web side and desktop side, so is a useful skill to have.

                  I also comment briefly on something I saw in the code you sent in terms of speed.

                  There are points where two *for_each() are processing the text of the list sequentially. These could be combined into one *for_each() expression, meaning only 1 pass through the list data. While maybe you needed the intermediate data, it doesn't look like you did. And in your case, maybe the list doesn't get particularlly long, so it doesn't matter much if you process it twice.

                  But my basic speed rule is when processing multiple items in a loop (which the *for_each() is effectively), "never pay for the same ground twice".
                  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: Add &quot;ALL&quot; to Listbox

                    Thanks Ira for taking a look. So it is what I thought. I believe the original code came directly from Action Scripting and that is the only reason for using the formatting as I had it.

                    Xdialog is still a bit new for me, but due to some problems in QReportBuilder and how I have to connect to multiple companies using passive link tables, forms simply are not a viable option. So now deal with xdialog on a daily basis....which I guess is a good thing! :)

                    RegEx is something I have used occaisionally and like it, but I am not proficient enough to make good use of it---the more samples I see the easier it is though so thanks!

                    I appreciate the speed mention as well---had forgotten the possibility of using just one *for_each(). You were right in that there may be 100 records at most for each of them which makes speed a non-issue here. I will tuck it away though, as I have your other advice on optimizing code, as I do use it more and more as the clients I seem to be dealing with are tending to be getting bigger and bigger.
                    Mike
                    __________________________________________
                    It is only when we forget all our learning that we begin to know.
                    It's not what you look at that matters, it's what you see.
                    Henry David Thoreau
                    __________________________________________



                    Comment

                    Working...
                    X