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() and GOTO

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

    evaluate_template() and GOTO

    Good Morning,

    I am trying to direct the action to certain places in a script using variables and a consolidated GOTO command. Does anyone know why this does not work or have a suggested replacement? Thanks,
    Mike W

    Code:
    dim tolabel as C="GOTO TEST2"
    
    evaluate_template(tolabel)
    
    TEST1:
    UI_msg_box("test","here")
    
    TEST2:
    UI_msg_box("test","other")
    Mike W
    __________________________
    "I rebel in at least small things to express to the world that I have not completely surrendered"

    #2
    evaluate_template knows nothing about the code environment of the invoking code (where evaluate_template is executed). It does know about the variable space, and thus can use the local variables, and anything else dimensioned with in it.

    Some code like below where x carries the choice is one way to do it.

    IF x=1
    code test 1
    ELSE IF x=2
    code test 2
    ELSE
    default code to run (if any)
    END IF

    You could also set the desired code into a text string, then use evaluate_template() to run that
    Regards,

    Ira J. Perlow
    Computer Systems Design


    CSDA A5 Products
    New - Free CSDA DiagInfo - v1.39, 30 Apr 2013
    CSDA Barcode Functions

    CSDA Code Utility
    CSDA Screen Capture


    Comment


      #3
      Trying to code eficiently

      Ira,

      I'll have to be honest that I do not understand what you wrote. This is what the Documentation says about this function, and I used this function in the code below that reads 13 fields in a table and applies these values consecutively to 13 fields in a second table, where it inserts a concatenated character string into a command line to produce a dynamic command. There is an exampe here-
      http://msgboard.alphasoftware.com/al...896#post389896

      Are you saying that the GOTO is not an Xbasic command? This is not too big a deal, I have several work arounds, but I was just trying to code efficiently, and if I can make a commands line dynamic with variables, I'd like to instead of many IF THEN statements.

      Thanks
      Mike W

      Code indirection refers to the situation when you want to execute an Xbasic command that is contained in a variable (i.e. to indirectly execute an Xbasic command).

      The EVALUATE_TEMPLATE(Command_String) function is used to execute an Xbasic command that is contained in Command_String.
      Code:
      dim tbl as p
      dim global Litem as C
      dim vitem as C
      dim qput as C
      dim objitem as C
      
      tbl = table.open("items")
      query.filter = ""
      query.order = ""
      query.options = ""
      xi=tbl.query_create()
      
      tbl.fetch_first()
      while .not. tbl.fetch_eof()
          objitem=alltrim(tbl.itemnum)
          qitem = alltrim(tbl.item)
          Litem=alltrim(qitem)
          [COLOR="Red"]evaluate_template("Parentform:Item"+objitem+".value = "+quote(Litem))[/COLOR]
      tbl.fetch_next()
      end while
      xi.drop()
      tbl.close()
      Mike W
      __________________________
      "I rebel in at least small things to express to the world that I have not completely surrendered"

      Comment


        #4
        Mike,

        I think Ira was saying that evaluate_template() doesn't know anything about the script in which it's running. The function can see objects and variables that exist when it's called. You're assuming the labels embedded in your script are variables. They're not. They're labels. -- tom

        Comment


          #5
          Tom,

          You are correctly interpreting what I said. Any XBasic code can be part of the command string of evaluate_template() including GOTOs, but they have to GOTO labels that are also in the code of the Command string, not outside it.

          But GOTO's are really a bad method. A CASE or IF...ELSE IF is generally best.
          Regards,

          Ira J. Perlow
          Computer Systems Design


          CSDA A5 Products
          New - Free CSDA DiagInfo - v1.39, 30 Apr 2013
          CSDA Barcode Functions

          CSDA Code Utility
          CSDA Screen Capture


          Comment


            #6
            trying to cut corners

            Tom, Ira,

            Thank you very much. I believe I understand this now. Logic, and overlying paradigms of older Dos-type programming don't always mesh with what I read in documentation, try and extend from prior sucesses, and think Xbasic can (should) be able to do.

            I have grunted out some great finds in efficient programming with Xbasic (and y'alls help), and am always looking for an additional less-verbose, consolidating processes. Well, this wasn't one. So be it, If-then, Case, work wonderfully, I'll type out the code and keep going.

            The wisdom that you impart though this message board continuously amazes me. You are certainly both appreciated legacies...

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

            Comment


              #7
              Re: evaluate_template() and GOTO

              Ira, I am trying to use indirection in an IF statement.

              This works,

              if c_tbl.foundinbase <> 1 .and. a_tbl.DISTRICT_STUDENT_ID = c_tbl.STUDENT_ID .and. a_tbl.LAST_NAME = c_tbl.LAST_NAME
              ...
              end if
              This does not (always evaluates as True)
              mc = " c_tbl.foundinbase <> 1 .and. a_tbl.DISTRICT_STUDENT_ID = c_tbl.STUDENT_ID .and. a_tbl.LAST_NAME = c_tbl.LAST_NAME"
              if eval(mc)
              ...
              end if
              Steve Wood
              See my profile on IADN

              Comment


                #8
                Re: evaluate_template() and GOTO

                Hi Steve,

                It depends on the context of the eval, not necessarily having access to session, layout and global variable pointers a_tbl and c_tbl. You could dim and assign a local pointer aptr=a_tbl and bptr=b_tbl and use those local pointers instead and it may work. You can also specify the pointer space in eval() as the context, but that might have issues if you require more than one pointer space.
                Regards,

                Ira J. Perlow
                Computer Systems Design


                CSDA A5 Products
                New - Free CSDA DiagInfo - v1.39, 30 Apr 2013
                CSDA Barcode Functions

                CSDA Code Utility
                CSDA Screen Capture


                Comment

                Working...
                X