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

Trying to combine lists from arrays...

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

  • Trying to combine lists from arrays...

    I am trying to combine selections from an array. Those selections have a list of their own which I'd like to combine. For example, I have a food list consisting of fruits, veges, meats, dairy, and legumes. Each food list has it's own list of foods: -fruits, for example, has a list of its own: apples, oranges, peaches, pears. When I select a food such as fruits I would like to also return those items. I can't however, figure out how to make multiple food selections and add those "subitems" to one group (in this case: TOTAL_LIST).


    'code------------------
    dim FOODLIST[5] as C
    FOODLIST.initialize(<<%list%
    fruits
    veges
    meats
    dairy
    legumes
    %list%)

    dim fruitlist[4] as c
    FRUITLIST.initialize(<<%list%
    apples
    oranges
    peaches
    pears
    %list%)

    dim vegeslist[5] as c
    VEGESLIST.initialize(<<%list%
    carrots
    string beans
    broccoli
    spinach
    corn
    %list%)

    dim meatslist[4] as c
    MEATSLIST.initialize(<<%list%
    pork
    chicken
    lamb
    ham
    %list%)

    dim legumeslist[4] as c
    LEGUMESLIST.initialize(<<%list%
    soybeans
    peas
    peanuts
    lentils
    %list%)

    ui_modeless_dlg_box("show_array",<<%dlg%

    [%mW%.50,10fLIST^#FOODLIST]
    {watch=list!foo}{sp}
    [%MW%.28,10fLIST];

    [%mw%.50,5TOTAL_LIST];
    <15&Cancel!cancel>
    %dlg%,<<%code%

    if a_dlg_button="cancel" then
    ui_modeless_dlg_close("show_array")
    end
    end if

    if a_dlg_button="foo" then


    end if

    %code%)

    'end code-----------

  • #2
    Re: Trying to combine lists from arrays...

    Here's something I came up with, but I am sure there's another (possibly more efficient) way.

    'code------
    dim FOODLIST as C
    FOODLIST=<<%a%
    fruits
    veges
    meats
    dairy
    legumes
    %a%

    dim fruits[5] as c
    FRUITS.initialize(<<%list%
    apples
    oranges
    peaches
    pears
    %list%)

    dim dairy[4] as c
    dairy.initialize(<<%list%
    milk
    eggs
    cheese
    cream
    %list%)

    dim veges[5] as c
    VEGES.initialize(<<%list%
    carrots
    string beans
    broccoli
    spinach
    corn
    %list%)

    dim meats[4] as c
    MEATS.initialize(<<%list%
    pork
    chicken
    lamb
    ham
    %list%)

    dim legumes[4] as c
    LEGUMES.initialize(<<%list%
    soybeans
    peas
    peanuts
    lentils
    %list%)

    dim total_list as c

    ui_modeless_dlg_box("show_array",<<%dlg%

    [%mW%.50,10fLIST^#FOODLIST]
    {watch=Flist!foo}{sp}
    [%MW%.14,10fLIST];

    [%mw%.50,15TOTAL_LIST]
    <15&Cancel!cancel>
    %dlg%,<<%code%

    if a_dlg_button="cancel" then
    ui_modeless_dlg_close("show_array")
    end
    end if

    if a_dlg_button="foo" then
    dim total_list1 as c
    total_list1=""
    dim total_list2 as c
    total_list2=""
    dim total_list3 as c
    total_list3=""
    dim total_list4 as c
    total_list4=""
    dim total_list5 as c
    total_list5=""

    if flist="" then
    total_list=""
    end if

    for each foo in fList
    if is_one_of(foo, Flist) = .t.

    if is_one_of("fruits",flist)
    total_list1 = fruits.dump("r")
    end if

    if is_one_of("veges",flist)
    total_list2 = veges.dump("r")
    end if

    if is_one_of("meats",flist)
    total_list3 = meats.dump("r")
    end if

    if is_one_of("legumes",flist)
    total_list4 = legumes.dump("r")
    end if

    if is_one_of("dairy",flist)
    total_list5 = dairy.dump("r")
    end if
    continue
    end if

    next

    end if
    total_list=""
    total_list=total_list1+total_list2+total_list3+total_list4+total_list5
    %code%)

    'end code-------

    Comment


    • #3
      Re: Trying to combine lists from arrays...

      I see that you have come up with a semi-solution to your combining of lists. But as powerful as Alpha's list-processing functions are, I wanted to chime in on this.

      The approach shown below is simpler and more concise. With minimal code, all of the processing is done for creating the combined list. Often times after extracting field data into lists, I use the *for_each() and remove_blank_lines() functions to do powerful processing in a short time.

      Code:
      DIM SHARED cFoodlist as C
      DIM SHARED cTotal_List as C
      DIM SHARED cTypes as C
      DIM SHARED varC_result as C
      DELETE a_cFoodlist		
      DIM a_cFoodlist[5] as c
      dim temp_list as c 
      temp_list = <<%list%
      fruits
      veges
      meats
      dairy
      legumes
      %list%
      cItems = <<%itms%
      f|apples
      f|oranges
      f|peaches
      f|pears
      d|milk
      d|eggs
      d|cheese
      d|cream
      v|carrots
      v|string beans
      v|broccoli
      v|spinach
      v|corn
      m|pork
      m|chicken
      m|lamb
      m|ham
      l|soybeans
      l|peas
      l|peanuts
      l|lentils
      %itms%
      a_cFoodlist.initialize(temp_list)
      ok_button_label = "&OK"
      cancel_button_label = "&Cancel"
      varC_result = ui_dlg_box("Food List",<<%dlg%
      {region}
      Food Groups:| [%M%.40,10cFoodlist^#a_cFoodlist!cFoods_];
      {endregion};
      {line=1,0};
      {region}
      [%mw%.50,15cTotal_List]
      {endregion};
      {region}
      <*15=ok_button_label!OK> <15=cancel_button_label!CANCEL>
      {endregion};
      %dlg%,<<%code%
      if left(a_dlg_button,7) = "cFoods_"
      	cTypes = ""
      	for j = 1 to w_count(cFoodlist,crlf())
      		cTypes = cTypes + left(word(cFoodlist,j),1)
      	next j
      	cTotal_List = cItems
      	cTotal_List = *for_each(foo,if(left(foo,1)$cTypes,word(foo,2,"|"),""),cTotal_List)
      	cTotal_List = remove_blank_lines(cTotal_List)
      	a_dlg_button = ""
      end if
      %code%)
      I hope this helps.

      Steve

      Comment


      • #4
        Re: Trying to combine lists from arrays...

        Hi Steve,
        That's more like it! I just started using xbasic this year and really enjoy the flexibility. Thank you for chiming in! I'll study and implement into my "real" code. Enjoy the sunny day we're having in NJ!

        Don

        Comment

        Working...
        X