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

Create multiple vars and set with table data

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

    Create multiple vars and set with table data

    I am using a table with data provided by Dan Latshaw and so far have accomplished the following:

    varlist = table.external_record_content_get("serv_tmpl","serv_id","sortkey")
    ?varlist
    = S013
    S001
    S002
    S003
    S014
    S004
    S015
    S005
    S020
    S017
    S012
    S022
    S008
    S011
    S023
    S019
    S018
    S007
    S010
    S009
    S024
    S016
    S006
    S021

    datalist = table.external_record_content_get("serv_tmpl","serv_desc","sortkey")
    ?datalist
    = Case Management
    Medicaid
    Medical
    CHIP
    Food Stamps/ SNAP
    WIC
    Housing/ Rental Assistance
    HPRP
    Section-8 Public Housing
    Job Training
    Other Employment Services
    Subsidized Or TANF Daycare
    Transportation
    Welfare To Work
    WIAS-Workforce Investment Act
    MATP-Med Assist Trans Program
    Mental Health Services
    Primary Health Services
    VA Medical
    VA Services
    D/A Substance Abuse Treatment
    DV-Domestic Violence
    Other TANF
    SSDI/ SSI/ SOAR Income

    for each foo in vList
    evaluate_template("dim global "+foo.value+" as c")
    next

    What I want to do now is set those 24 variables with the corresponding data from the datalist - how do I do that?
    Robin

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

    #2
    Re: Create multiple vars and set with table data

    Try

    varlist = table.external_record_content_get("serv_tmpl","serv_id","sortkey")
    datalist = table.external_record_content_get("serv_tmpl","serv_desc","sortkey")
    qx = 1
    for each foo in vList
    evaluate_template("dim global "+foo.value+" as c = "+word(datalist,qx,crlf()))
    qx = qx + 1
    next
    There can be only one.

    Comment


      #3
      Re: Create multiple vars and set with table data

      Hi Stan,
      I was trying to do something like your example and that was where I got stuck - in the meantime I found this works too:


      Code:
      tbl = table.open("serv_tmpl")
      tbl.index_primary_put("sortkey")
      tbl.fetch_first()
      while .not. tbl.fetch_eof()
      	evaluate_template("dim global "+tbl.serv_id+" as c = "+quote(alltrim(tbl.serv_desc)))
      	tbl.fetch_next()
      end while
      tbl.close()
      However, I like yours better!
      Robin

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

      Comment


        #4
        Re: Create multiple vars and set with table data

        Mine needs the quotes too.

        evaluate_template("dim global "+foo.value+" as c = "+quote(word(datalist,qx,crlf())))
        There can be only one.

        Comment


          #5
          Re: Create multiple vars and set with table data

          When dealing with more than one or two values as you are I lean towards creating a collection.

          Example code below has some extraneous statements combining the two strings which would be obviated if I had access to the table.

          Code:
          coll_list = ""
          qx = 1
          for each foo in varlist
          coll_list = coll_list+foo.value+";"+word(datalist,qx,crlf())+crlf()
          qx = qx + 1
          next
          delete depts. 'clear any previous values
          dim depts as u 'this is the collection
          depts.initialize("1;2","1","2",coll_list) 'this does the work
          ? depts.get("S014") 'retrieve a value
          = " Food Stamps/ SNAP"
          ? depts.get("S001") 'and again
          = " Medicaid"
          ? depts.size() 'not sure if you would need this
          = 24
          ? depts.exist("ABC1") 'can test for a key before trying to use its value
          = .F.
          
          ? depts.dump("key~value") 'can examine the collection
          = S013~Case Management
          S001~ Medicaid
          S002~ Medical
          S003~ CHIP
          S014~ Food Stamps/ SNAP
          S004~ WIC
          S015~ Housing/ Rental Assistance
          S005~ HPRP
          S020~ Section-8 Public Housing
          S017~ Job Training
          S012~ Other Employment Services
          S022~ Subsidized Or TANF Daycare
          S008~ Transportation
          S011~ Welfare To Work
          S023~ WIAS-Workforce Investment Act
          S019~ MATP-Med Assist Trans Program
          S018~ Mental Health Services
          S007~ Primary Health Services
          S010~ VA Medical
          S009~ VA Services
          S024~ D/A Substance Abuse Treatment
          S016~ DV-Domestic Violence
          S006~ Other TANF
          S021~ SSDI/ SSI/ SOAR Income
          There can be only one.

          Comment


            #6
            Re: Create multiple vars and set with table data

            How would you change the script for the table?
            Robin

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

            Comment


              #7
              Re: Create multiple vars and set with table data

              I would use table.external_record_content_get() with a twist to populate the list in one pass. Example below builds a string from the ordgde table, pulling a numeric field (ex_posit) and a character field (fscde) and placing the semicolon between them. The collection is initialized from this list as suggested earlier.

              There is another method .from_table() which is more direct but it ignores marked records (a bug I think).

              Code:
              ? table.external_record_content_get("ordgde","alltrim(str(ex_posit))+';'+alltrim(fscde)","ex_posit")
              = 20;255869
              30;259309
              40;160093
              50;126797
              60;126946
              80;125864
              90;385740
              100;255844
              120;258004
              123;443760
              There can be only one.

              Comment


                #8
                Re: Create multiple vars and set with table data

                That is simpler, coll_list replaces the need for the varlist as well as the datalist. Thanks Stan, I think that example clarifies how a collection can be used very well.
                Last edited by MoGrace; 08-19-2016, 01:40 PM.
                Robin

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

                Comment


                  #9
                  Re: Create multiple vars and set with table data

                  I thought I would try making a generic function so I could set other collection variables and am not having much luck getting a return value.

                  This is the rough script:
                  Code:
                  FUNCTION SetCollectVar AS C (datalist AS C, varname AS U )
                  'Call before function	
                  'Example: dataList = table.external_record_content_get("servtmpl","alltrim(serv_id)+';'+alltrim(serv_desc)","serv_id")
                  
                  cmd = "delete "+varname
                  evaluate_template(cmd)
                  cmd = "dim "+varname+" as U"
                  evaluate_template(cmd)
                  cmd = convert_expression(varname+".initialize(\"1;2\",\"1\",\"2\",dataList)","V")
                  evaluate_template(cmd)
                  cmd = convert_expression(varname+".dump(\"key~value\")","V")
                  
                  SetCollectVar = evaluate_template(cmd)
                  END FUNCTION
                  This is my testing in the IW:
                  Code:
                  dataList = table.external_record_content_get("HOUSING","alltrim(housingid)+';'+alltrim(housing)","housingid")
                  
                  ?SetCollectVar(datalist,"house")
                  [COLOR="#0000FF"]ERROR: Variable type mismatch: attempt to pass data of type 'C' to argument 'varname ' is of type 'U'.
                  [/COLOR]
                  '==============
                  
                  varname = "house"
                  
                  cmd = "delete "+varname
                  ?cmd
                  = "delete house"
                  evaluate_template(cmd)
                  
                  cmd = "dim "+varname+" as U"
                  ?cmd
                  = "dim house as U"
                  evaluate_template(cmd)
                  
                  cmd = convert_expression(varname+".initialize(\"1;2\",\"1\",\"2\",dataList)","V")
                  ?cmd
                  = house.initialize("1;2","1","2",dataList)
                  evaluate_template(cmd)
                  
                  cmd = convert_expression(varname+".dump(\"key~value\")","V")
                  ?cmd
                  = house.dump("key~value")
                  [COLOR="#FF0000"]?evaluate_template(cmd)
                  = ""[/COLOR]
                  
                  [COLOR="#0000FF"]'note that the variable is populated[/COLOR]
                  v= house.dump("key~value")
                  ?v
                  = H001~Emergency shelter  including hotel or motel paid by emergency shelter voucher
                  H002~Foster care home or foster care group home
                  H003~Hospital or other residential non-psychiatric medical facility
                  H004~Hotel or motel paid for without emergency shelter voucher
                  H005~Jail, prison or juvenile detention facility
                  H006~Long-term care facility or nursing home
                  H007~Owned by client, no ongoing housing subsidy
                  H008~Owned by client, with ongoing housing subsidy
                  H009~Permanent housing for formerly homeless persons
                  H010~Place not meant for habitation
                  H011~Psychiatric hospital or other psychiatric facility
                  H012~Rental by client, no ongoing housing subsidy
                  H013~Rental by client, with VASH subsidy
                  H014~Rental by client, with GPD TIP subsidy
                  H015~Rental by client, with other ongoing housing subsidy
                  H016~Residential project or halfway house with no homeless criteria
                  H017~Safe Haven
                  H018~Staying or living in a family member's room, apartment or house
                  H019~Staying or living in a friend's room, apartment or house
                  H020~Substance abuse treatment facility or detox center
                  H021~Transitional housing for homeless persons (including homeless youth)
                  H022~Other
                  H023~Client doesn't know
                  H024~Client refused
                  H025~Data not collected
                  H026~Subsidized Housing
                  H027~On the Street
                  H028~Nursing Home
                  Robin

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

                  Comment


                    #10
                    Re: Create multiple vars and set with table data

                    FUNCTION SetCollectVar AS C (datalist AS C, varname AS U )

                    varname AS C

                    The name of the collection variable is character, the value of that variable gets dimmed as U in the function.
                    There can be only one.

                    Comment


                      #11
                      Re: Create multiple vars and set with table data

                      Hi Stan,
                      I tried it as C first, then A, then P (typeof() returned P for the other collection var) and last as U. It didn't make any difference - same error.

                      But sometimes new functions don't update properly, so I will change it back to C and reopen the adb and see if that makes a difference...
                      Robin

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

                      Comment

                      Working...
                      X