Alpha Video Training
Results 1 to 18 of 18

Thread: A5 restart command?

  1. #1
    Volunteer Moderator Peter.Greulich's Avatar
    Real Name
    Peter Greulich
    Join Date
    Apr 2000
    Location
    Boston, MA
    Posts
    11,648

    Default A5 restart command?

    Is there an a5 command that will close & restart A5?

  2. #2
    "Certified" Alphaholic
    Real Name
    Andrew Schone
    Join Date
    Dec 2005
    Location
    Kansas
    Posts
    1,047

    Default Re: A5 restart command?

    Can you please clarify if you want to close the A5 database and leave the Alpha5 shell open or do you want to close the entire A5 shell and then restart it.

    Off hand I do not know of a Xbasic command that will natively do that. I do however believe that this can done via a VBscript that is called from within Alpha5. I have not tested nor done this before so can not guarantee that this is the best solution.

  3. #3
    Volunteer Moderator Peter.Greulich's Avatar
    Real Name
    Peter Greulich
    Join Date
    Apr 2000
    Location
    Boston, MA
    Posts
    11,648

    Default Re: A5 restart command?

    or do you want to close the entire A5 shell and then restart it.

    Yes, the latter.

  4. #4
    VAR csda1's Avatar
    Real Name
    Ira J Perlow
    Join Date
    Apr 2000
    Location
    Boston, Massachusetts, USA
    Posts
    3,530

    Default Re: A5 restart command?

    Peter,

    That is the prime reason I developed the CSDA Code Utility for Alpha 5.

    It saves the state of all the current windows, closes A5, reopens A5 and restores all the windows back to their original state and stays out of the way of affecting your database application.

    It also has quick saves of your application (even in shared mode) to regularly backup the development process, a logging of the open windows and a variety of timing and debugging aids.

    It has a couple of issues with A5v8 and it's directories (because of Vista support), but an update will be available in the next day or so that will resolve these issues.

    To answer your question precisely, the answer is no,there is no Xbasic command. Can it be done? Yes, 6 months of development and testing allows me to do just that!
    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



  5. #5
    Volunteer Moderator Peter.Greulich's Avatar
    Real Name
    Peter Greulich
    Join Date
    Apr 2000
    Location
    Boston, MA
    Posts
    11,648

    Default Re: A5 restart command?

    Quote Originally Posted by csda1 View Post
    Can it be done? Yes, 6 months of development and testing allows me to do just that!
    Funny! :)

    Yes, Ira, I'm very aware of your code utility - after all, you demoed it at the conference! But, of course, as I understand it, your utility is for development purposes and wouldn't be suitable for my very minor need. But thanks for the reminder.

  6. #6
    VAR
    Real Name
    Martin W. Cole
    Join Date
    Apr 2000
    Location
    Terrell, Texas (near Dallas)
    Posts
    5,957

    Default Re: A5 restart command?

    Peter, you can do it with a5.load()

    I have an app that lets you change facilities (same app is in different folders for different hospitals) - where the therapist wants to first enter her activities in one and then in another if she worked both places that day.

    The code below will give you an idea. The reason I know it will work is that when I was in one facility I changed facilities to the same facility, and it loaded perfectly. Note that A5.load() closes the current adb automatically. Also note the line in red (for apps where the "main menu" has cancel() in the canexit event.)


    Code:
    lastuse=toseconds(time())
    f=form.view("load2","dialog")
    f.close()
    if ans="yes"
     if gpc="homeoffice"
      if loglevel < 2
       msgbox("Note","Current User not authorized for this choice!",16)
       end 
      end if 
     end if 
     parentform.code.canexit=""
     A5.LOAD("C:\Alpha\TowsonRehab" + chr(92) + var->gpc + chr(92) + "towson.adb")
    end if
    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

  7. #7
    VAR csda1's Avatar
    Real Name
    Ira J Perlow
    Join Date
    Apr 2000
    Location
    Boston, Massachusetts, USA
    Posts
    3,530

    Default Re: A5 restart command?

    Hi Martin,

    A5.Load() closes the database, and reopens with the new database.

    Peter, on the other hand, wants to quit Alpha 5, and restart Alpha 5 with the same or another database, which is not the same thing.
    Last edited by csda1; 05-17-2007 at 01:14 AM.
    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



  8. #8
    VAR
    Real Name
    Martin W. Cole
    Join Date
    Apr 2000
    Location
    Terrell, Texas (near Dallas)
    Posts
    5,957

    Default Re: A5 restart command?

    ahh soooooo - moral: read lines velly closely!!

    He might be able to do it with (I'm not sure what you call it - its like a compiled bach file) that he could call when he closes Alpha that would wait for maybe a couple of seconds and then open it again.

    Wonder why he wants to do that?!
    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

  9. #9
    VAR csda1's Avatar
    Real Name
    Ira J Perlow
    Join Date
    Apr 2000
    Location
    Boston, Massachusetts, USA
    Posts
    3,530

    Default Re: A5 restart command?

    Hi Martin,

    Quote Originally Posted by martinwcole View Post
    Wonder why he wants to do that?!
    I'm not sure why either, unless you are doing a self patching of Alpha 5 or a restart utility like mine, two very unlikely scenarios. Peter?
    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



  10. #10
    Volunteer Moderator Peter.Greulich's Avatar
    Real Name
    Peter Greulich
    Join Date
    Apr 2000
    Location
    Boston, MA
    Posts
    11,648

    Default Re: A5 restart command?

    Quote Originally Posted by csda1 View Post
    I'm not sure why either, unless you are doing a self patching of Alpha 5 or a restart utility like mine, two very unlikely scenarios. Peter?
    Martin: Yes, I do use A5.load to load other dbs. But thanks for the thought.

    Ira: Yes, I want to "patch" A5. A5 is locking a certain file while it runs. I can update w. A5 closed manually, I just want to automate it.

  11. #11
    "Certified" Alphaholic DaveM's Avatar
    Real Name
    Dave Mason
    Join Date
    Jul 2000
    Location
    Hudson, FL
    Posts
    6,027

    Default Re: A5 restart command?

    Not sure if it will work, but


    The ON_DATABASE_EXIT() function allows you to "register" code that will be executed when the current database is closed. You can call the function as many times as you want to register as many different code snippets as you want.
    There is also a script that runs after the database closes like autoexec runs when the db starts. You may be able to use that.

    Sorry, my time is limited today or I would look it up for you.

    dave
    Last edited by DaveM; 05-17-2007 at 03:50 PM.

  12. #12
    Volunteer Moderator Peter.Greulich's Avatar
    Real Name
    Peter Greulich
    Join Date
    Apr 2000
    Location
    Boston, MA
    Posts
    11,648

    Default Re: A5 restart command?

    Quote Originally Posted by DaveM View Post
    Not sure if it will work, but

    There is also a script that runs after the database closes like autoexec runs when the db starts. You may be able to use that.
    ON_DATABASE_EXIT() doesn't appear to do the trick because A5 is still running.



    Thanks, Dave



    P.S. Your latter comment sounds interesting...

  13. #13
    Alpha Software Employee AaronBBrown's Avatar
    Real Name
    Aaron Brown
    Join Date
    Feb 2001
    Location
    Waltham, MA
    Posts
    2,836

    Default Re: A5 restart command?

    Have you tried a sys_shell() followed by an a5.close(). It would mean the other instance of A5 would start opening before the current one closed, but it doesn't sound like that would be a problem in your case.
    [FONT=Tahoma][SIZE=1][COLOR=Blue]Aaron Brown
    Alpha Software Development Team[/COLOR][/SIZE][/FONT]

  14. #14
    Volunteer Moderator Peter.Greulich's Avatar
    Real Name
    Peter Greulich
    Join Date
    Apr 2000
    Location
    Boston, MA
    Posts
    11,648

    Default Re: A5 restart command?

    Quote Originally Posted by AaronBBrown View Post
    Have you tried a sys_shell() followed by an a5.close().
    Sorry, Aaron. That doesn't help. I want to run a command in between A5 being open.

  15. #15
    "Certified" Alphaholic DaveM's Avatar
    Real Name
    Dave Mason
    Join Date
    Jul 2000
    Location
    Hudson, FL
    Posts
    6,027

    Default Re: A5 restart command?

    Peter,

    I researched that area I thought could run a script after db was closed. Not there! My mistake.

    An alternative would be a windows script or an exe to be called when db is closing with a wait period, then a restart for your alpha app.

    Dave

  16. #16
    "Certified" Alphaholic
    Real Name
    Andrew Schone
    Join Date
    Dec 2005
    Location
    Kansas
    Posts
    1,047

    Default Re: A5 restart command?

    I have attached a sample database that has a restart button to demonstrate how to terminate a running Alpha5 database and then restart it.

    The restart button will call the VBScript "DB_Restart.vbs"

    WARNING!
    The script will do a forced process termination of the "Alpha5.exe" process. This is not a polite method to close down applications, unsaved work will be lost. Additional coding to protect data will need to be implemented prior to the vbscript call.

    The vbscript works by terminating any running process that is called Alpha5.exe. If you have multiple databases all opened at the same time this script will terminate all of them (in theory, did not test that).

    The script is not dynamic enough to be added to any database. You will need to change the varible strDB to the database file name that you want to open. It is possible to pass arguments to the script so that it knows who the calling database is. I did not take the time to code the arguments capability to the script.

    Code:
    strDB = "DB_Restart.adb"
    Also the script file needs to be stored in the same folder as the .ADB file you wish to open.
    Code:
    '====================
    '
    ' NAME:     DB_Restart.vbs
    '
    ' AUTHOR:     A. Schone
    '
    ' SCRIPT TYPE:    vbscript
    '
    ' SUB TYPE:    
    '
    ' WSH VERSION:    2.0
    '
    ' COMMENT:     
    '
    ' ARGUMENTS:    
    '
    ' HISTORY:    05/17/2007        Creation
    '
    ' Description:
    '	DB_Restart will terminate the Alpha5.exe process and then open the Alpha5 Database referenced by strDB.
    '	DB_Restart must reside in the same folder as the .ADB you wish to open
    '====================
    
    Option Explicit
    'On Error Resume Next
    
    ' Initialize vars
    Dim strDB
    Dim strPath
    
    'Database to reopen
    strDB = "DB_Restart.adb"
    
    strPath = GetPath() + "/" + strDB
    
    EndAlpha5()
    
    'Administrative tasks that need to be executed prior to re-opening of the database go here
    
    StartAlpha5()
    
    WScript.Quit(0)
    
    Sub EndAlpha5
    	Dim objWMIService, objProcess, colProcess
    	Dim strComputer, strProcessKill 
    	strComputer = "."
    	strProcessKill = "'alpha5.exe'" 
    
    	Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") 
    
    	Set colProcess = objWMIService.ExecQuery("Select * from Win32_Process Where Name = " & strProcessKill )
    	For Each objProcess in colProcess
    		objProcess.Terminate()
    	Next 
    End Sub
    
    Sub StartAlpha5
    	Dim objShell
    	Set objShell = CreateObject("Wscript.Shell")
    	objShell.Run strPath
    End Sub
    
    Function GetPath
    	' Return path to the current script
    	DIM path
    	path = WScript.ScriptFullName  ' script file name
    	GetPath = Left(path, InstrRev(path, "\"))
    End Function
    Last edited by aschone; 05-17-2007 at 07:06 PM. Reason: Added additional detail and warning

  17. #17
    "Certified" Alphaholic G Gabriel's Avatar
    Real Name
    G. Gabriel
    Join Date
    Oct 2004
    Posts
    7,204

    Default Re: A5 restart command?

    Simple is always good:
    Create a new script in the code tab and name it"OnDatabaseClose":
    sys_open("C:\Documents ......\your_file.adb")

  18. #18
    Volunteer Moderator Peter.Greulich's Avatar
    Real Name
    Peter Greulich
    Join Date
    Apr 2000
    Location
    Boston, MA
    Posts
    11,648

    Default Re: A5 restart command?

    In my particular case, at least, I have discovered as long as A5 is running I can't do what I want. I have to run my script from a 3rd party utility.

Similar Threads

  1. Alpha 5 Restart & Script Edit Restore
    By csda1 in forum Code Archive
    Replies: 5
    Last Post: 06-02-2006, 08:02 PM
  2. Using .not. Command
    By lbrady in forum Alpha Five Version 6
    Replies: 2
    Last Post: 11-17-2005, 03:32 PM
  3. IF command, Case command, sort command
    By Dannie Mogensen in forum Web Application Server v6
    Replies: 1
    Last Post: 11-14-2004, 06:08 PM
  4. Command help
    By Mark Campidonica in forum Alpha Five Version 5
    Replies: 5
    Last Post: 08-28-2003, 06:36 AM
  5. Do While command
    By Keith George in forum Alpha Four Version 6 and Prior
    Replies: 8
    Last Post: 01-04-2002, 10:59 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
  •