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

entering a record with a variable

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

    entering a record with a variable

    the structure of both tables is the same
    I need to copy the records from one to the other
    any ideas

    t1=table.open(dirname + "\\logintests" + chr(92) + "logintests.dbf")
    t2=table.open("logintests")
    fcount=t2.fields_get()
    t2.fetch_first()
    while .not. t2.fetch_eof()
    t1.enter_begin()
    for i=1 to fcount
    fld=t1.field_get(i)
    fname=fld.name_get()
    eval_valid("t1." + var->fname="t2." + var->fname)
    next
    t1.enter_end()
    t2.fetch_next()
    end while
    t1.close()
    t2.close()​​
    Cole Custom Programming - Terrell, Texas
    972 524 8714
    [email protected]

    ____________________
    "A young man who is not liberal has no heart, but an old man who is not conservative has no mind." GB Shaw

    #2
    Martin,
    In several scripts I am using the EVAL() function, for example:
    eval("drc." + var->kind2) = var->kid2

    So in your example I would suggest the following:
    eval("t1." + var->fname) ="t2." + var->fname
    To make it less complicated, you could merge the "t2." in the fname variable and skip that in the eval statement

    Regards,

    Jo
    Jo Hulsen
    Dommel Valley Solutions
    The Netherlands

    Comment


      #3
      here is a copy that is working

      dim global lnum as c
      dim global dirname as c
      lnum=parentform:labnum.value
      t1=table.open(dirname + "\\logintests" + chr(92) + "logintests.dbf")
      t1.zap(.t.)
      t1.close()
      msgbox("","")
      t1=table.open(dirname + "\\logintests" + chr(92) + "logintests.dbf")
      t2=table.open("logintests")
      QClear()
      query.filter="labnum=var->lnum"
      idx=t2.query_create()
      if idx.records_get() > 0
      else
      t1.close()
      t2.close()
      end
      end if
      fcount=t2.fields_get()
      t2.fetch_first()
      while .not. t2.fetch_eof()
      t1.enter_begin()
      for i=1 to fcount
      fld=t1.field_get(i) '=t2.fld_get(i)
      fname=fld.name_get()
      eval("t1." + var->fname)=eval("t2." + var->fname)
      next
      t1.enter_end()
      t2.fetch_next()
      end while
      t1.close()
      t2.close()
      t1=table.open(dirname + "\\logintests" + chr(92) + "logintests.dbf")
      msgbox("","" + t1.records_get())
      t1.fetch_first()
      while .not. t1.fetch_eof()
      msgbox("","" + t1.description)
      t1.fetch_next()
      end while
      t1.close()

      end​
      Cole Custom Programming - Terrell, Texas
      972 524 8714
      [email protected]

      ____________________
      "A young man who is not liberal has no heart, but an old man who is not conservative has no mind." GB Shaw

      Comment


        #4
        This could work too...

        cmd="t1." + var->fname+"=t2." + var->fname
        myevalid=eval_valid(cmd)
        if .not. myevalid then
        ' write cmd to a error file
        end if

        ​
        Al Buchholz
        Bookwood Systems, LTD
        Weekly QReportBuilder Webinars Thursday 1 pm CST

        Occam's Razor - KISS
        Normalize till it hurts - De-normalize till it works.
        Advice offered and questions asked in the spirit of learning how to fish is better than someone giving you a fish.
        When we triage a problem it is much easier to read sample systems than to read a mind.
        "Make it as simple as possible, but not simpler."
        Albert Einstein

        http://www.iadn.com/images/media/iadn_member.png

        Comment


          #5
          As usual, I am lost.
          Append not working?
          See our Hybrid Option here;
          https://hybridapps.example-software.com/


          Apologies to anyone I haven't managed to upset yet.
          You are held in a queue and I will get to you soon.

          Comment


            #6
            Originally posted by Ted Giles View Post
            As usual, I am lost.
            Append not working?
            A good idea if the table structure is stable. Gets crazy if the file structures don't match..

            Not sure if it is in this case.

            Another option is to build an append operation in code and then execute that.

            Martin

            I'd also suggest a batch_begin() and batch_end() around the while loop to improve speed of execution.
            Al Buchholz
            Bookwood Systems, LTD
            Weekly QReportBuilder Webinars Thursday 1 pm CST

            Occam's Razor - KISS
            Normalize till it hurts - De-normalize till it works.
            Advice offered and questions asked in the spirit of learning how to fish is better than someone giving you a fish.
            When we triage a problem it is much easier to read sample systems than to read a mind.
            "Make it as simple as possible, but not simpler."
            Albert Einstein

            http://www.iadn.com/images/media/iadn_member.png

            Comment


              #7
              probably take less time to learn mysql enough to do the heavy work in mysql, then bring the results into the dbf table.
              Gregg
              https://paiza.io is a great site to test and share sql code

              Comment


                #8
                Well, I looked at using an append, but one of the tables is in a different folder, which append does not like. Anyway, I am satisfied with what is working, and runs in maybe 1.5 seconds.
                Cole Custom Programming - Terrell, Texas
                972 524 8714
                [email protected]

                ____________________
                "A young man who is not liberal has no heart, but an old man who is not conservative has no mind." GB Shaw

                Comment


                  #9
                  For anyone watching this, an Append is possible IF the table to accept the appended data is temporarily added to the primary database.
                  Example;

                  Workspace 1 somewhere on your realestate
                  Data Table 1

                  Workspace 2 somewhere else on your realestate
                  Data Table 2

                  Add Data Table 2 to Workspace 1 temporarily.
                  Data Table 1
                  Data Table 2

                  Append. Either way.

                  Drop Data Table 2 ( or leave it there if you are planning many appends)

                  If using SQL, do not Drop the table as it may be deleted.

                  If using DBF, the table is still intact in Workspace 2 and will have the appended records.
                  See our Hybrid Option here;
                  https://hybridapps.example-software.com/


                  Apologies to anyone I haven't managed to upset yet.
                  You are held in a queue and I will get to you soon.

                  Comment


                    #10
                    Hi Martin,
                    I'm a little late on this but you stated here:
                    "the structure of both tables is the same. I need to copy the records from one to the other"

                    Gosh, if the table structures are the same, I use a script that has a data variable vdata as B and source table (ts) and target table (tt) open and loops through the source table with the functions -vdata=ts.record_data_set() and write to target table with tt.record_data_get(vdata).. Am I missing something here?

                    Mike W
                    __________________________
                    "I rebel in at least small things to express to the world that I have not completely surrendered"

                    Comment


                      #11
                      well, the two tables are identical, but one is in the main database folder, and the other is in a subfolder of a different folder than the main
                      Cole Custom Programming - Terrell, Texas
                      972 524 8714
                      [email protected]

                      ____________________
                      "A young man who is not liberal has no heart, but an old man who is not conservative has no mind." GB Shaw

                      Comment


                        #12
                        it is no problem if the two tables are not in the same workspace (i.e. database) as long as you reference the table that is NOT in the workspace with a fully qualified name (.e. c:\mydata\table1.dbf)

                        Comment


                          #13
                          thanks, Selwyn
                          Cole Custom Programming - Terrell, Texas
                          972 524 8714
                          [email protected]

                          ____________________
                          "A young man who is not liberal has no heart, but an old man who is not conservative has no mind." GB Shaw

                          Comment

                          Working...
                          X