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

Multiple form instances being created with log on/off routine

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

    Multiple form instances being created with log on/off routine

    I have a "log on/off" routine that can be run from a button on every form in my application. I am having an issue with the routine opening up multiple instances of my Main_Menu form if I repeat the logon process multiple times while I am on the Main_Menu form when launching the routine.

    The Log On/Off process .....
    1. Closes the current form with - parentform.close(.f.)
    2. Sets a couple of global variables
    3. Open the Main_Menu form with
    form.view(vCenterForm, "", "", "center", "center")
    Note: vCenterForm is set to Main_Menu in this case

    I wanted to make the process run the same no matter what form the user is on, so I always close the parent form first.

    The issue I have is that if I am on the Main_Menu form when I run the script it closes the Main_Menu and reopens it as Main_Menu0 (a zero is placed after Main_Menu). If I repeat the logon process while on the Main_Menu form it cycles the open form name between Main_Menu and Main_Menu0

    I know I am leaving out a lot of details although I believe my problem is geared around the way I am closing and opening the forms.

    Any ideas?

    Let me know what additional information would be needed or helpful.

    #2
    Re: Multiple form instances being created with log on/off routine

    May I ask what useful purpose is served by having the button on your Main_menu form ? If I were you I'd have a second script that is used only on your Main_menu form.

    Comment


      #3
      Re: Multiple form instances being created with log on/off routine

      The purpose of the Log on/Off option being on any form is because we use "Shared" workstations and will be allowing users to walk up to the machine and Log On from wherever they are in the application.

      Why would the process matter if I am closing the form before using the form.view command?

      Comment


        #4
        Re: Multiple form instances being created with log on/off routine

        Originally posted by Scott Kurimski View Post
        Why would the process matter if I am closing the form before using the form.view command?
        It probably doesn't matter.

        Try this:
        Code:
        IF is_object("Main_Menu")
            Main_Menu.show()
            Main_Menu.activate()
        ELSE
            :Form.view("Main_Menu","","","center","Center")
        END IF
        Peter
        AlphaBase Solutions, LLC

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


        Comment


          #5
          Re: Multiple form instances being created with log on/off routine

          I suspect your script is running to conclusion before the Main_menu form is completely closed. After all, the script itself is running in the form's space in memory, right? I asked about the purpose because you may be able to achieve your goal by keeping the form open, while still doing the necessary processing you require. Have you found its necessary to close the form in order to log in a new user?

          Comment


            #6
            Re: Multiple form instances being created with log on/off routine

            I close forms so the interface is very simple for the user and there would only be one tab showing (lower left) is Alpha at any one point in time. I was having refresh issues with global variables on the form and found if the form was closed and reopened the always updated appropriately. It looks like closing the form is causing other issues as well.

            Can I hide the form and accomplish the same results? I assume it would make it faster to respond in the long run becuase it would not have to reopen the forms each time I wanted to access them?

            What would the proper process be to refresh the parent form after the Log on/off script has run? I want to make it so no matter what form they are on it is closed or hidden and they are returned to the Main_Menu form.

            Interestingly enough, I commented out parentform.close(.f.) and used Peters code from the previous post although when I am not on the Main_Menu form it does not open the Main_Menu form again although I think it may be a refresh issue. What is the command to refresh/repaint the screen no matter where you are at?

            Comment


              #7
              Re: Multiple form instances being created with log on/off routine

              Have you decided not to use

              A5_ChangeLoggedOnUser()

              ?

              -- tom

              Comment


                #8
                Re: Multiple form instances being created with log on/off routine

                I am not using Alpha's built in security.

                Comment


                  #9
                  Re: Multiple form instances being created with log on/off routine

                  Ok. I see now why you're in this box. Will ponder.

                  Is the main_menu form based on a dummy table?

                  Comment


                    #10
                    Re: Multiple form instances being created with log on/off routine

                    Yes, the table is called startup.

                    Comment


                      #11
                      Re: Multiple form instances being created with log on/off routine

                      Tom,

                      Just in case it is helpful I am posting the Log On/Off code I have to date so you can see what I am doing. The code below works as expected except for the original issue regarding opening up multiple instances of the form when run from the Main_Menu form.

                      DIM GLOBAL gvModuleName as C
                      DIM GLOBAL gvuser as C
                      DIM GLOBAL gvEmpName as C
                      DIM GLOBAL gvEmpid as C
                      DIM GLOBAL gvLogOnOff as C

                      DIM SHARED vuserpass as C
                      DIM SHARED varC_result as C
                      DIM SHARED vCenterForm as C
                      DIM vuserfound as C

                      'Change Title to "Log On As" and refresh parent layout
                      gvModuleName = "Log On As"

                      'Blank the Username and Password
                      gvuser=""
                      vuserpass=""

                      'Change the Employee Name to "No Employee"
                      gvEmpName="No Employee"

                      'Set Log_On_Off button text to "Log On"
                      gvLogOnOff = "Log On"
                      Log_On_Off.text = gvLogOnOff

                      'Refresh Main Menu
                      topparent.Repaint()

                      '---------------
                      Retry_here:
                      '---------------
                      ok_button_label = "&Log On"
                      'cancel_button_label = "&Cancel"
                      varC_result = ui_dlg_box("EIM Track",<<%dlg%
                      {font=Arial,10}
                      {frame=1,1:Enter your Username and Password:}
                      {region}
                      {lf};
                      Username:| [.40gvuser];
                      Password:| [%p%.40vuserpass];
                      {lf};
                      {endregion};
                      {lf};
                      {region}
                      {justify=right}
                      <*15=ok_button_label!Log On*?>
                      {endregion};
                      %dlg%)

                      IF varC_result = "Log On"
                      ' Get data from Employee Master file to verify password - make one text string that has both values and then parse it out below
                      ' Lookup the records for the matching username and password
                      lres = lookupc("F",alltrim(gvuser),"alltrim(emplognid)+' -- '+alltrim(emppass)",a5.Get_Path()+"\emp.dbf","_emplognid")
                      vuserfound = word(lres,1," -- ")
                      vpassfound = word(lres,2," -- ")

                      'Compare user name entered to that in the Employee Master file (found with lookupc above)
                      IF alltrim(lower(gvuser)) = alltrim(lower(vuserfound))
                      'Name matches - now look at the password for a match

                      IF alltrim(lower(vuserpass)) = alltrim(lower(vpassfound)) ' Password matches too
                      gvuser = alltrim(lower(gvuser))

                      'Clear vuserpass variable
                      vuserpass = ""

                      'Close the current form
                      parentform.close(.f.)

                      'Set a Global Variable containing the Employees full name
                      gvEmpName = lookupc("F", gvuser, "alltrim(Empfname)+' '+ alltrim(Emplname)", "emp","_Emplognid")

                      'Set a Global Variable containing the Employees ID Number
                      gvEmpid = lookupc("F", gvuser, "alltrim(Empid)", "emp","_Emplognid")

                      'Set a Global Variable containing the current module name
                      gvModuleName = "Main Menu"

                      'Form Name to Center when opening
                      vCenterForm = "Main_Menu"

                      'Set Log_On_Off button text to "Log Off"
                      gvLogOnOff = "Log Off"
                      Log_On_Off.text = gvLogOnOff

                      'Loads the Main Menu
                      form.view(vCenterForm, "", "", "center", "center")

                      'Refresh Main Menu
                      topparent.Repaint()
                      END'
                      ELSE
                      'Password does not match - try again
                      ui_msg_box("Password Error!","Password entered is incorrect.",UI_STOP_SYMBOL)

                      'Clear vuserpass variable
                      vuserpass = ""
                      GOTO retry_here
                      END IF

                      ELSE 'User Name is wrong - this is from first IF statement
                      ui_msg_box("User Name Not Found","The User Name you entered could not be found",UI_STOP_SYMBOL)
                      gvuser = ""
                      vuserpass = ""
                      GOTO Retry_here
                      END IF
                      END IF

                      Comment


                        #12
                        Re: Multiple form instances being created with log on/off routine

                        Ok. I'm back to my original question. Why close the main_menu form?

                        Comment


                          #13
                          Re: Multiple form instances being created with log on/off routine

                          Originally posted by Tom Cone Jr View Post
                          Ok. I'm back to my original question. Why close the main_menu form?
                          Reduces the number of tabs open and I was having issues with the screen not refreshing/repainting.

                          Comment


                            #14
                            Re: Multiple form instances being created with log on/off routine

                            It seems to me that your script could determine if it were running in the main_menu form or not. If it is not, then let the script close the parentform. If it is running in the main_menu form there should be no reason to open and close it. Right?

                            later edit...

                            Code:
                            parentform.name()


                            will return the name of the form within which you button lives.
                            Last edited by Tom Cone Jr; 06-07-2010, 01:26 PM.

                            Comment


                              #15
                              Re: Multiple form instances being created with log on/off routine

                              Correct, there would be no need to close and open the form if it was already on the Main_Menu form although I would need to refresh it so we can see the changes to the variables.

                              I was not able to get the IS_Object() function to work properly as Peter suggested earlier.

                              Being new to Xbasic I am still struggling with the correct syntax to do everything you mentioned. Can you provide an examples based on the code I listed previously?

                              Comment

                              Working...
                              X