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

XBASIC Conversion to Version 11's XBASIC, Action Scripting, Et Cetera

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

    XBASIC Conversion to Version 11's XBASIC, Action Scripting, Et Cetera

    I'm progressing well on my journey to upgrade a large V1 application to V11, largely because of the friendly assistance I've received here on the forums. "Alphaholics" are a great breed.

    I'd like to impose on your time to help me in two areas:

    1. Conversion of Reports and Labels - I've converted enough forms to realize the strong compatibility between the old and new versions of A5. I'd appreciate any comments regarding these objects. Is the syntax close enough that it's intuitive how to code V11 Reports? If not, what should I be reading?

    2. Conversion of V1 Scripts. I'm attaching one of my more difficult scripts (it would be nice if you thought it was a piece of cake). I would appreciate your guidance as to how to proceed once you've seen the script.

    If there are higher level tools in V11 than I had available in V1 which may enable replacing a fair amount of XBASIC, that would be wonderful. If so, please tell me where to look (I find that an overview of the technical tools is a bit hard to come by). If not, does the A5V11 documentation have any information aimed at converting XBASIC syntax, especially use of "cards" to the equivalent A11 syntax.

    That's about it. I look forward to any comments.

    The attached script is from an invoicing application. It asks the user to specify a time period for selection of sales information so that it can summarize totals of # of purchases and $ value of those purchases. That information is stored in the Customer table for subsequent querying. My son uses this information to decide who to mail his catalog to.

    Here it is (hopefully). Thanks again ... Sam

    a5v1script.txt

    #2
    Re: XBASIC Conversion to Version 11's XBASIC, Action Scripting, Et Cetera

    I think I caught most things that needed translation.

    modern translation.txt

    I would suggest you do the same with the summarize operation that you did with the update and post. Then the date variables can be easily incorporated into the script.
    Last edited by Stan Mathews; 08-29-2012, 03:49 PM.
    There can be only one.

    Comment


      #3
      Re: XBASIC Conversion to Version 11's XBASIC, Action Scripting, Et Cetera

      Wow, Stan, thanks so much for the time you spent in reviewing my XBASIC code! After all these years it's astounding how similar XBASIC 11's syntax is to what I had learned back in V1. That's very good news for me.

      You made the comment that you would "suggest" I do the same thing with the summarize function that I did with the update and post.

      Does that mean that there's an alternative way to do it, such as an Action Script?

      Is action scripting the new A5 answer to the old A5's "cards". If it is not, then can you position action scripting for me as an alernative to raw XBASIC? It sure was a relative no-brainer to fill out the cards than having to learn the XBASIC syntax.

      Stan, thanks so much for giving your time to explain the differences in terms of modifying my old script. That was so kind of you and so much more effective than talking about it.

      Best regards ... Sam

      Comment


        #4
        Re: XBASIC Conversion to Version 11's XBASIC, Action Scripting, Et Cetera

        Does that mean that there's an alternative way to do it, such as an Action Script?
        The alternative I envisioned was that your update and post "operations" (post v2 (at least) term) are "coded" in that you have replaced the card references with the script equivalents. Why not the summarize?

        Is action scripting the new A5 answer to the old A5's "cards".
        Don't know, no experience with cards. From your comments, cards seem to be synonomous with operations. Yes, it is easier to design operations and fill out the required settings but they are only frontends for the xbasic behind them.

        Try designing a summarize operation and then convert it to xbasic. You can then see the feasibility of tweaking that xbasic to accept variables as parameters, accept dynamically derived table names, etc.
        There can be only one.

        Comment


          #5
          Re: XBASIC Conversion to Version 11's XBASIC, Action Scripting, Et Cetera

          Does that mean that there's an alternative way to do it, such as an Action Script?
          The alternative I envisioned was that your update and post "operations" (post v2 (at least) term) are "coded" in that you have replaced the card references with the script equivalents. Why not the summarize?

          Is action scripting the new A5 answer to the old A5's "cards".
          Don't know, no experience with cards. From your comments, cards seem to be synonomous with operations. Yes, it is easier to design operations and fill out the required settings but the are only frontends for the xbasic behind them.

          Try designing a summarize operation and then convert it to xbasic. You can then see the feasibility of tweaking that xbasic to accept variables as parameters, accept dynamically derived table names, etc.

          Eval() is especially useful.

          str = "4"
          eval("update.field"+str) = "QCNT2"

          assigns "QCNT2" to the variable update.field4

          for str = 1 to 4
          eval("update.field"+alltrim(str(str)) = "QCNT"+alltrim(str(str))
          next str

          creates the assignments

          update.field1 = "QCNT1"
          update.field2 = "QCNT2"
          update.field3 = "QCNT3"
          update.field4 = "QCNT4"

          just as if you had hard coded them.
          There can be only one.

          Comment


            #6
            Re: XBASIC Conversion to Version 11's XBASIC, Action Scripting, Et Cetera

            The eval example is clever. Careful, Stan, you don't want me to feel too inadequate do you?

            You asked why I didn't do the summarize, like I did the update and post. The truth is I did them all as cards long ago. When I started running the application on WINXP the post and updates ran very very poorly for some reason, measured in minutes. When I converted the post and update they ran in only a few seconds. Never got around to summarize because it ran OK.

            Comment


              #7
              Re: XBASIC Conversion to Version 11's XBASIC, Action Scripting, Et Cetera

              Here's an example using evaluate_template().

              Code:
              [COLOR="#0000FF"]'get a list of open stores with awgcode not blank and iga flag true[/COLOR]
              iga = table.external_record_content_get("store","alltrim(sn)","storenumber","status = 'open' .and. alltrim(awgcode)>\"\" .and. iga")
              [COLOR="#0000FF"]'take those store "numbers" and put "St" in front of each[/COLOR]
              hrepl = *for_each(foo,"St"+padl(foo,3,"0"),iga)
              [COLOR="#0000FF"]'count how many were found[/COLOR]
              strs = w_count(hrepl,crlf())
              
              [COLOR="#0000FF"]'start building a post operation[/COLOR]
              a_tbl = table.open("mkt_pur",FILE_RW_EXCLUSIVE)
              post.t_db = "P:\executive\hdb\Cost.DBF"
              post.m_key = "val(remspecial(Upc))"
              post.t_key = "val(F01)"
              post.m_filter = ""
              post.t_filter = ""
              post.m_count = strs [COLOR="#0000FF"]'use count derived above[/COLOR]
              [COLOR="#0000FF"]'loop through the list of stores[/COLOR]
              FOR i = 1 TO strs
              ufld = "post.m_field"+alltrim(str(i))
              uexp = quote(word(hrepl,i,crlf()))
              ustore = right(word(hrepl,i,crlf()),3)
              [COLOR="#0000FF"]'next code line generates post lines like[/COLOR]
              [COLOR="#0000FF"]' post.m_field38 = "St046"[/COLOR]
              evaluate_template(ufld+" = "+uexp)
              uexpv = "post.m_exp"+alltrim(str(i))
              [COLOR="#0000FF"]'next code line generates a post line like[/COLOR]
              [COLOR="#0000FF"]'post.m_exp1 = "if(@Cost->F1000 =\"046\",@COST->F38/@Cost->F19,St046)"[/COLOR]
              evaluate_template(uexpv +" = "+ quote("if(@Cost->F1000="+quote(ustore)+",@Cost->F38/@Cost->F19,"+unquote2("St"+ustore)+")"))
              post.t_count = 0
              NEXT i
              a_tbl.post()
              a_tbl.close()
              The benefit to me is that when a new store is opened (or closed) I merely add (or delete) that store number to the store table and add (or delete) a field for it in the mkt_pur table. The code changes for the posting script are "self healing".
              There can be only one.

              Comment


                #8
                Re: XBASIC Conversion to Version 11's XBASIC, Action Scripting, Et Cetera

                Stan, you're making my brain sore. Is it OK if I come back to this after I've converted all my scripts? I'll have a much better chance of understanding it. Why do I have a feeling you really know your Alpha Five?

                Comment


                  #9
                  Re: XBASIC Conversion to Version 11's XBASIC, Action Scripting, Et Cetera

                  You missed a "minor but significant" issue, Stan. The old a_app_current_path (or something like that) included a backslash on the end and a5.get_path() doesn't.

                  So.....
                  _DB_NAME = a5.get_path() + "INV_HEAD.DBF"

                  needs to be....
                  _DB_NAME = a5.get_path() + "\INV_HEAD.DBF"

                  Comment


                    #10
                    Re: XBASIC Conversion to Version 11's XBASIC, Action Scripting, Et Cetera

                    So right you are. Thanks for the assist.
                    There can be only one.

                    Comment


                      #11
                      Re: XBASIC Conversion to Version 11's XBASIC, Action Scripting, Et Cetera

                      Originally posted by CALocklin View Post
                      You missed a "minor but significant" issue, Stan. The old a_app_current_path (or something like that) included a backslash on the end and a5.get_path() doesn't.

                      So.....
                      _DB_NAME = a5.get_path() + "INV_HEAD.DBF"

                      needs to be....
                      _DB_NAME = a5.get_path() + "\INV_HEAD.DBF"
                      Cal, this is so trivial but it looks like you're showing the opposite of what you're saying. The "needs to be" example has the "\".

                      Probably I'm wrong.

                      Comment


                        #12
                        Re: XBASIC Conversion to Version 11's XBASIC, Action Scripting, Et Cetera

                        Because you will need the backslash. a5.get_path() yields the current database path, without the backslash.
                        There can be only one.

                        Comment


                          #13
                          Re: XBASIC Conversion to Version 11's XBASIC, Action Scripting, Et Cetera

                          I must be stupid or have lost the ability to communicate.

                          If the new syntax yields the path WITHOUT the backslash, why is Cal inserting it?
                          _DB_NAME = a5.get_path() + "\INV_HEAD.DBF"

                          Comment


                            #14
                            Re: XBASIC Conversion to Version 11's XBASIC, Action Scripting, Et Cetera

                            I've never been able to specify a path to a file (table) without the full path. The full path includes a backslash between the lowest directory level and the filename.

                            A_APP_CURRENT_PATH included the backslash in its result.
                            A5.get_path() does not.

                            examples (sample)
                            A_APP_CURRENT_PATH+ "INV_HEAD.DBF" -> "C:\mydatabase\INV_HEAD.DBF"
                            A5.get_path()+"INV_HEAD.DBF" -> "C:\mydatabaseINV_HEAD.DBF"
                            A5.get_path()+"\INV_HEAD.DBF" -> "C:\mydatabase\INV_HEAD.DBF"
                            There can be only one.

                            Comment


                              #15
                              Re: XBASIC Conversion to Version 11's XBASIC, Action Scripting, Et Cetera

                              Thanks for the explanation Stan. I understand it now. I had read Cal's posting incorrectly.

                              Comment

                              Working...
                              X