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

evaluate template question

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

    evaluate template question

    I am trying to use evaluate_template to represent the name of
    the field in a table during a typical data entry

    i know the following codes not running, can someone suggest
    an equivalent to what i am trying to do,

    the actual table has 50 field, depending on what data being submitted,
    typcally only few fields per record get filled...
    so i evaluate datax and datay

    such variable will represnet my field name/

    i like to automatically on the fly post data to corresponding field.

    i hope i am explaining myself well

    dim datax as c
    dim datay as c

    datax = "name_field"
    datay = "city"

    DIM tbl AS P
    tbl=TABLE.OPEN("test_data.dbf",FILE_RW_SHARED)
    tbl.ENTER_BEGIN()

    tbl.evaluate_template(datax) = "walmart"
    tbl.evaluate_template(datay) = "chicago"
    tbl.enter_end(.t.)
    tbl.close()

    #2
    Re: evaluate template question

    Ken,

    Checkout the help on the difference between eval() and evaluate_template(). (If you havn't already.)

    Eval() returns a value after evaluating the expression where as Evaluate_template() executes a command that is represented within/by the expression.

    According to the help on table functions you can use tbl.eval() but not tbl.evaluate_template().

    "All very interesting but how then do I do what I want?", I can hear you saying.

    I can't test at the moment but I think this correct.
    Code:
     dim datax as c
     dim datay as c
     
     datax = "name_field"
     datay = "city"
     
     DIM tbl AS P
     tbl=TABLE.OPEN("test_data.dbf",FILE_RW_SHARED)
     tbl.ENTER_BEGIN()
     
    evaluate_template("tbl." +datax+ " = 'walmart'"
    evaluate_template("tbl." +datay+ " = 'chicago'"
    
    tbl.enter_end(.t.)
     tbl.close()
    The result of
    Code:
    evaluate_template("tbl." +datax+ " = 'walmart'"
    is
    Code:
    tbl.name_field = "walmart"
    which then gets executed.
    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


      #3
      Re: evaluate template question

      If you just wanted to extract the value from the table field you could use tbl.eval().

      Code:
      dim value as C
       dim datax as c
       dim datay as c
       
       datax = "name_field"
       datay = "city"
       
       DIM tbl AS P
       tbl=TABLE.OPEN("test_data.dbf",FILE_RW_SHARED)
       
      value = tbl.eval(datax) 
      
      tbl.close()
      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


        #4
        Re: evaluate template question

        Originally posted by Tim Kiebert View Post
        Ken,

        Checkout the help on the difference between eval() and evaluate_template(). (If you havn't already.)

        Eval() returns a value after evaluating the expression where as Evaluate_template() executes a command that is represented within/by the expression.

        According to the help on table functions you can use tbl.eval() but not tbl.evaluate_template().

        "All very interesting but how then do I do what I want?", I can hear you saying.

        I can't test at the moment but I think this correct.
        Code:
         dim datax as c
         dim datay as c
         
         datax = "name_field"
         datay = "city"
         
         DIM tbl AS P
         tbl=TABLE.OPEN("test_data.dbf",FILE_RW_SHARED)
         tbl.ENTER_BEGIN()
         
        evaluate_template("tbl." +datax+ " = 'walmart'"
        evaluate_template("tbl." +datay+ " = 'chicago'"
        
        tbl.enter_end(.t.)
         tbl.close()
        The result of
        Code:
        evaluate_template("tbl." +datax+ " = 'walmart'"
        is
        Code:
        tbl.name_field = "walmart"
        which then gets executed.
        I think you're missing some closing parentheses.......

        Code:
        evaluate_template("tbl." +datax+ " = 'walmart'"[COLOR="Red"])[/COLOR]
        evaluate_template("tbl." +datay+ " = 'chicago'"[COLOR="red"])[/COLOR]
        If it was me, I'd blame it on my eyesight.

        I don't think tbl.evaluate_template() would make sense. Tbl.eval() is just a shortcut (?), as in

        tbl.eval("firstname+lastname")

        instead of

        tbl.firstname+tbl.lastname

        which when you look at it is not really shorter.
        There can be only one.

        Comment


          #5
          Re: evaluate template question

          I am not sure, will test it out, in the similar idea with sql statement:

          is it possible to use eval or evaluate_template to change the field(that i wish to insert) of an sql table

          dim connString as C

          dim conn as ole::adodb.connection
          connString = "DRIVER={MySQL ODBC 3.51 Driver};SERVER=localhost;DATABASE=logistic;UID=root;PWD=alpha5v7"
          conn.open(connString)

          dim yvr1 as c
          dim yvr2 as c
          dim yvr3 as c
          dim dvr1 as c
          dim dvr2 as c
          dim dvr3 as c

          yvr1 = "name" ' this i expect this field name to change depending of what data come in
          yvr2 = "address" ' this one also changing
          yvr3 = "city" ' this one also,

          this sql table has 100 field(names), example, name, address, city, id, and more....

          depending of what xml data coming in, i need to poulate to some of the fields on this big table with little data, quite empty look example above, the name,address & city required insert

          while later on, it might be, something else like id, location,distance
          all typical 3 fields at a time on my example, real life can be upto 20 plus fields
          that is why the need to use variables just makes it easier/

          dvr1 = remspecial(time())
          dvr2 = "11111 west avenue"
          dvr3 = "new york"

          rs = conn.Execute("INSERT INTO customer (name, address, city) VALUES ('"+dvr1+"','"+dvr2+"','"+dvr3+"')")


          where i can subsitute the rs statement:

          rs = conn.Execute("INSERT INTO customer (variable?, variable?, variable?) VALUES ('"+dvr1+"','"+dvr2+"','"+dvr3+"')")

          can i use eval ?

          truly i am not familiar, just managed to get moving one step at a time/
          i can do this well with alpha native table, but the need to go sql is mandatory

          appriciate your assistances

          ken tjia

          Comment


            #6
            Re: evaluate template question

            Stan,
            Thanks for the correction. Thats what I get for sneaking of to have a read of the forum instead of working.;)

            Originally posted by Stan Mathews View Post
            I think you're missing some closing parentheses.......
            Yep, oops.
            If it was me, I'd blame it on my eyesight.
            Well if they were there and I didn't see them I could. However since they weren't there and I thought they were I'm not sure what to blame it on..... please be kind.


            I don't think tbl.evaluate_template() would make sense.
            Me either.
            Tbl.eval() is just a shortcut (?), as in

            tbl.eval("firstname+lastname")

            instead of

            tbl.firstname+tbl.lastname

            which when you look at it is not really shorter.

            Agreed as far as that example goes.
            But in my second post above

            value = tbl.eval(a_variable)
            would allow you to dynamically change the field name referenced in the table pointer. Such as preceed that code with a dialog that asks "Get value for what field" and present the user with a list of fields with the choice going into a_variable.

            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


              #7
              Re: evaluate template question

              Originally posted by [email protected] View Post
              I am not sure, will test it out, in the similar idea with sql statement:

              is it possible to use eval or evaluate_template to change the field(that i wish to insert) of an sql table

              dim connString as C

              dim conn as ole::adodb.connection
              connString = "DRIVER={MySQL ODBC 3.51 Driver};SERVER=localhost;DATABASE=logistic;UID=root;PWD=alpha5v7"
              conn.open(connString)

              dim yvr1 as c
              dim yvr2 as c
              dim yvr3 as c
              dim dvr1 as c
              dim dvr2 as c
              dim dvr3 as c

              yvr1 = "name" ' this i expect this field name to change depending of what data come in
              yvr2 = "address" ' this one also changing
              yvr3 = "city" ' this one also,

              this sql table has 100 field(names), example, name, address, city, id, and more....

              depending of what xml data coming in, i need to poulate to some of the fields on this big table with little data, quite empty look example above, the name,address & city required insert

              while later on, it might be, something else like id, location,distance
              all typical 3 fields at a time on my example, real life can be upto 20 plus fields
              that is why the need to use variables just makes it easier/

              dvr1 = remspecial(time())
              dvr2 = "11111 west avenue"
              dvr3 = "new york"

              rs = conn.Execute("INSERT INTO customer (name, address, city) VALUES ('"+dvr1+"','"+dvr2+"','"+dvr3+"')")


              where i can subsitute the rs statement:

              rs = conn.Execute("INSERT INTO customer (variable?, variable?, variable?) VALUES ('"+dvr1+"','"+dvr2+"','"+dvr3+"')")

              can i use eval ?

              truly i am not familiar, just managed to get moving one step at a time/
              i can do this well with alpha native table, but the need to go sql is mandatory

              appriciate your assistances

              ken tjia
              Since I have already embarrassed myself once in this thread I might as well try again. I have nil to very little experience building sql statements but it seems that you just need to construct a string that goes into the rs = conn.Execute() function. And I would say you are over half way there.

              I would suggest
              Code:
               rs = conn.Execute("INSERT INTO customer (" +yvr1+ "," +yvr2+ "," +yvr3+") VALUES ('"+dvr1+"','"+dvr2+"','"+dvr3+"')")
              I tried this in the interactive window and seems to reflect what you need
              Code:
              yvr1 = "name" ' this i expect this field name to change depending of what data come in
              yvr2 = "address" ' this one also changing
              yvr3 = "city" ' this one also,
              
              dvr1 = remspecial(time())
              dvr2 = "11111 west avenue"
              dvr3 = "new york"
              
              
              sql_string = "INSERT INTO customer (" +yvr1+ ", " +yvr2+ ", " +yvr3+") VALUES ('"+dvr1+"','"+dvr2+"','"+dvr3+"')"
              
              ?sql_string
              = "INSERT INTO customer (name, address, city) VALUES ('175341','11111 west avenue','new york')"
              As you can see the data/values that is being passed in to the sql statement is enclosed in single quotes. Am not sure if that is ok. If not then you may need escaped double quotes
              Code:
              sql_string = "INSERT INTO customer (" +yvr1+ ", " +yvr2+ ", " +yvr3+") VALUES (\""+dvr1+"\",\""+dvr2+"\",\""+dvr3+"\")"
              ?sql_string
              = INSERT INTO customer (name, address, city) VALUES ("175341","11111 west avenue","new york")
              I think you could then follow that with
              Code:
              rs = conn.Execute(sql_string)
              Caution:I don't know if 'sql_string' is or isn't a reserved sql word/command.

              Stan: With all those quotes, escapes, and parentheses I hope you are proof reading this for me. ;)
              Last edited by Tim Kiebert; 03-02-2007, 03:34 AM.
              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

              Working...
              X