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

How to automatically return to Main Menu

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

  • How to automatically return to Main Menu

    Perhaps this can't be done, but maybe some sharp Xbasic guru has an answer.

    On a network I want one and only one particular user to be in Alpha Five, all others out. The obvious reason is that certain indexes can be updated automatically, overnight, by the one user's computer being the only one open (because a script_schedule command will execute at a certain time), plus other events will take place. There are three tricky aspects to this.

    First, I want the one open user to be at the Main Menu, regardless of where he was when he left the office. The reason: I don't want him to have any data files open. How do I return him to the Main Menu from wherever he might have been, some screen, some menu, whatever? I don't want to close him out of Alpha, just to be sure the data files are all closed, implying the closing of any form or browse which would have data files open.

    Second, the script_schedule command, if you've ever used it, is great for scheduling the first running of a script, but I don't know of a way to continue to keep it running every day. Maybe using the script invoked by script_schedule to run that very script will in fact invoke it for the next day. Not sure. Maybe you know. The reason is that the one computer I wish to be open to the Main Menu each night may not be exited and restarted, i.e., a new session of Alpha may not be started. Since I am using the autoexec.scp to set the script_schedule events, I need to be sure it will trigger every night.

    Third, since I depend on this one computer to be open to Alpha, logged in as a specific user, then if Alpha happened to be closed at the end of the business day and not open to run the script_schedule events, is there a way to 1) detect that Alpha is not open on this computer via a Windows scheduled event 2) if not open, open Alpha using the specific user's login to arrive at the Main Menu. Obviously, I need to know that Alpha is not open first since I don't want to try opening another session of Alpha.

    Thank you if you're familiar with these nuances.

    Jeff Fried

  • #2
    Re: How to automatically return to Main Menu

    This is a tall order, however it is possible to accomplish what you are asking.

    1) This script I believe I found in the code archive. Originally written by Martin Cole. This will close all open forms then shutdown Alpha5. However in your case you would want to remove the a5.close() line so that you do not shutdown Alpha5. Ideally you could replace that line with the line that would open you main menu form.
    Code:
    	'Date Created: 02-Aug-2007 09:55:50 PM
    'Last Updated: 05-Feb-2010 08:31:26 AM
    'Created By  : Administrator
    'Updated By  : martin cole
    on error goto errors
    	temp=""
    	loop: 
    	temp=a5.Form_Enum(2) 'get a list of all forms in the app
    	for i=1 to w_count(temp,crlf())
    		fname=word(temp,i,crlf())
    		if is_object(fname)
    			if fname="Menu_master"
    				:Menu_master.code.canexit="" 'override canexit setting
    			else
    				if eval(trim(fname) + ".mode_get()") <> "view"
    					eval(trim(fname) + ".activate()")
    					sys_send_keys("{esc}") 'this cancels possible pop-ups
    					sys_send_keys("{esc}") 'this cancels the current entry/edit
    					xbasic_wait_for_idle() 
    					if is_object(fname) 'may be closed here from esc
    						eval(":" + trim(fname) + ".cancel()")
    						eval(":" + trim(fname) + ".close()")			
    					end if 
    					goto next1 
    				end if 
    				eval(":" + trim(fname) + ".cancel()")
    				eval(":" + trim(fname) + ".close()")			
    			end if
    		end if 
    		next1: 
    	next
    	a5_close_all_windows()
    	temp=a5_list_open_windows()
    	for i=1 to w_count(temp,crlf())
    		eval(word(temp,i,crlf()) + ".cancel()")		
    		eval(word(temp,i,crlf()) + ".close()")
    	next
    	sleep(1/3)
    	if a5_is_runtime() .and. a5.Get_Master_Path()="" 'terminal services machine
    		if api_getmachinename()="martin"
    			msgbox("trapped restart")
    		else
    			sys_shell("shutdown /L")
    		end if 
    	end if 
    	a5.close()
    	end
    	errors:
    	err_msg = error_text_get(error_code_get())
    	line = error_line_number_get()
    	script = error_script_get()
    	ui_msg_box("Error", err_msg+" Error occurred at line "+alltrim(str(line,4,0))+ " in script: "+script)
    	end
    Andrew

    Comment


    • #3
      Re: How to automatically return to Main Menu

      2) Scheduling of a script with a reschedule
      Dr. Wayne wrote the starting of this and I modified it for my needs. You can find the original discussion here

      the script is called StatusCheck it is originally ran from the autoexec via the following command
      Code:
      script_play( "StatusCheck" )

      Code:
      'Date Created: 23-Aug-2010 04:52:28 PM
      'Last Updated: 24-Aug-2010 01:22:13 PM
      'Created By  : andy
      'Updated By  : andy
      DIM vMaintenanceL as L
      vMaintenanceL = lookupl("F",1,"Maintenance","control","Key")
      IF  vMaintenanceL = .t. THEN
      '	ui_msg_box("Maintenance","System is going into Maintenance Mode")
      	IF vgUserP.OverrideMaint = .f. THEN
      		f_shutdown(60)
      	END IF
      else
      	DIM vScriptRunTimeC as C
      	vScriptRunTimeC = totime( toseconds( time() ) + 60, 1 ,0 )
      	'ui_msg_box("",vScriptRunTimeC)
      	script_schedule( "StatusCheck", vScriptRunTimeC )
      END IF
      Andrew

      Comment


      • #4
        Re: How to automatically return to Main Menu

        3) For your third item I would approach that using VB script or a batch file that is ran via the windows scheduler. When configuring the scheduled task you and specify the user credentials that you want to use.

        Here is a quick VB Script to test if Notepad is running. In your case replace "Notepad.exe" with "Alpha5.exe"
        This was found here
        Code:
        set service = GetObject ("winmgmts:")
        
        for each Process in Service.InstancesOf ("Win32_Process")
        	If Process.Name = "notepad.exe" then
        		wscript.echo "Notepad running"
        		wscript.quit
        	End If
        next
        wscript.echo "notepad not running"
        To open Alpha5 you could use the following. This was found here
        Code:
        strProgramPath = "C:\Windows\system32\calc.exe"
        
        SET objShell = CREATEOBJECT("Wscript.Shell")
        
        objShell.Run strProgramPath
        Andrew

        Comment


        • #5
          Re: How to automatically return to Main Menu

          Originally posted by aschone View Post
          This is a tall order, however it is possible to accomplish what you are asking.

          1) This script I believe I found in the code archive. Originally written by Martin Cole. This will close all open forms then shutdown Alpha5. However in your case you would want to remove the a5.close() line so that you do not shutdown Alpha5. Ideally you could replace that line with the line that would open you main menu form.
          Code:
          	'Date Created: 02-Aug-2007 09:55:50 PM
          'Last Updated: 05-Feb-2010 08:31:26 AM
          'Created By  : Administrator
          'Updated By  : martin cole
          on error goto errors
          	temp=""
          	loop: 
          	temp=a5.Form_Enum(2) 'get a list of all forms in the app
          	for i=1 to w_count(temp,crlf())
          		fname=word(temp,i,crlf())
          		if is_object(fname)
          			if fname="Menu_master"
          				:Menu_master.code.canexit="" 'override canexit setting
          			else
          				if eval(trim(fname) + ".mode_get()") <> "view"
          					eval(trim(fname) + ".activate()")
          					sys_send_keys("{esc}") 'this cancels possible pop-ups
          					sys_send_keys("{esc}") 'this cancels the current entry/edit
          					xbasic_wait_for_idle() 
          					if is_object(fname) 'may be closed here from esc
          						eval(":" + trim(fname) + ".cancel()")
          						eval(":" + trim(fname) + ".close()")			
          					end if 
          					goto next1 
          				end if 
          				eval(":" + trim(fname) + ".cancel()")
          				eval(":" + trim(fname) + ".close()")			
          			end if
          		end if 
          		next1: 
          	next
          	a5_close_all_windows()
          	temp=a5_list_open_windows()
          	for i=1 to w_count(temp,crlf())
          		eval(word(temp,i,crlf()) + ".cancel()")		
          		eval(word(temp,i,crlf()) + ".close()")
          	next
          	sleep(1/3)
          	if a5_is_runtime() .and. a5.Get_Master_Path()="" 'terminal services machine
          		if api_getmachinename()="martin"
          			msgbox("trapped restart")
          		else
          			sys_shell("shutdown /L")
          		end if 
          	end if 
          	a5.close()
          	end
          	errors:
          	err_msg = error_text_get(error_code_get())
          	line = error_line_number_get()
          	script = error_script_get()
          	ui_msg_box("Error", err_msg+" Error occurred at line "+alltrim(str(line,4,0))+ " in script: "+script)
          	end
          This looks interesting. I'll adapt it, test it, and let you know. Thanks.

          Jeff

          Comment


          • #6
            Re: How to automatically return to Main Menu

            Andrew,

            Thank you for these three potential solutions. I need to study them and let you know.

            Jeff

            Comment


            • #7
              Re: How to automatically return to Main Menu

              Originally posted by aschone View Post
              2) Scheduling of a script with a reschedule
              Dr. Wayne wrote the starting of this and I modified it for my needs. You can find the original discussion here

              the script is called StatusCheck it is originally ran from the autoexec via the following command
              Code:
              script_play( "StatusCheck" )

              Code:
              'Date Created: 23-Aug-2010 04:52:28 PM
              'Last Updated: 24-Aug-2010 01:22:13 PM
              'Created By  : andy
              'Updated By  : andy
              DIM vMaintenanceL as L
              vMaintenanceL = lookupl("F",1,"Maintenance","control","Key")
              IF  vMaintenanceL = .t. THEN
              '	ui_msg_box("Maintenance","System is going into Maintenance Mode")
              	IF vgUserP.OverrideMaint = .f. THEN
              		f_shutdown(60)
              	END IF
              else
              	DIM vScriptRunTimeC as C
              	vScriptRunTimeC = totime( toseconds( time() ) + 60, 1 ,0 )
              	'ui_msg_box("",vScriptRunTimeC)
              	script_schedule( "StatusCheck", vScriptRunTimeC )
              END IF
              Andrew,

              Regarding the 2nd of your suggested solutions, where a script_schedule needs to re-schedule itself in case the Alpha session is not re-booted (since script_schedule does not reset itself for the next day), I'm not sure I followed how Dr. Wayne's method applies to my situation. But I have now tested how it should work for me, in case anyone is interested and can benefit from this.

              The situation is this. I want certain procedures to run during the night automatically, let's say 3 a.m. To assure this is initially scheduled when Alpha is opened, I have placed the script_schedule command in autoexec.scp, but not the actual "script_schedule(<script name>,<time>)". Rather, I placed in the autoexec.scp the command to run a script that schedules the overnight procedures. Let's say the script that will run is called "sch_over", which has the only purpose in doing the following: script_schedule("Overnight","3:00"). The scheduled script is, as you see, named "Overnight". The "Overnight" script runs the various operations I want to accomplish, and the last line in "Overnight" is to run a script called "sch_over", which again schedules "Overnight" to run at the next "3:00". This should accomplish the goal of rescheduling every day if the original Alpha session remains open.

              Jeff

              Comment


              • #8
                Re: How to automatically return to Main Menu

                Another approach to a "nightly maintenance" routine is to create a new adb - like "maintenance"

                first set all users in th regular adb to close after a certain time

                in the maintenance adb you could add all the tables or all necessary tables and put in the routines, scripts, etc. you want to run. Make a history table for tracking that it ran, the date, etc.

                Set it to run everything when it opens, and then close.

                Then - set a scheduled task to run in windows at a certain time and run the maintenance.

                I've been using this approach for maybe 8 years. Mine rebuilds the indexes, compacts the tables, zips the tables, and then runs maintenance routines and reports for daily summations.
                Cole Custom Programming - Terrell, Texas
                972 524 8714
                martin_w_cole@msn.com

                ____________________
                "A young man who is not liberal has no heart, but an old man who is not conservative has no mind." GB Shaw

                Comment


                • #9
                  Re: How to automatically return to Main Menu

                  Originally posted by martinwcole View Post
                  Another approach to a "nightly maintenance" routine is to create a new adb - like "maintenance"

                  first set all users in th regular adb to close after a certain time

                  in the maintenance adb you could add all the tables or all necessary tables and put in the routines, scripts, etc. you want to run. Make a history table for tracking that it ran, the date, etc.

                  Set it to run everything when it opens, and then close.

                  Then - set a scheduled task to run in windows at a certain time and run the maintenance.

                  I've been using this approach for maybe 8 years. Mine rebuilds the indexes, compacts the tables, zips the tables, and then runs maintenance routines and reports for daily summations.
                  This sounds like it might be a better approach since I don't need to assure the main computer is in Alpha and at the Main Menu. Thanks for the advice.

                  Comment


                  • #10
                    Re: How to automatically return to Main Menu

                    Martin,

                    I now remember why I did not take the approach of exiting all users and running a separate maintenance routine. The reason is due to "... cannot be added to this database because it is secured and bound to another database". I know this is due to having a master password defined, but when I remove the master password, the individual logins for each user are no longer in effect.

                    In your experience with your "nightly maintenance" routine, can I assume you had individual logins defined for each user but were still able to keep files unbound to the master database? Is it possible you can define logins without a master password, but if you defined them after creating a master password you cannot remove the master password without also disabling individual logins? I found that after putting back the master password, the user logins came back as they were.

                    Thanks.

                    Jeff

                    Comment


                    • #11
                      Re: How to automatically return to Main Menu

                      Martin,

                      Additional comments about the master password. Having just tried to experiment with a new database, I see that you cannot define users and groups unless you have a database password. This is a kind of catch-22 since the need for sharing files between databases appears not to be possible unless you eliminate the database (master) password, but without it you cannot control users and groups. Is there a solution to this?

                      Thanks.

                      Jeff

                      Comment


                      • #12
                        Re: How to automatically return to Main Menu

                        I have never used Alphas password system, so I don't know how you would deal with that.

                        But, what you could do is close all forms, etc., and close all but one "machine" - in other words, the maintenance would be tied to one particular computer. I store the machine name in a global variable in my autoexec.
                        Cole Custom Programming - Terrell, Texas
                        972 524 8714
                        martin_w_cole@msn.com

                        ____________________
                        "A young man who is not liberal has no heart, but an old man who is not conservative has no mind." GB Shaw

                        Comment


                        • #13
                          Re: How to automatically return to Main Menu

                          Originally posted by martinwcole View Post
                          I have never used Alphas password system, so I don't know how you would deal with that.

                          But, what you could do is close all forms, etc., and close all but one "machine" - in other words, the maintenance would be tied to one particular computer. I store the machine name in a global variable in my autoexec.
                          I always use individual and group security to control who has access to what. For example, when I am the user, I can click a hidden button on the Main Menu to gain access to the control panel.

                          In an earlier post above, Andrew Schone provided me with code you had written that closes any open windows in Alpha prior to Alpha shutting down. I have not yet studied it, but I was wondering if you have implemented this and if it is stable, in your opinion. I'm also curious why, if you are going to exit Alpha, you wanted to go through the steps of exiting any open forms. Were you concerned that someone who left an entry mid-stream would lose their work when Alpha exit runs? I'm not sure what happens in those cases, whether Alpha leaves without saving or saving.

                          Anyhow, I will need something like your windows-closing code to exit to the Main Menu so all data files will be available for index updating.

                          Thank you.

                          Jeff

                          Comment


                          • #14
                            Re: How to automatically return to Main Menu

                            Originally posted by martinwcole View Post
                            I have never used Alphas password system, so I don't know how you would deal with that.

                            But, what you could do is close all forms, etc., and close all but one "machine" - in other words, the maintenance would be tied to one particular computer. I store the machine name in a global variable in my autoexec.
                            Martin,

                            Just to sum up how I solved this, I now have all computers shutting down Alpha in the evening with script_schedule. One computer, which also acts as the maintenance computer with scheduled tasks, shuts down Alpha in early morning since the user of that computer sometimes accesses it in the evening.

                            The key was how I open Alpha on the maintenance computer and feed the user ID and password. I accomplished this using a keyboard macro, programmed with the proper timings to feed the user ID after the credentials dialog appears. Once open, the autoexec script takes over. It is set to run a series of overnight procedures in an Overnight.scp, which will only run if the time is in a certain time range, i.e., an early morning time range when the user would not be on the machine. Among the procedures run are index updates. After the procedures run (only a couple minutes), I have the computer shutting down, which is not really necessary but keeps it consistent with all the others. I also have emails sent to me just prior to Alpha opening, then as a next to last step within Alpha, telling me the process began, with the time, and the process ended, with the time. If anything were to go wrong, I would not receive at least the second email, and this would tell me to look at it after I check email. Of course the program that generates the second email within Alpha, which is also part of the autoexec.scp, also has the time range and user-specific conditions so it does not trigger during regular times.

                            In addition, I developed a log file to capture every event that takes place within this overnight process (about 15 of them so far), including each index that was updated, the date and time, a description of the event, etc. As I add more overnight procedures, I will also add to this log and will thereby have an ongoing history of what took place.

                            The original missing link was how to start up Alpha. I know you can have a Windows scheduled event to open Alpha, but I could not come up with a way to get through the login credentials using Alpha. It might be interesting to know how to do this, but the solution I have now works. The other approach that I could have taken if not for my use of individual login credentials for each user is the one you suggested, which is a separate application that opens, does its thing, and exits. As you now know, if you use a database password, your data files cannot be shared with another application.

                            I thought you and anyone else who might be interested in developing overnight updates and other procedures might benefit from this.

                            Thanks again to you and the others who contributed advice.

                            Jeff

                            Comment


                            • #15
                              Re: How to automatically return to Main Menu

                              I know this is an thread, but I would like to have more info in the Keyboard macro.
                              How is executed, any third part software?
                              Please advise

                              Comment

                              Working...
                              X