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

System Variables Not global? 2 line function

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

    System Variables Not global? 2 line function

    I put this line of code in the Button1:OnPush event:

    ui_msg_box(A_FORM_CURRENT, A_FORM_CURRENT)



    when this executes I get gibberish for the A_FORM_CURRENT value. Its a mix of number and letters... clues why?

    #2
    RE: System Variables Not global? 2 line function

    Wierd.

    With a bit of experimentation I found this combination that works just as expected:

    Code:
    curr_form = a_form_current
    curr_db = a_db_current
    ui_msg_box(curr_db,curr_form)
    -- tom

    Comment


      #3
      RE: System Variables Not global? 2 line function

      Thank you tom.

      The problem was the form and the table were named the same so A5 couldnt tell which was being referenced.

      Thankfully I copied and pasted your code and saw the problem so if you wouldnt have included the code you got to work. i would still be struggling with this.

      Thank you kind sir.

      Comment


        #4
        RE: System Variables Not global? 2 line function

        The above mentioned code by Tom does work and work properly.

        This code does not:
        curr_db = a_db_current
        trace.WriteLn(curr_db)

        ui_msg_box(curr_db,A_FORM_CURRENT)


        A_FORM_CURRENT still spits jibberish.


        Anyone one know what data type A_FORM_CURRENT is?
        The System Variables help page says it returns the NAME of the current for. So I am assuming its a Character.

        I still have no clue why a System Variable doesnt work in the button event. I again make an assumption that System Variables are of the Global Scope.

        So either I have the data type wrong, the scope wrong, I have a fudemental misunderstanding, or its a bug.


        Any help.

        Comment


          #5
          RE: System Variables Not global? 2 line function

          Define "gibberish"

          If you want the name of the current form, use topparent.name()
          Aaron Brown
          Alpha Software Development Team

          Comment


            #6
            RE: System Variables Not global? 2 line function

            gibberish = $$$06c2e728.TMP

            Comment


              #7
              RE: System Variables Not global? 2 line function

              That occurs because you are toggling back and forth between design and view mode. When the form is opened from the control panel or with form.view(), that shouldn't occur.

              What is it you are doing that requires you to know the name of the form?
              Aaron Brown
              Alpha Software Development Team

              Comment


                #8
                RE: System Variables Not global? 2 line function

                Wow. I am impressed you know that :).

                I am just making a function that you call and it moves the focus to the next tab on the tabbed object.

                FUNCTION NextTab AS V (tab_Object AS P )
                'Description: Function simply moves to the next tab in a tabbed object

                Dim page as N
                page = tab_Object.tab_get()
                tab_Object.tab_set(page + 1)

                END FUNCTION

                When i was originally writing that function I was trying to use the form name for an object reference. But I wanted it to work on any form so that is why I was trying to use the A_FROM_CURRENT variable.

                I figured the function out but not being able to use the A_FROM_CURRENT was boggling my mind.

                Comment


                  #9
                  RE: System Variables Not global? 2 line function

                  The approach you just posted is the correct way to go about this. You should never depend on the *name* of a form to write code, otherwise if the form gets renamed, your code breaks. Whenever possible, pass object pointers, as you did above.
                  Aaron Brown
                  Alpha Software Development Team

                  Comment


                    #10
                    RE: System Variables Not global? 2 line function

                    Exactly, that is why I was trying to use the system variable, A_FORM_CURRENT, and not the explicit name of the form.

                    How can you findout the number of tabs a tabbed object has?

                    I looked through the properties and methods and failed to find anything that returns the number of tabs. I would like to do this so I could write 1 function that handles tab navigation.

                    'This would check to see if the user is on the last tab
                    'if so then they would be navigated to the first tab
                    'just cycling them
                    Dim page as N
                    page = tab_object.get_tab()
                    if( page +1 " tab_object.number_of_tabs)
                    tab_object.set_tab(1)
                    Else
                    tab_object.set_tab( page +1)
                    End If


                    Is it possible to add such a property to the tabbed object myself?

                    Comment


                      #11
                      RE: System Variables Not global? 2 line function

                      What I'm trying to say is, there is no need to use the name of the form at all! You can you topparent.this to get a *pointer* to the form, rather than hard-coding the name. I'd have to see exactly what you are doing, but I doubt you need to use the name for anything.

                      Regardless, topparent.name() will return an appropriately normalized name of the form.

                      There is no built in method to determine the number of pages on the tab control, but this will work:

                      pTabControl.Tabs.Sheet.Size()
                      Aaron Brown
                      Alpha Software Development Team

                      Comment


                        #12
                        RE: System Variables Not global? 2 line function

                        At that time, I did not know how to get a pointer to an object. So I was trying to use :A_FORM_CURRENT:tabbed1 .

                        Now I know how to get pointers to objects, obj(), and I will use that from now on. Just like I did in the working function I posted.

                        Thanks for the topparent and tab size. That is useful.

                        As you can tell I am trying to learn Xbasic and it's standards. So I am just struggling through the basics and it can be frustrating at times trying to learn a new language.

                        Comment


                          #13
                          RE: System Variables Not global? 2 line function

                          You do not need obj() to get a pointer to the current form, all you need is

                          pForm = topparent.this


                          To get a pointer to the tabbed object,

                          pTab = topparent.Tabbed1.this
                          or
                          pTab = pForm.Tabbed1.this
                          Aaron Brown
                          Alpha Software Development Team

                          Comment


                            #14
                            RE: System Variables Not global? 2 line function

                            " At that time, I did not know how to get a pointer to an
                            " object. So I was trying to use :A_FORM_CURRENT:tabbed1 .

                            A_FORM_CURRENT wouldn't work like that anyhow for several reasons. First, it would be looking for a form NAMED "A_FORM_CURRENT". To use a variable (like A_form_current) to get a pointer to a form, you need to use eval() or obj().

                            On top of that, A_form_current returns the literal name of the form, including spaces and special characters. To get a pointer to a form by name, you need to use the normalized (variable friendly) name of the form, which is stored in topparent.name().

                            This would work

                            pForm = eval(topparent.name()+".this")
                            as would
                            pForm = obj(topparent.name())
                            or
                            pForm = obj(a_form_current)

                            but these would not work
                            pForm = :a_form_current.this
                            pForm = eval(a_form_current+".this")



                            a_form_current works with obj() only because obj() is specifically designed to deal with the friendly form name.
                            Aaron Brown
                            Alpha Software Development Team

                            Comment


                              #15
                              RE: System Variables Not global? 2 line function

                              Incidentally, that "gibberish" stored in a_form_current is actually correct, and is the current "name" of the form. While toggling back and forth between design and view modes, the name gets turned into a temporary name.
                              Aaron Brown
                              Alpha Software Development Team

                              Comment

                              Working...
                              X