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

Embedded xDialog - global vars not updated!

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

    Embedded xDialog - global vars not updated!

    Hi folks,

    Have a problem I don't get around:

    This is a multi tenant app where I set 4 global vars containing the tenant_ID, plus user name and user_role (can be admin or manager or user).

    I am starting this app via an xDialog, say, 'Tenant_Login' where the user selects a tenant, plus enters his/her user ID and password. When the login is OK, I set the above mentioned global vars (all DIM'med like DIM GLOBAL gvTenant_ID as C) to be used as base filters on subsequent forms, plus open a menu form containing an embedded xDialog which is a toolbox from which I start the various forms or scripts etc.. This is all working flawlessly.

    BUT:
    On this menu form's embedded xDialog-Toolbox, there is an item called 'change tenant' which starts the above mentioned xDialog 'Tenant_Login' again and thus enabling the user to select another tenant plus login credentials which - in turn - sets the global vars to new values, used to set form base-filters and the like.
    And the problem is:
    Whenever I launch this xDialog 'Tenant_Login' from within this embedded xDialog by selecting 'change tenant', the global vars do NOT get updated, but keep their former values! As many times as I start the login dialog by itself, all global vars get set just fine, but not when launched from within the embedded xDialog.

    From what I see through the debugger, my xDialog 'Tenant_Login' does set the global vars OK, but obviously not outside its's (or the embedded xDialog's?!) context.

    I am truly stumped!
    Thanks for each and every input on this!
    SwissCharles
    Between the Alps and a comfy place

    #2
    Re: Embedded xDialog - global vars not updated!

    I suggest you post a zipped copy of the app here with specific instructions for us to follow to see the behavior you're describing.

    Two ideas for you to consider in the meantime:

    a) Are you declaring the globals again when the xDialog is called from within the form? I think you should. Otherwise, Alpha may be populating variables with the same names but local scope, instead of global.

    b) Is it possible the globals are being changed just fine, but your form is not being refreshed? How do you know the globals are not being changed?

    Also, tell me more about an "Embedded Xdialog", I haven't worked with one of those before. Is this new, or have I overlooked something?

    -- tom

    Comment


      #3
      Re: Embedded xDialog - global vars not updated!

      Originally posted by Tom Cone Jr View Post
      Also, tell me more about an "Embedded Xdialog", I haven't worked with one of those before. Is this new, or have I overlooked something?
      the latter...
      Al Buchholz
      Bookwood Systems, LTD
      Weekly QReportBuilder Webinars Thursday 1 pm CST

      Occam's Razor - KISS
      Normalize till it hurts - De-normalize till it works.
      Advice offered and questions asked in the spirit of learning how to fish is better than someone giving you a fish.
      When we triage a problem it is much easier to read sample systems than to read a mind.
      "Make it as simple as possible, but not simpler."
      Albert Einstein

      http://www.iadn.com/images/media/iadn_member.png

      Comment


        #4
        Re: Embedded xDialog - global vars not updated!

        Hi Tom,
        Thanks for chiming in!


        Originally posted by Tom Cone Jr View Post
        I suggest you post a zipped copy of the app here with specific instructions for us to follow to see the behavior you're describing.
        Ok, will do that - see below...

        Two ideas for you to consider in the meantime:

        a) Are you declaring the globals again when the xDialog is called from within the form? I think you should. Otherwise, Alpha may be populating variables with the same names but local scope, instead of global.
        Well, I additionally declared them in Code Editor\View\Global Vars which has no effect on the problem.
        I also declared them in autoexec, to no avail.
        Following advice I found on this excellent forum (honor where honor is due ;-) I did declare them in the first script which is setting them (AC_LoginDlg).
        I also declared them in the embedded xDialog (MainMenue_xD) even though this dialog is not in any way doing something with them. All of this had no effect what so ever.


        b) Is it possible the globals are being changed just fine, but your form is not being refreshed? How do you know the globals are not being changed?

        Firstly, on the form in question, there is a calculated field concatenating user name, user role and name of tenant. Additionally to that, when going to the interactive window \ xBasic explorer \ Variables, you will see, that all global vars are all still showing the 'old' values.

        Also, tell me more about an "Embedded Xdialog", I haven't worked with one of those before. Is this new, or have I overlooked something?

        See: http://alphafivewiki.com/New+SuperControls+V9

        -- tom
        See the attached copy of the database.

        Since the user interface is written in german, I will - along with the instructions on how to reproduce the problem - provide a crash course in german along the lines ;-)

        Upon launching the app, after the autoexec script, the script 'AC_LoginDlg' is processed.
        This script displays an xDialog where users set the tenant (Mandant) into which they want to login, plus user name and password.
        Select tenant '00001' 'Mustermandant' from the dropdown list. Use user name 'cus' and password 'vgz7ujm' .
        This will log you in as an administrator.

        After this, the menu form AC_Start is launched.
        At the top right, you will see that the global vars are set by showing user name (aktueller Benutzer), user's role (in Gruppe:) and the tenant's Name (in Mandant).
        On the left of this form is the embedded xDialog whose script you will find in the code section as 'MainMenue_xD'. This script defines a toolbox in explorer style.
        On this toolbox-menu you will find an entry called 'change tenant' (Mandant wechseln) it's the second entry from below in section Anwendung.
        Selecting this entry, the script AC_LoginDlg is launched again. This time use tenant ID '00002' 'Filiale am Hauptsitz' plus user id 'bv' with password 'vgzhn'. And that's where the problem manifests itself: After filling out the dialog again, you will see, that the global vars have not changed at all, they still show the values from the former login!

        But when you close form AC_Start and launch 'AC_LoginDlg' directly from the control panel, all is well and the global vars will be set for the new user.

        What I have tried so far:
        - DIMming the global vars in autoexec script
        - DIMming the global vars in MainMenue_xD script
        - DIMming the global vars in code editor \ global vars (kept that)

        So, what have I overlooked?

        Any input most appreciated!
        Attached Files
        SwissCharles
        Between the Alps and a comfy place

        Comment


          #5
          Re: Embedded xDialog - global vars not updated!

          Charles,

          I took a look and am finding the same results. I believe the issue has something to do with the context(behind the scenes memory location which I know little about) in which the embedded dialog is running. I think this should be reported as a bug which either needs fixing or explaining.

          I was able to make a work around by turning your AC_LoginDlg script into a function ie AC_LoginDlg()
          Code:
          Function AC_LoginDlg as V()
               'copy the whole script here
          End Function
          But then there is another issue with the code run within an embedded xdialog. It seems we can't call a UDF directly from this code. I have found a work around to this by creating a function local to the embedded xdialog code which runs the actual function I want. Below is the end of your MainMenue_xD script with the extra function.

          Code:
          If a_dlg_button = "Mandant wechseln" then 
          	a_dlg_button = "" 
          	parentform.Close()
          	'script_play_local("AC_LoginDlg")
          	[COLOR="#FF0000"]do_AC_LoginDlg()[/COLOR]
          	'parentform.Refresh()
          end if
          
          If a_dlg_button = "Anwendung schliessen" then 
          	a_dlg_button = "" 
          	'Exit Alpha Five.
          	:a5.close()
          end if
          %code%)
          
          [COLOR="#FF0000"]Function do_AC_LoginDlg as V()
          	AC_LoginDlg()
          end function[/COLOR]
          Hmmm, while writing this post I had an idea. Instead of calling the new AC_Login_Dlg function I just called your original script from that extra local function in the xdialog code, as below. That also seems to work ok. But I would go with AC_Login_Dlg function any way just to be sure.

          Code:
          Function do_AC_LoginDlg as V()
          	script_play_local("AC_LoginDlg")
          end function
          I guess the same thing that keeps code from an embedded xdialog running a UDF is causing your problem as well.
          Tim Kiebert
          Eagle Creek Citrus
          A complex system that does not work is invariably found to have evolved from a simpler system that worked just fine.

          Comment


            #6
            Re: Embedded xDialog - global vars not updated!

            Hi Charles (and Tim),

            I suspect what's happening is that the embedded dialog is being run as an evaluate_template_private() which runs in it's own private variable spaces, or possibly with a WITH/END WITH which is overriding the global space somehow (though I don't think this is possible to override the global space using WITH/END WITH). It probably is a bug, although there could be a reason it needs to be done this way.

            If you assign and reference embedded Xdialog global variables variables like this;

            Code:
            'Set a Global Variable containing the Mandant
            global_variables().gvMandant_ID = vmanfound
            
            'Set a Global Variable containing the Employees full name
            global_variables().gvUsrName = vfullnamefound
            
            'Set a Global Variable containing the Employees ID Number
            global_variables().gvUsr_ID = vuserfound
            
            'Set a Global Variable containing the current User's Gruppe
            global_variables().gvUsrGruppe = vusrgrpfound
            or by assigning a temp local pointer like

            Code:
            dim gv as p
            gv=global_variables()
            
            'Set a Global Variable containing the Mandant
            gv.gvMandant_ID = vmanfound
            
            'Set a Global Variable containing the Employees full name
            gv.gvUsrName = vfullnamefound
            
            'Set a Global Variable containing the Employees ID Number
            gv.gvUsr_ID = vuserfound
            
            'Set a Global Variable containing the current User's Gruppe
            gv.gvUsrGruppe = vusrgrpfound
            then you should find it working, and it should always work. If you find the same issue for shared variables, use session_variables() to get the shared pointer for that if needed in a similar way.

            If a UDF function doesn't work directly as Tim showed, you could also reference it globally as in
            Code:
            global_variables().functionname()
            or with a pointer
            Code:
            gv.functionname()
            Also suggest reading my Tips on variables dimensioning
            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


              #7
              Re: Embedded xDialog - global vars not updated!

              Hello Ira,

              Thanks for jumping in!!!

              It completely slipped my mind to use that syntax for the global variables. Also that syntax for calling a UDF feels like it was in my memory banks at some time but it was either long gone or very deeply buried. I tried it in Charles' app and also in my app where I had the issue and it does the trick.

              I could not get global_variables().varname to set the value. In the script or the interactive window. I could use that syntax to read the value.

              However using ...
              Code:
              dim gv as p
              gv=global_variables()
              
              'Set a Global Variable containing the Mandant
              gv.gvMandant_ID = vmanfound
              did work

              So Charles, you have a couple of options now.
              Leave the script_play command and change the setting of the globals as above or
              turn the login code into a function and change the script play into a function call ie global_variables().AC_LoginDlg()
              Tim Kiebert
              Eagle Creek Citrus
              A complex system that does not work is invariably found to have evolved from a simpler system that worked just fine.

              Comment


                #8
                Re: Embedded xDialog - global vars not updated!

                Originally posted by Tim Kiebert View Post
                I could not get global_variables().varname to set the value. In the script or the interactive window. I could use that syntax to read the value.
                That format worked for me in V11, didn't try others.

                However, you can't use a function that returns a pointer in a DIM (REDIM, and probably other Alpha Five language directives), as in
                Code:
                DIM global_variables().myvar as c
                This does work with directives.
                Code:
                Dim gv as p
                gv=global_variables()
                DIM gv.myvar as c
                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


                  #9
                  Re: Embedded xDialog - global vars not updated!

                  Isn't this a lot of hard work when I suspect the Security settings - which will easily track the User - can do it and allow filters etc on the forms?
                  What have I missed here?
                  See our Hybrid Option here;
                  https://hybridapps.example-software.com/


                  Apologies to anyone I haven't managed to upset yet.
                  You are held in a queue and I will get to you soon.

                  Comment


                    #10
                    Re: Embedded xDialog - global vars not updated!

                    I'm puzzled. If the global variables are declared "outside" the xdialog script itself, why can't the xd script collect inputs in locals and then simply assign them to the globals when the user clicks the OK button? I must still be missing something. Can anyone enlighten me? ( My wife knows that's more than a rhetorical question, so be gentle, please! ) -- tom

                    Comment


                      #11
                      Re: Embedded xDialog - global vars not updated!

                      @ Ira,

                      Many thanks for your input!
                      As soon as I am at the dev machine, I will try this solution first:
                      Code:
                      'Set a Global Variable containing the Mandant
                      global_variables().gvMandant_ID = vmanfound
                      
                      'Set a Global Variable containing the Employees full name
                      global_variables().gvUsrName = vfullnamefound
                      
                      'Set a Global Variable containing the Employees ID Number
                      global_variables().gvUsr_ID = vuserfound
                      
                      'Set a Global Variable containing the current User's Gruppe
                      global_variables().gvUsrGruppe = vusrgrpfound
                      Will give a feedback when done.

                      @Ted:
                      What you probably missed is my intention to keep data of multiple tenants in the same database.
                      Each tenant can have different users and admins but these may only login to their specific tenant. Login credentials are per tenant. If one user needs access to two or more tenants, he/she needs an account per tenant.
                      SwissCharles
                      Between the Alps and a comfy place

                      Comment


                        #12
                        Re: Embedded xDialog - global vars not updated!

                        @ Ira and Tim:

                        This syntax did the trick:

                        dim gv as p
                        gv=global_variables()

                        'Set a Global Variable containing the Mandant
                        gv.gvMandant_ID = vmanfound
                        ....
                        This one - as Tim already noted - did not work here either (using latest build v11):

                        'Set a Global Variable containing the Mandant
                        global_variables().gvMandant_ID = vmanfound
                        ....
                        I am a happy camper again

                        Thanks for helping me with this problem - much appreciated!
                        Last edited by SwissCharles; 11-22-2011, 04:53 AM.
                        SwissCharles
                        Between the Alps and a comfy place

                        Comment


                          #13
                          Re: Embedded xDialog - global vars not updated!

                          Originally posted by SwissCharles View Post
                          @Ted:
                          What you probably missed is my intention to keep data of multiple tenants in the same database.
                          Each tenant can have different users and admins but these may only login to their specific tenant. Login credentials are per tenant. If one user needs access to two or more tenants, he/she needs an account per tenant.
                          Oh no! I really didn't miss your intention.
                          Still, if you have solved the problem in a way that works for you, you will indeed be a happy camper - until your variables get corrupted that is.
                          See our Hybrid Option here;
                          https://hybridapps.example-software.com/


                          Apologies to anyone I haven't managed to upset yet.
                          You are held in a queue and I will get to you soon.

                          Comment


                            #14
                            Re: Embedded xDialog - global vars not updated!

                            Originally posted by Ted Giles View Post
                            Isn't this a lot of hard work when I suspect the Security settings - which will easily track the User - can do it and allow filters etc on the forms?
                            What have I missed here?
                            Originally posted by SwissCharles View Post
                            @Ted:
                            What you probably missed is my intention to keep data of multiple tenants in the same database.
                            Each tenant can have different users and admins but these may only login to their specific tenant. Login credentials are per tenant. If one user needs access to two or more tenants, he/she needs an account per tenant.
                            Originally posted by Ted Giles View Post
                            Oh no! I really didn't miss your intention.
                            Still, if you have solved the problem in a way that works for you, you will indeed be a happy camper - until your variables get corrupted that is.
                            @ Ted:
                            I'm not sure, if I did understand your input then.
                            Say, I do set the global var gvTenant_ID (in my script gvMandant_ID) as a base filter on various tables/forms. A user for, say, tenant 00002 shall only see the sales for this tenant.
                            The same user may have another account for, say, tenant 00001 (user name and pwd could be different!) To see sales for tenant 00001 he/she must log out of tenant 00002 and login with the former tenant.
                            How would you do this with the security system of the desktop version?

                            Thanks for your thoughts!
                            SwissCharles
                            Between the Alps and a comfy place

                            Comment


                              #15
                              Re: Embedded xDialog - global vars not updated!

                              Well Charles, I may have spoken too soon.
                              The Security works fine and User ID's only pick up the Tennants they are supposed to - well most of the time - however the Conditional Actions are causing me some grief.
                              I'll keep at it, however I will need to dig out some older apps to see if I can remember how I did it in an older version.
                              It has become a personal challenge now!
                              See our Hybrid Option here;
                              https://hybridapps.example-software.com/


                              Apologies to anyone I haven't managed to upset yet.
                              You are held in a queue and I will get to you soon.

                              Comment

                              Working...
                              X