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, in interactive window

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

    xbasic, in interactive window

    Watching the third video in the Xbasic-101 series. Working in the AlphaSports db. This is the code they show.
    Dim F as P
    F=form.load("invoice")
    F.fetch.last()
    F.show()
    sleep(2)
    F.close()

    Things that have happened while playing with this. Using only the following lines of code,

    F=form.load("invoice")
    F.fetch.last()

    The fetch.last automatically shows the form after fetching the last record, no show command needed.
    Is this correct functionality, or is it bad programing. To me this code is saying F=form.load("invoice"),
    therefore F.fetch.last() is the same as form.load("invoice").fetch.last This line gives the same results,
    it fetches the last record before showing the form.


    If you do this:

    F=form.load("invoice")
    F.fetch.last()
    F.show() 'this command is not really needed, works the same with or without
    sleep(2)
    sleep(2)

    all the sleep commands seem to be executed befort the form is shown, remove the sleep commands and the form is displayed with last record showing. I put the sleep commands after the F.show() to demonstrate they are executed first and they are cumulative. Why are they executing before the F.show()

    This also works: shows form after going to last record.

    form.load("invoice")
    invoice.fetch_last()

    Is this bad form, not going the pointer route?
    On a simple command, is the pointer necessary? We all know the KISS rule.

    Please give some feedback and your thinking on this. Am I learning bad programing?

    Thank you,
    John

    #2
    Re: xbasic, in interactive window

    Yep, you're right. ~ BUG me thinks. (get used to them)

    Also, in messing with this I noticed that after hiding the window via the IW (after setting it to a form session and initially opening the form from a script) even stranger things continued to happen...

    The IW looses the form's entire existence after using f.hide(). On one trial, I attempted to set the IW Session back to the form, and it wasn't even there there. (Instead there were 2 instances of the same IW to chose from. (I think this secondary anomaly may be a "key" to the underlying issue!)

    Update: If you use:

    Code:
    f = form.view("invoice")     'and now you hide the form.....
    f.hide()
    f.fetch_last()     'it remains hidden after the initial "flash"
    Send in a bug report, and try this.... (use "STEP" in debugger to step through the code)

    Code:
    debug(1)
    dim f as p = form.load("invoice")     'Here I declared the pointer variable (preferred).
    'f = form.load("invoice")     'but your way works too.
    f.fetch_last()
    msgbox("another bug")
    sleep(2)
    ui_beep()
    sleep(2)
    ui_beep()
    debug(0)
    end
    PS: There might be a parameter for the <frm>.load() method that deals with this...... I haven't checked.
    Last edited by SNusa; 03-21-2013, 04:31 PM.
    Robert T. ~ "I enjoy manipulating data... just not my data."
    It's all about the "framework." (I suppose an "a5-induced" hard drive crash is now in order?)
    RELOADED: My current posting activity here merely represents a "Momentary Lapse Of Reason."

    Comment


      #3
      Re: xbasic, in interactive window

      I put the sleep commands after the F.show() to demonstrate they are executed first and they are cumulative. Why are they executing before the F.show()
      I think the sleep command runs asynchronously. I rarely have used it. It might work okay in an xbasic script where you don't interact with any forms and such, but I don't remember.
      Peter
      AlphaBase Solutions, LLC

      [email protected]
      https://www.alphabasesolutions.com


      Comment


        #4
        Re: xbasic, in interactive window

        Originally posted by Peter.Greulich View Post
        I think the sleep command runs asynchronously. I rarely have used it. It might work okay in an xbasic script where you don't interact with any forms and such, but I don't remember.
        Hey Peter: The problem wasn't sleep as per say, it was the fact that a hidden form opened via vp_Form.load("FormA") "mystically appears" when the a form.fetch_first() method is applied. It should remain hidden until form.show() method is applied.

        One of the examples used in the training material (w/ Steve Workings & Jay Talbott, v.10) was to pre-load forms in advance (and keep them hidden) to make an application appear "lightening fast." Apparently, you can't do that anymore? In my testing, I did somehow also end up with the "form pointers" becoming lost/"detached" by Alpha. (Alpha couldn't "see" the hidden form when setting the IW session.) ~ Instead, setting the session of the IW resulted in 2 instances of the IW appearing in the selection box. (One of those selections should have been the hidden form.)

        Note: If you load the form via form.view() and then hide it, it does remain hidden. (But it flashes this way, before disappearing.)

        (I don't think you're even supposed to be able to get 2 instances of the IW open at the same time. It's the first I've ever seen this happen, and I haven't been able to reproduce it. Although the problem of the hidden form appearing happens ever time.)
        Code:
        dim f as p = form.load("invoice")
        f.fetch_last()     'form should remain hidden, yet it appears when this method is invoked.
        The only thing I can think of, is possibly the forms primary index needs to be set before calling the fetch method?
        Nope: That didn't help.... The form.Index_set() method also causes the form to appear..... Guess you can't load forms & keep them hidden!
        (Well, you can, but you can't reference them via "code" until you're ready for them to "appear!")

        ~These are the kind of things that I perpetually ran into while learning the basics...... Eventually, you just kind of get a feel for what is going to break, what causes it, and how to "survive."
        Last edited by SNusa; 03-21-2013, 08:08 PM.
        Robert T. ~ "I enjoy manipulating data... just not my data."
        It's all about the "framework." (I suppose an "a5-induced" hard drive crash is now in order?)
        RELOADED: My current posting activity here merely represents a "Momentary Lapse Of Reason."

        Comment


          #5
          Re: xbasic, in interactive window

          Portal 6 uncovered (yet) another seemingly related bug.....

          If you have an open form and hide it via code from within the form: <form>.hide() (For kicks/testing, I placed the code on the form fetch event.)

          Not only is the form hidden from view, but it's also hidden from the IW. (You can't find the forms session when you attempt to set the IW session.)
          Incidentally, this form does still exist in the XB explorer tree.

          ~And although it's not listed in the IW session selection window, you can issue FORM.close() to close the form which clears the node from the XB explorer tree!

          Take a peek at the attachment after running a script that loads a hidden window and notice the discrepancies......
          (After taking this screen capture, If I enter the command :Frm_E.show(), the "MIA" form appears.)

          Snap 2013-03-21 at 23.14.33.png

          It sure looks like Alpha (the IW anyways) lost the pointer to this form!
          You can access from the IW by hard coding the object, but not by pointer since you can't set the session.
          (It's the result of hiding a form.

          Bug: ~ Any code referencing a hidden form that was loaded by form.load() causes the form to loose it's hidden state!
          Issue: ~ Hidden forms are hidden from the IW session selection window.
          Last edited by SNusa; 03-21-2013, 11:34 PM.
          Robert T. ~ "I enjoy manipulating data... just not my data."
          It's all about the "framework." (I suppose an "a5-induced" hard drive crash is now in order?)
          RELOADED: My current posting activity here merely represents a "Momentary Lapse Of Reason."

          Comment


            #6
            Re: xbasic, in interactive window

            Never understood making F a pointer in this example.
            Dim F as P
            F=form.load("invoice")
            F.fetch.last()

            Could F be dimmed as C and still hold "form.load('invoice')"
            I thought pointers were for object with properties, Yes or NO?
            Isn't, form.load a method. It would appear that a pointer var can hold or point to just about any string value, so where does it differentiate from a Character var? Is a pointer var something that is universal and not of any particular type?

            Comment


              #7
              Re: xbasic, in interactive window

              Could F be dimmed as C and still hold "form.load('invoice')"
              No.

              I thought pointers were for object with properties, Yes or NO?
              Yes but not only for them, and an object is not character type.

              Isn't, form.load a method.
              Yes.

              It would appear that a pointer var can hold or point to just about any string value
              Can hold, no, point to just string, no.

              Is a pointer var something that is universal and not of any particular type?
              No. A pointer variable is pointer type.


              A pointer variable can point to any data type.

              Dim f as P
              f.name = "joe"
              f.age = 7
              f.birthdate = {01/01/2001}
              f.deceased = .F.
              There can be only one.

              Comment


                #8
                Re: xbasic, in interactive window

                Originally posted by Portal 6 View Post
                Never understood making F a pointer in this example.
                Dim F as P
                F=form.load("invoice")
                F.fetch.last()

                Could F be dimmed as C and still hold "form.load('invoice')"
                I thought pointers were for object with properties, Yes or NO?
                Isn't, form.load a method. It would appear that a pointer var can hold or point to just about any string value, so where does it differentiate from a Character var? Is a pointer var something that is universal and not of any particular type?
                A pointer variable "points to an object", which enables you to manipulate/use the object. ~ In contrast, a character variable "holds/represents a value."

                On some objects you can change property attributes (directly), instead of using a "method"

                For example:
                <object>.enabled = .NOT. <object>.enabled (where object might be a field) ~ here you're changing the enabled property to it's opposite state.
                (without using a method to do it, you're setting the property directly.)

                By comparison, to hide this same field object, you can't set the hidden property directly. Instead you have to use a method of the object to do it for you...
                <object>.hide()

                PS: If there are parenthesis, it's usually a function/method........

                Think of a pointer as a name attached to a Post Office box# (or vice-versa).
                The pointer is just another way to reference the object.

                A pointer "points to an object" whereas a character variable "is the container" which "holds the variables value."

                You can create a pointer which points to all the session variable on a form. (and then manipulate these session variable via the pointer)
                In this case, the pointer points to the variables
                Last edited by SNusa; 03-30-2013, 06:07 PM.
                Robert T. ~ "I enjoy manipulating data... just not my data."
                It's all about the "framework." (I suppose an "a5-induced" hard drive crash is now in order?)
                RELOADED: My current posting activity here merely represents a "Momentary Lapse Of Reason."

                Comment


                  #9
                  Re: xbasic, in interactive window

                  One other way to "look" at the difference between pointers and character variables:

                  Calling a function.

                  If you call a function and sent parameters "ByRef" as opposed to "ByVal".....

                  ByVal (the default) sends the value of the variable into the function where any changes made to the variable (inside the function) will never be preserved or seen outside that function. The function uses/takes the value of the parameter and creates a second "instance" of that variable.
                  ByRef sends a pointer (pointing to the variable container, instead of the value itself) And and if you change any of the variables associated with a pointer, these value changes DO persist outside the function afterwards.

                  If however you create a pointer container pointing to variables, and you use the pointer as a parameter in a function..... The above does not apply. All pointers passed into functions are passed ByRef. (So any changes made to their values within the function do in fact persist outside the function. ~ Passing pointer variables ByVal does not work (as one might expect) for function parameters of type "pointer.")
                  Last edited by SNusa; 03-30-2013, 06:25 PM.
                  Robert T. ~ "I enjoy manipulating data... just not my data."
                  It's all about the "framework." (I suppose an "a5-induced" hard drive crash is now in order?)
                  RELOADED: My current posting activity here merely represents a "Momentary Lapse Of Reason."

                  Comment

                  Working...
                  X