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

using var in table.external_record_content_get

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

  • using var in table.external_record_content_get

    Does anyone know if you can include a variable in the table.external_record_content_get expression area?

    Example (which does not work). Getting "myvar" to appear inline next to the valid field name ("name"):

    myvar="123"
    lst = table.external_record_content_get("[PathAlias.ADB_Path]\users","name" + myvar)

    ?lst
    steve123
    mike123
    fred123
    Steve Wood
    Join the ALPHA DEVELOPERS NETWORK
    There is no Cloud. It's just someone else's computer.
    Web - Mobile - Hosting - Products - Frameworks - Developer Resources
    AlphaToGo | IADN (100% Alpha Anywhere Websites)

  • #2
    Re: using var in table.external_record_content_get

    lst = strtran(table.external_record_content_get("[PathAlias.ADB_Path]\users","alltrim(name)"),crlf(),myvar+crlf())+myvar

    tested, looks ok.

    Code:
    myvar = "123"
    
    ? table.external_record_content_get("atest","alltrim(svc)")
    = new
    none
    mill
    
    ? strtran(table.external_record_content_get("atest","alltrim(svc)"),crlf(),myvar+crlf())+myvar
    = new123
    none123
    mill123
    Last edited by Stan Mathews; 03-12-2010, 04:11 PM.
    There can be only one.

    Comment


    • #3
      Re: using var in table.external_record_content_get

      Hi Steve,

      Originally posted by Steve Wood View Post
      Does anyone know if you can include a variable in the table.external_record_content_get expression area?

      Example (which does not work). Getting "myvar" to appear inline next to the valid field name ("name"):

      myvar="123"
      lst = table.external_record_content_get("[PathAlias.ADB_Path]\users","name" + myvar)

      ?lst
      steve123
      mike123
      fred123
      myvar="123"
      lst = table.external_record_content_get("[PathAlias.ADB_Path]\users","name+\"" + myvar+"\"")

      The above always will work. Depending upon scope of myvar, the following may also work

      myvar="123"
      lst = table.external_record_content_get("[PathAlias.ADB_Path]\users","name+ var->myvar")
      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


      • #4
        Re: using var in table.external_record_content_get

        Here is what I came up with based on your help:

        Code:
        lst2 = ""
        for each foo1 in a_list
        	dta = "ulink + eval(foo1)"
        	vid = word(foo1,1,"|")
        	vemailto = word(foo1,2,"|")
        	lst2 = lst2 + table.external_record_content_get("[PathAlias.ADB_Path]\web_users","\"a|" + vid + "\"+'|'+ulink+'|'+ ""\""+ vemailto + "\"" ,"","agencyid="+quote(word(foo1,1,"|")))
        	lst2 = lst2 + crlf()
        next
        lst = lst + lst2
        Steve Wood
        Join the ALPHA DEVELOPERS NETWORK
        There is no Cloud. It's just someone else's computer.
        Web - Mobile - Hosting - Products - Frameworks - Developer Resources
        AlphaToGo | IADN (100% Alpha Anywhere Websites)

        Comment


        • #5
          Re: using var in table.external_record_content_get

          Steve,
          I was doing very similar yesterday. We were probably working on them at the same time. :) Aren't they loads of fun. After a while the quotes and escapes all start to blur.

          Here are a couple of other ideas based on Stan's general idea of processing after the initial external_record_content_get.

          This one simplifies the content expression placing the variables within '{}' and then uses the evaluate_string() to replace the variables.
          Code:
          lst2 = ""
          for each foo1 in a_list
              dta = "ulink + eval(foo1)"
              vid = word(foo1,1,"|")
              vemailto = word(foo1,2,"|")
              lst2 = lst2 + table.external_record_content_get("[PathAlias.ADB_Path]\web_users","\"a|{vid}|\"+ulink+\"|{vemailto}\"" ,"","agencyid="+quote(vid))
              lst2 = lst2 + crlf()
              evaluate_string(lst2,local_variables())
          next
          lst = lst + lst2
          This one returns only the ulink and then adds the other bits with the *for_each function
          Code:
          lst2 = ""
          for each foo1 in a_list
              dta = "ulink + eval(foo1)"
              vid = word(foo1,1,"|")
              vemailto = word(foo1,2,"|")
              lst2 = lst2 + table.external_record_content_get("[PathAlias.ADB_Path]\web_users","ulink","","agencyid="+quote(vId))
              lst2 = lst2 + crlf()
              lst2 = *for_each(ln,"a|"+vid+"|"+ln+"|"+vemailto,lst2)
          next
          lst = lst + lst2
          I don't know if they are any better in any way. I haven't tested with you know who's whiz bang timer yet. ;) But if you start to run out of escape and quote characters it may make things a bit easier to work with.
          Tim Kiebert
          Eagle Creek Citrus
          A complex system that does not work is invariably found to have evolved from a simpler system that worked just fine.

          Comment


          • #6
            Re: using var in table.external_record_content_get

            Yes, expressions are loads of fun! I think sometimes I go off on the deep end and create complex expressions with code indirection to see how far I can go. Then I have no idea what the code means later. Here is one that I've been glaring at for awhile:

            basefilter1 = eval("word(foo,1,\"|\")+\"->\"+word(foo,4,\"|\")+\"=\"+quote(eval(\"tbl.\"+word(foo,4,\"|\")))")

            Note - Ira's got a couple of classes on beginning and advanced xbasic, and regular expressions if anyone is interested in the subject of these particular posts. See IADN's webinar page.
            Steve Wood
            Join the ALPHA DEVELOPERS NETWORK
            There is no Cloud. It's just someone else's computer.
            Web - Mobile - Hosting - Products - Frameworks - Developer Resources
            AlphaToGo | IADN (100% Alpha Anywhere Websites)

            Comment


            • #7
              Re: using var in table.external_record_content_get

              Steve,
              You may not be aware that there is a <tbl>.record_content_get() function that is faster than table.external_record_content_get() if you're going to place it in a loop. table.external_record_content_get() opens and closes the table and its indexes for each call, which is the slowest part, usually, of table access.

              So to rewrite your code:
              Code:
              lst2 = ""
              webUsers=table.open("PathAlias.ADB_path]\web_users",file_ro_shared)
              for each foo1 in a_list
              	dta = "ulink + eval(foo1)"
              	vid = word(foo1,1,"|")
              	vemailto = word(foo1,2,"|")
              	lst2 = lst2 + \
              webUsers.record_content_get("\"a|" + vid + "\"+'|'+ulink+'|'+ ""\""+ vemailto + "\"" ,"","agencyid="+quote(word(foo1,1,"|")))
              	lst2 = lst2 + crlf()
              next
              webUsers.close()
              lst = lst + lst2
              Obviously it doesn't matter if there are only a dozen entries in the table, but if you're repetitively processing hundreds or thousands of records, it is a noticeable speed improvement. Also, depending on timing issues, doing table.external_record_content_get() thousands of times on a table can lead A5 to choke up on occasion -- probably some instances are not fully closed before the next iteration of the loop.

              Comment


              • #8
                Re: using var in table.external_record_content_get

                Originally posted by Steve Wood View Post
                Yes, expressions are loads of fun! I think sometimes I go off on the deep end and create complex expressions with code indirection to see how far I can go.
                Believe me, you have no idea how complicated it can get in the search for ultimate speed of an equation - nested *for_each(), eval()'s etc. :)

                Originally posted by Steve Wood View Post
                Then I have no idea what the code means later.
                Tons of comment lines showing result expression and explaining what you are doing. These are for yourself (or clients). Very often, I will show step-by-step calculations in comments, then actually use a combined expression for actual execution. To test, I can uncomment the strp-by-step version and see what is happening.

                Your first loop equation, has a couple of issues I'll bring up. You keep jumping between using single quotes, "escaped" double-quotes and the quote() function. I tend to stick with one method, rather than changing back and forth a lot. Also, be aware that in some cases you may run into, the single quote will not work within some passed expressions. This is not a bug, but a consequence of passing expressions as text strings.

                So,
                "agencyid="+quote(word(foo1,1,"|"))
                could have been written (I've added spaces around single quotes so you could see them for display here though) as either
                "agencyid=\""+word(foo1,1,"|")+"\""
                "agencyid=' "+word(foo1,1,"|")+" ' "
                "agencyid=word(\""+foo1+"\",1,\"|\")"
                The last one evaluates WORD() at filter time, rather than earlier at filter specification time. Not very useful for this case, but there are similar things that would be useful if instead of WORD(), it was a UDF function that changed results over the processing period

                The other problem is
                foo1="abc|def"
                dta = "ulink + eval(foo1)"
                vid = word(foo1,1,"|")
                vemailto = word(foo1,2,"|")
                ' This is what I think you want for the filter expr "a|abc|"+ulink+"|def"
                ' Below returns the string,
                ' (but the interactive window shows it incorrectly as it shows
                ' the contents of the string but it is one whole string despite how it appears
                ?"\"a|" + vid + "|\"+ulink+\"|"+ vemailto + "\""
                = "a|abc|"+ulink+"|def"
                ' Just to show you the difference with the interactive editor
                ?"abc"
                = "abc"
                ?"\"abc\"+def"
                = "abc"+def
                ?len("\"abc\"+def")
                = 9
                ' Same as
                ?"'abc'+def"
                = "'abc'+def"
                ?len("'abc'+def")
                = 9


                Originally posted by Steve Wood View Post
                Here is one that I've been glaring at for awhile:

                basefilter1 = eval("word(foo,1,\"|\")+\"->\"+word(foo,4,\"|\")+\"=\"+quote(eval(\"tbl.\"+word(foo,4,\"|\")))")
                There are a variety of variants that could be done, depending if foo is a constant prior to executing the filter. If foo="abc|123|456|def". do you want the filter expression to be "abc->def=tbl.def" ? In any case, the above is overly complex for this situation. It could just be
                foo="abc|123|456|def"
                ?word(foo,1,"|")+"->"+word(foo,4,"|")+"=tbl."+word(foo,4,"|")
                = "abc->def=tbl.def"
                But what I think you want is a filter expression like
                abc->def= string_constant
                which would be more like
                word(foo,1,"|")+"->"+word(foo,4,"|")+"=\""+eval("tbl."+word(foo,4,"|"))+"\""
                Last edited by csda1; 03-14-2010, 12:37 PM.
                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


                • #9
                  Re: using var in table.external_record_content_get

                  Thanks again. Usually when things start to look complex, it means it is no longer effecient. The whole reason I am using nexted FOR loops is my frustration with Sets. I wanted to get a nice clean simple output of every "ID" field in the entire tree/heirarchy (simplified example), either starting at the top most table, or somewhere in the middle. Someting like this, where the first col is the level, the second is the ID field:

                  1|A100
                  1|A101
                  2|A201
                  2|A300
                  3|A112
                  4|A554
                  Steve Wood
                  Join the ALPHA DEVELOPERS NETWORK
                  There is no Cloud. It's just someone else's computer.
                  Web - Mobile - Hosting - Products - Frameworks - Developer Resources
                  AlphaToGo | IADN (100% Alpha Anywhere Websites)

                  Comment

                  Working...
                  X