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



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

Playing "tricks" with strings

  • Filter
  • Time
  • Show
Clear All
new posts

  • Playing "tricks" with strings

    I inherited some coding that used to work in an old version of Alpha. Can someone tell me if/how this is implemented today.

    A string variable contains values to be used in an expression. Let's call the string variable CONTAINER. There are two fields FLD1 and FLD2 which will eventually be used in an expression.


    At some point in the logic we have set CONTAINER = "FLD1<\"2\".AND.FLD2>\"6\""

    Our expression requires us to have FLD1 <"2" .AND. FLD2 >"6" as tests.

    How do we remove these field tests from the string variable that has them "trapped"? In Alpha 1 the following actually works: QCNT2>=VAR->VCNT2.OR.QVAL2>=VAR->VTOT2).AND." + CONTAINER + "

    Sometimes in version 11 this syntax works and sometimes it seems to throw invalid expression errors. Any thoughts about how to handle this?

    Thanks ... Sam
    Last edited by sgerber; 09-21-2012, 12:03 AM.

  • #2
    Re: Playing &quot;tricks&quot; with strings

    Sometimes in version 11 this syntax works and sometimes it seems to throw invalid expression errors.
    As I suggested to you earlier....

    Whether or not the value of a variable is available has everything to do with the scope of the variable. If you

    dim vcnt2 as N
    vcnt2 = 7

    and then reference the variable in another script, it will not have a value or be known.

    In many instances Alpha will try to resolve shared and global variables in a filter string but you should strive to avoid having to.

    Instead of

    "state = var->ste"

    you should use

    "state = "+quote(var->state)
    There can be only one.


    • #3
      Re: Playing &quot;tricks&quot; with strings

      Whether or not the value of a variable is available has everything to do with the scope of the variable. If you

      dim vcnt2 as N
      vcnt2 = 7
      Stan, I DIM all variables as GLOBAL so they'll pass between scripts and forms, reports, etc. Did you think I wasn't?

      In many instances Alpha will try to resolve shared and global variables in a filter string but you should strive to avoid having to.

      Instead of
      "state = var->ste"
      you should use
      "state = "+quote(var->state)
      Sorry but I don't understand this. I guess I'm a bit dense right now but I'm not getting the point.


      • #4
        Re: Playing &quot;tricks&quot; with strings

        A quoted string is literal text.

        "state = var->ste"
        this is essentially no different than
        "state = Maine"

        Built into Alpha is functionality that will attempt to substitute the value of a variable into a quoted string in place of the variable name. That functionality is not perfect and does not apply to local variables.

        You can be a hero and assist Alpha when you want that variable substitution leaving nothing to be interpreted.

        "state = "+quote(var->ste)
        This statement says take the quoted character string "state = " and concatenate the current value, quoted, of the variable ste.

        Try it in the interactive window where the auto substitution does not work.

        dim global ste as C
        ste = "Maine"

        ? "state = var->ste"
        = "state = var->ste"

        ? "state = "+quote(var->ste)
        = state = "Maine"
        There can be only one.


        • #5
          Re: Playing &quot;tricks&quot; with strings

          Stan, I'll bet you're tired of me by now. If you are then please just ignore this post.

          I just spent more than an hour in the "Interactive Window" All I really seem to have proved is that I can't use your technique which returns a string from the character variable. The string doesn't work inside a filter expression. I further proved that the old Alpha Five V1 syntax for the variable works fine in the interactive window, as it did in the Operations Genie. It just doesn't seem to work in Report or Label record filters. Here's part of my session in the interactive window:

          dim global vconmag as C
          vconmag = "CONLON<\"2\".AND.MAGIC<\"2\""
          ? "result="+quote(var->vconmag)
          = result="CONLON<\"2\".AND.MAGIC<\"2\""
          ? vconmag
          = CONLON<"2".AND.MAGIC<"2"
          I DIMmed my real life variable and set it to values exactly as my script does. The first thing you'll see is that your +quote returns unresolved characters \"2\" and the extra syntax of result=.

          The next thing you'll see is that simply entering the character variable returns its contents without quotes and with the escape characters resolved. That's exactly what I want because it will work in a filter expression.

          The next item is my real life filter expression without the troublesome vconmag variable and then you'll see my complete filter, including vconmag. You'll see that the 17 year old Alpha V1 syntax works like a charm in the filter.

          Why it's problematic in some layout record filters is beyond me. I also cannot seem to obtain approval from the Alphaholics that it's OK sometimes to use things that worked in Version 1, although clearly the Alphaholics make fun of me for sticking with some of the things I learned in 1996. I've even had one person suggest I forget everything I ever knew about V1 and start over. Stan, that's crap and if I had done that I'd be nowhere converting my application, despite your very good nature and all the assistance I've received from you here.

          I'll stop ranting and just leave you with the result of my session in the interactive window.

          Also, Stan I still cannot get Alpha to save my query, as a query, so that the Label and Reports can specify it as such. I'll eventually get a resolution for that but it's been a real time drain. Can't believe how bad the documentation sucks. Give me 2 or 3 books with the software and the assistance of the forums and they can keep their ill-conceived and partly DEPRECATED (their term) documentation.

          My best to you Stan. I'm not a happy camper today but I am mostly done with my conversion in just a month and a half, thanks in large measure to your forbearance.

          --- Sam


          • #6
            Re: Playing &quot;tricks&quot; with strings

            You'll see that the 17 year old Alpha V1 syntax works like a charm in the filter.
            Because that's the syntax, without the quote() that I suggested. (Stopping the string and concatenating the variable.) You can also see that the same syntax works without the trailing +""

            ..........).AND."+ VCONMAG +""
            same as
            ...........).AND."+ VCONMAG

            The quote() isn't needed in your instance because it shouldn't be quoted in the filter. I was demonstrating a case in which the variable to be substituted needed to be quoted.

            Try your expression again in the interactive an establish values beforehand for


            and see if it works the same way as VCONMAG.
            Last edited by Stan Mathews; 09-21-2012, 02:41 PM.
            There can be only one.


            • #7
              Re: Playing &quot;tricks&quot; with strings

              Thanks for responding, Stan. Thought you might have needed a break for a while.

              I just tried what you asked in the Interactive window and of course you were right. I wasn't looking at the syntax correctly and didn't realize that the extra +"" at the end wasn't necessary. In fact, Stan, that may be the reason my expression isn't working in some of the form or report filters. I appreciate your calling that to my attention.

              That query we've been discussing can't be done in a report or label filter so far as I can see because the "vconmag" variable is built on the fly after the xbasic script takes variables from the user. Also, that query is used to print mailing labels at a later point in time. My son, who owns the business that uses A5, will run the query multiple times with different parameters. He does this so he can select a certain number of customers for his mailing. When he reaches that number he will then print the mailing labels which is done by another script I'm writing.

              That's why it's important for me to save his last query. The script that prints the labels will need to use it.

              Do you have any thoughts, Stan, as to what a developer must do to save a query as a query list, not an index? Should I open a new thread for that topic instead.

              As always, Stan, thank you. --- Sam
              Last edited by sgerber; 09-21-2012, 06:34 PM.


              • #8
                Re: Playing &quot;tricks&quot; with strings

                Not necessary doesn't mean it should cause any issues. Just that sometimes it clouds the visualization of what is really happening.

                I can think of no reason why you shouldn't be able to save a query.

                Is the query based on a table or a set? When you are attempting to find/use the query is the layout based on the same table/set?

                Try to design and save a query in AlphaSports on the customer table and locate it for the record selection of the CustomerLabels label layout.
                There can be only one.