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

It worked in A4V7

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

    It worked in A4V7

    Have a lotto application...
    Need to update records in one table from the input to a second table...
    Cannot find any way to do this on a field by field basis, so I figure that I have to do it with the OnSave event????
    Much rather do it as each field is entered, cuz then it's only one small script activated as the field is entered; as opposed to a longer script that must read each field individually and then act.... maybe in a loop ????
    BUT just spent the better part of an hour going thru the XBasic Reference and I cannot find what I 'think' I am looking for...
    Here's the scenario....
    Winning number data: date is entered and then 6 fields.
    Need to take each field value (ie 18), access a second table, add one (1) to a running count number for that field value AND then repeat for each of the remaining 5 fields... It was rather easy using the 'Read' command in A4.....
    here's my 'cobolized' xbasic.....?????

    assuming all the 'dim' statements are valid....

    dim fld[6] as N

    tbl1=table.open("db-name")
    tbl2=table.open("db1-name")

    tbl1.fetch_last()

    for i = 1 to 6
    var1=fld[i].value_get()
    tbl2.fetch(var1)
    count = count + 1
    next i

    var1 in this case is both the number value and the record number...
    tbl2 is already established with all counts initialized to zero.

    then close both tables

    #2
    RE: It worked in A4V7

    As usual, while working on something else, I ran across some data and NOW I have:

    dim fld[6] as N
    dim n_var as N
    tbl1=table.open("db_name")
    tbl2=table.open("db1_name")
    tbl1.fetch_last()
    for i = 1 to 6
    n_var = fld[i].value_get()
    tbl2.fetch_goto(n_var)
    count = count + 1 where count is the fieldname
    next i
    tbl1.close()
    tbl2.close()
    This compiled OK so now I will go and try it..
    D

    Comment


      #3
      RE: It worked in A4V7

      Well, that did not work....
      Must be a problem with the update clause...
      Probably because I don't have the correct syntax to access the 'count' field in the second file....
      BTTDB

      D

      Comment


        #4
        RE: It worked in A4V7

        Richard,

        Alpha Four you have to place the table in change or enter mode before you can edit a record's field values or before you can enter field values for a new record. Remember?

        The same is true in Alpha Five.

        If you want to create a new record in the second table you use

        "tbl".enter_begin()

        If you have found the record you want to edit (in table 2) you use

        "tbl".change_begin()



        In each case these simply initiate the change or enter. You then write to the fields.
        You then save the change or enter using other commands.

        Check the Xbasic Reference Manual for examples.

        -- tom

        Comment


          #5
          RE: It worked in A4V7

          OK -- I surrender..
          I have been thru (twice +) every occurrence of the words 'save' and 'put' in the XBasic Reference Manual.
          Nowhere can I find any mention of saving the record changes. If I am missing something, any clue would help..
          D

          Comment


            #6
            RE: It worked in A4V7

            Latest version that still does not work. I get 'argument is wrong type' error -- even after the 'fetch_last' command......????

            'Date Created: 14-May-2004 12:22:01 AM
            'Last Updated: 14-May-2004 08:51:22 PM
            'Created By :
            'Updated By :


            dim fld[6] as N
            dim n_var as N
            dim adder as N

            tbl1=table.open("lotto_south_winners")
            tbl2=table.open("lotto_south_numbers")

            tbl1.fetch_last()

            for i = 1 to 6
            n_var = fld[i].value_get()
            tbl2.index_get(number)
            tbl2.fetch_find(n_var)
            tbl2.change_begin()
            adder = tbl2.Frequency.value_get()
            adder = adder + 1
            tbl2.Frequency.value_put(adder)
            tbl2.change_end()
            ? n_var;? adder
            next i
            tbl1.close()
            tbl2.close()

            Comment


              #7
              RE: It worked in A4V7

              Here's another try. This time I get : ERROR field types don't match...
              In tbl1, date, fields 1 thru 6 are date and numeric.
              In tbl2, number is N, frequency is N, last_date is D
              I'm at a complete loss
              D

              'Date Created: 14-May-2004 12:22:01 AM
              'Last Updated: 14-May-2004 09:29:13 PM
              'Created By :
              'Updated By :


              dim fld[6] as N
              dim n_var as N
              dim n_adder as N
              dim d_ldt as D

              tbl1=table.open("j:\program files\a5v5\development\lotto pgms\lotto_south_winners")
              tbl2=table.open("j:\program files\a5v5\development\lotto pgms\lotto_south_numbers")

              tbl1.fetch_last()

              for i = 1 to 6
              n_var = fld[i].value_get()
              tbl2.index_get(number)
              tbl2.fetch_find(n_var)
              n_adder = tbl2.Frequency.value_get()
              n_adder = n_adder + 1
              d_ldt = tbl2.Last_date.value_get()
              tbl2.change_begin()
              tbl2.Frequency.value_put(n_adder)
              tbl2.Last_date.value_put(d_ldt)
              tbl2.change_end()
              '? n_var;? n_adder;? d_ldt
              next i
              tbl1.close()
              tbl2.close()

              Comment


                #8
                RE: It worked in A4V7

                richard,

                I'm sorry you had trouble.

                I use the Alpha Five Help file (the CHM version) available from the Learning Center, and forget sometimes that others may not.

                "tbl".enter_begin() is a method of the table object. You'll find it in the chapter of the Xbasic Ref. Manual on tables.

                ditto "tbl".change_begin()

                If you were using the CHM help documentation you just click the index tab, enter either term as i presented it and you get to the right page instantly.

                Comment


                  #9
                  RE: It worked in A4V7

                  Richard,

                  I don't have your tables or field names.

                  The following assumes your second table (the one you're trying to update in your script) has a separate record for each possible "integer" that the lottomachine might generate.

                  In pseudo code this is how I'd approach your script:

                  1) establish a pointer to the current data entry table using "tbl" = table.current()
                  2) verify that data entry is finished i.e. that table is not still in change or enter mode.
                  3) if not in VIEW mode promptuser to cancel or commit thepending changes
                  4) end script if user opts to quit, otherwise
                  5) open the second table and establish a pointer to it using "tbl2" = table.open()
                  6) set the index to that table using "tbl2".index_primary_put() (not primary_get() as you have done)
                  7) fetch the first record in tbl2
                  8) fetch the first integer value record using "tbl2".fetch_find() and a search key from your first number field in "tbl"
                  9) place the second table in change mode, using "tbl2".change_begin()
                  10) assign the new running count value to the running count field for the current integer using "tbl2".your_fieldname = var-"your_new_count value
                  11) commit the change to disk using "tbl2".change_end(.t.)
                  12) fetch the second integer value record using "tbl2".fetch_find() and a search key from your second number field in "tbl"
                  13) repeat steps 9 through 11
                  14) fetch the third integer value record using "tbl2".fetch_find() and a search key from your third number field in "tbl"
                  15) repeat steps 9 through 11

                  and so on

                  nn) close the second table with "tbl2".close()

                  -- tom

                  Comment


                    #10
                    RE: It worked in A4V7

                    I got a bit hung up on the PDF books and forgot about the CHM help file..
                    Thanx for the reminder.
                    D

                    Comment


                      #11
                      RE: It worked in A4V7

                      Richard,

                      I think there is a problem with your philosophy on this. You are worried about putting a "big" script at the end of entry to enter all six values at once, so you want a script on each field as you exit.

                      This can lead to big problems. First, what happens if you are half way through entry and then decide you don't want to enter that record? How do you go back and "unenter" the values you have already entered? Second, what if you exit a field and then discover that you made a mistake (maybe you wouldn't, but I do all the time)?

                      In terms of the time it takes, entering these six values will happen so fast, you won't notice.

                      Put code something like this on a "post" button on your entry form:

                      dim fromtable as P
                      dim totable as P

                      fromtable=table.current()
                      totable=table.open("your-table-name")
                      fromtable.commit() 'saves the values
                      totable.enter_begin()
                      totable.your-field1-name=fromtable.your-field1-name
                      totable.your-field2-name=fromtable.your-field2-name
                      .
                      .
                      totable.your-field6-name=fromtable.your-field6-name
                      totable.enter_end()
                      totable.close()
                      end

                      You may also want to think about a way to tell that you've entered this record so you don't post it twice.

                      Pat
                      Pat Bremkamp
                      MindKicks Consulting

                      Comment


                        #12
                        RE: It worked in A4V7

                        Well -- in a way you're correct...
                        First tho, I am trying to put the 'script' in the "OnSave" event for the form....
                        To me that means that all the fields have been 'entered' and are correct (might need a ui-box here)and the record is being 'saved'.....
                        But what I found (while trying to formulate) was that there are complications caused by deleting, or changing any field in, the record.
                        So now I am beginning to think 'buttons' to accomplish the various tasks and attaching the "correct" script to each button. This would basically mean a manual 'posting' operation for the data.... so the data could be corrected both plus and minus...
                        Right now, I don't see Field Rule Posting as a viable option, but this might change ??????
                        Meanwhile BTTDB and thanx to everyone for the help...
                        D

                        Comment


                          #13
                          RE: It worked in A4V7

                          Quick question ---

                          If the last record entered is 'sorted' and becomes the first record displayed (ie sort by date last -"first); then which record do I 'fetch' to get the latest date????

                          I would think that it would be the first record...

                          D

                          Comment

                          Working...
                          X