Alpha DevCon 2018
Results 1 to 5 of 5

Thread: xBasic code executing and ignoring a missing form definition

  1. #1
    Member
    Real Name
    Mark Gallagher
    Join Date
    Feb 2017
    Location
    Sarasota, Florida
    Posts
    37

    Default xBasic code executing and ignoring a missing form definition

    Background

    I'm doing some maintenance on a form that has a number of labels and fields defined
    2 of which I thought were not being used.

    I removed the suite field from the form because it was hidden and I removed the
    text2 label, which was displaying recno on the form, because I figued who ever
    developed this was using it for debug purposes and forgot to remove it.

    After I saved the form and started testing I got an error right away that
    parent:suite is missing. I looked at the xBasic code associated with the button
    and found these lines of code.

    parent:suite.text = "OPERA MUSIC RECORDS" (this was the hidden field)

    text2.text = str(recno()) (this was displaying recno)

    I put the suite field, which is a field defined in the database table, back into the
    form and the error went away. What's interesting is that I did not put the
    text2.text label, which is not defined in the database, back into the form and I
    do not get an error. It's like it is being ignored.

    Question

    Can someone tell me why the text2.text label does not cause an error even
    though I removed it from the form and the code referencing it is still executing?

  2. #2
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default Re: xBasic code executing and ignoring a missing form definition

    That is interesting. I believe the reason that no error is thrown after the removal of the text2 object is that text2.text is a valid (dot)variable name. In the absence of the object the Alpha assumes the script is creating and setting a variable's value.

    You can see this in the interactive with

    text2.text = "123" 'implicit dim and explicit value assignment

    ? text2.text
    = "123"

    On the form you could change the script, for testing, to

    text2.text = str(recno())
    msgbox(text2.text)

    The construction parent:suite.text tells Alpha to look at the form that is the parent of the button, find the suite object, access its text property.
    Last edited by Stan Mathews; 04-27-2017 at 02:35 PM.
    There can be only one.

  3. #3
    Member
    Real Name
    Mark Gallagher
    Join Date
    Feb 2017
    Location
    Sarasota, Florida
    Posts
    37

    Default Re: xBasic code executing and ignoring a missing form definition

    Thanks Stan for a great explanation!

    I was able to test this in the interactive as you described using a variable defined with and without a dot.

    In your response you wrote ...

    " ... text2.text is a valid (dot)variable name."

    Can you elaborate on what an Alpha "(dot)variable name" is?

    Mark

  4. #4
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default Re: xBasic code executing and ignoring a missing form definition

    I could but the documentation is pretty comprehensive.

    https://www.alphasoftware.com/docume...0Variables.xml
    There can be only one.

  5. #5
    Member
    Real Name
    Mark Gallagher
    Join Date
    Feb 2017
    Location
    Sarasota, Florida
    Posts
    37

    Default Re: xBasic code executing and ignoring a missing form definition

    OK, got it!

    Thanks for the link Stan.

    Mark

Similar Threads

  1. Executing SQL Code
    By sprivitera in forum Application Server Version 11 - Web/Browser Applications
    Replies: 3
    Last Post: 04-16-2013, 07:52 PM
  2. Dialog and executing code
    By swest in forum Application Server Version 11 - Web/Browser Applications
    Replies: 0
    Last Post: 02-07-2012, 08:42 AM
  3. Put objects on a Form by Xbasic code.
    By Marcel Kollenaar in forum Alpha Five Version 7
    Replies: 4
    Last Post: 04-15-2006, 07:23 PM
  4. form xbasic code
    By dik_coleman in forum Alpha Five Version 5
    Replies: 3
    Last Post: 05-10-2004, 12:07 PM
  5. Seeing Xbasic code for a form
    By kumargroup in forum Alpha Five Version 5
    Replies: 2
    Last Post: 11-21-2003, 06:57 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •