Alpha Video Training
Results 1 to 6 of 6

Thread: Create an AEX file and delete all scripts and udf’s

  1. #1
    "Certified" Alphaholic Ronald Anusiewicz's Avatar
    Real Name
    Ronald Anusiewicz
    Join Date
    Oct 2000
    Location
    Southampton, MA
    Posts
    1,583

    Default Create an AEX file and delete all scripts and udf’s

    I did a search of the message board looking for an easier way to create an AEX file and then to delete all the scripts and UDF functions. Steve Workings posted a script that he used.

    While it worked for me, I was getting some errors when running the script. I did get a little carried away, but this script works very well now.

    Caution, backup your databse, scripts and functions before running this script.



    Code:
    'Date Created: 30-Nov-2012 10:07:53 PM
    'Last Updated: 07-Jan-2013 03:58:23 PM
    'Created By  : Ron
    'Updated By  : Ron
    
    ''CAUTION, THE USE OF THIS SCRIPT IS AT THE USERS OWN RISK
    ''I HAVE USED THIS IN VERSION 11 AND IT APPEARS TO WORK CORRECTLY
    
    ''this script is designed to create an aex file.  Then after creating the file
    ''it will delete all scripts and udf's from the code tab.  Make a copy of your database before
    ''using this script.  The variable vcName is the name of your database.  You will need to
    ''edit this variable before running the script.
    
    DIM SHARED vcConfirm as C
    DIM SHARED vcConfirm2 as C
    
    'set the name of your database here
    dim vcName as C
    vcName = a5.Get_Path() + "\phone"  
    
    DIM SHARED vDlg_Title as C
    DIM SHARED vMsg as C
    vMsg="This Script Will Delete All Scripts And Functions While Creating An AEX File To Be Used In Place Of The Idividual Scripts And Functions."+crlf(2)+  "It is Imperative to Create An Export From The Code Tab To Backup All Scripts And Functions before continuing."
    DIM SHARED varC_result as C
    DIM XDialogStyle as P
    XDialogStyle.AccentColor = "Off White"
    XDialogStyle.Color = "Blue White"
    vDlg_Title="WARNING"
    dlg_text = <<%dlg%
    {Windowstyle=Gradient Horizontal}
    {font=calibri,15,b}{units=F}{xmargin=4,4}{ysize=.3};
    {color=red on white}
    {text=%H=R%55,7vMsg};;
    
    {color=black on white}
    {region}
    Type "YES" to Confirm:| [.10vcConfirm];
    Type "YES" to Confirm:| [.10vcConfirm2];
    {endregion};
    
    {line=0};;{justify=center,Center}
    <12,1.5OK>{sp=2}
     <*12,1.5Cancel>{sp=2}
    %dlg%
    varC_result=ui_dlg_box(vdlg_title, dlg_text, <<%code%
    %code%)
    
    IF varC_result <> "OK" THEN
    	END
    END IF
    
    
    
    'Show PleaseWait125 Function, msg declared for title
    dim shared msg as C
    dim shared curfile as C = ""
    dim count as n 
    msg = " Creating AEX File"
    count = 11
    
    PleaseWait125(.t.,msg)
    curfile = "Startup"
    pct = round((0/count)*99,0) 
    ui_modeless_dlg_refresh(msg)
    ui_yield()
    
    
    if vcConfirm = "YES" .and. vcConfirm2 = "YES" then
    	
    	'' Make AEX ---------------------------------------------------------------------------------
    	a5_compile_scripts()
    	
    	curfile = "AEX file Created"
    	pct = round((1/count)*99,0)
    	ui_modeless_dlg_refresh(msg)
    	ui_yield()
    	
    	' Make new AEX temp file ---------------------------------------------------------------------
    	curfile = "copy file "+vcName+".alb to aex.dbf"
    	pct = round((2/count)*99,0)
    	ui_modeless_dlg_refresh(msg)
    	ui_yield()
    	file.copy(vcName+".alb", a5.Get_Path() + "\aex.dbf")
    	
    	curfile = "copy file "+vcName+".alm to aex.fpt"
    	pct = round((3/count)*99,0)
    	ui_modeless_dlg_refresh(msg)
    	ui_yield()
    	file.copy(vcName+".alm", a5.Get_Path() + "\aex.fpt")
    	
    	curfile = "copy file "+vcName+".alx to aex.cdx"
    	pct = round((4/count)*99,0)
    	ui_modeless_dlg_refresh(msg)
    	ui_yield()
    	file.copy(vcName+".alx", a5.Get_Path() + "\aex.cdx")
    	
    	' add the AEX temp file to the current database -------------------------------------------------
    	curfile = "Adding the AEX table to the database"
    	pct = round((5/count)*99,0)
    	ui_modeless_dlg_refresh(msg)
    	ui_yield()
    	file_add_to_db(a5.Get_Path() + "\AEX.dbf")
    	
    	xbasic_wait_for_idle()
    	
    	' Remove scrips and UDFs -------------------------------------------------------------------------
    	curfile = "Remove Scripts and UDF's"
    	pct = round((6/count)*99,0)
    	ui_modeless_dlg_refresh(msg)
    	ui_yield()
    
    	t = table.open("AEX")
    	filter = "type = 'scrp' .or. type = 'gudf'"
    	t.delete_range(filter)
    	t.pack()
    	t.close()
    	
    	' Replace al* files with new dictionary -----------------------------------------------------------
    	curfile = "copy aex.dbf to "+ vcName+".alb"
    	pct = round((7/count)*99,0)
    	ui_modeless_dlg_refresh(msg)
    	ui_yield()
    	file.copy(a5.Get_Path() + "\aex.dbf", vcName+".alb")
    
    	curfile = "copy aex.fpt to "+ vcName+".alm"
    	pct = round((8/count)*99,0)
    	ui_modeless_dlg_refresh(msg)
    	ui_yield()
    	file.copy(a5.Get_Path() + "\aex.fpt", vcName+".alm")
    
    	curfile = "copy aex.cdx to "+ vcName+".alx"
    	pct = round((9/count)*99,0)
    	ui_modeless_dlg_refresh(msg)
    	ui_yield()
    	file.copy(a5.Get_Path() + "\aex.cdx", vcName+".alx")
    	
    	' Erase the AEX temp table --------------------------------------------------------------------------
    	curfile = "Erase the temp table AEX"
    	pct = round((10/count)*99,0)
    	ui_modeless_dlg_refresh(msg)
    	ui_yield()
    	
    	dim tbl as p
    	tbl = A5.GET_PATH()+ "\aex.dbf"
    	table.erase(tbl, .t.)
    	
    	
    	PleaseWait125(.f.,msg)
    	
    	ui_msg_box("","Completed")
    	
    end if
    
    END  
    
    FUNCTION PleaseWait125 AS C (Show = .T.,msg="")
    	IF show = .F. THEN
    		IF ui_modeless_dlg_exist(msg) THEN
    			ui_modeless_dlg_close(msg)
    		END IF
    		exit function
    	END IF
    	
    	PleaseWait125 = ""
    	
    	IF msg = "" THEN
    		msg = " Creating AEX File"
    	END IF
    	
    	dim shared pct as N
    	box_code = <<%dlg%
    {background=Dirty White}
    {font=arial,26,i}
      Please Wait!     
    {'};
    {font=arial,12}
    {sp=32}{text=4pct}%;
      {progress=60pct}  {'};
    {'};
    {font=arial,9}
      {text=65curFile};
    %dlg%
    	box_event = <<%code%
    2=2
    %code%
    	ui_modeless_dlg_box(msg,box_code,box_event)
    	ui_modeless_dlg_setfocus(msg)
    	ui_modeless_dlg_refresh(msg)
    END FUNCTION
    Attached Files Attached Files

  2. #2
    "Certified" Alphaholic Ray in Capetown's Avatar
    Real Name
    Ray Hendler
    Join Date
    Jan 2009
    Location
    South Africa
    Posts
    2,036

    Default Re: Create an AEX file and delete all scripts and udf’s

    While that's great - and I dream of doing that when apps settle down. But they NEVER seem to, EVER.
    Always need to tweak a script or UDF.
    Sometimes I forget what exactly one does and need to check. So realistically, for me, it will remain a dream.
    I will have to live with a cluttered code tab but its all or nothing no? Can one select what stuff to AEX and what to keep handy?

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

    Default Re: Create an AEX file and delete all scripts and udf’s

    Ray,

    Quote Originally Posted by Ray in Capetown View Post
    I will have to live with a cluttered code tab but its all or nothing no? Can one select what stuff to AEX and what to keep handy?

    The CSDA Code Utility has a function that is included called LIBMAKE, that will create an AEX with exactly the global code and objects required for specific projects. Very few people use this, but it has extreme abilities for building AEX packages.

    All of my code, for any of my utilities, is kept in exactly 1 code library, even though only a small portion are used by any specific utility to make the AEX for the utility. This is the way I can maintain pieces of code shared by many utilities. For the largest of the utilities, it takes less than a minute to create the AEX with LIBMAKE.

    There are CSDA Code Utility specific comment lines that act as directives that will allow pulling in other code objects that are required for that function/script to work automatically. Password protection on global scripts or Functions doesn't matter for the purposes of LIBMAKE, although it runs a bit faster with no passwords on used code objects

    You can also have it prompt you for it's parameters (such as which code objects) for adhoc usage, but for regular build's, it is better to have a standard piece of code that feeds the needed top-level code objects to it.

    E.g. This is an abstract of the directives from the CSDA Diag Info
    'PACKAGES ScreenCapture,A5desktop,Barcode,DiagInfo
    'DEPENDENCIES
    'INCLUDE Win_Special_FolderX(),CSDA_AEXEnum(),CSDA_Update()
    'INCLUDE ui_msg_boxX(),CSDA_DispHelp(),CSDA_A5XBasicSpeed()
    'INTERNAL win_memory_infox(),win_motherboardX(),GetCPUInfo()
    'EXTERNAL _CSDA_DiagInfo(),CSDA_HelpFlags()
    'EXCLUDE a5desktop()

    Each directive name can be spread across multiple lines if needed (as shown with the INCLUDE).
    • PACKAGES is the top level name for objects to include in the AEX build, and hence is essentially a filter to grab all code objects that should be compiled. Slows down if you have a lot of code objects because it must open every single one to see if it is in the package(s)
    • INCLUDE are code objects to include in the code object at the end of it prior to compiling (so it is NOT available as global code),
    • EXTERNAL forces the object to be external (in other words global code), even if also listed under the INCLUDE directive
    • EXCLUDE does not build that object into the AEX (even if specified under EXTERNAL or INCLUDE) and assumes it is available from some other AEX in the system
    • INTERNAL is currently unused, but basically is a list of all code objects that are internal to the current object that it directly uses
    • DEPENDENCIES is currently unused, but is a list of all code objects (internal or external, that the object requires to operate


    Each project can automatically pull in the needed objects and no unneeded ones. All of my utilities are built with it. By just specifying a package name in the LIBMAKE call, that automatically searches all code for the package name and pulls in the all the code and dependent code, making them internal functions (to a piece of code, and hence inaccessible by other global code) or scripts or functions in the AEX. Other objects (Images, toolbars, Menus) can also be added to the AEX, but they are not all accessible without advanced tools (unless you developed tools like I did to go and extract the code).

    LIBMAKE has been included in the CSDA Code Utility since it's 1st release.
    Last edited by csda1; 01-18-2013 at 12:09 PM.
    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



  4. #4
    "Certified" Alphaholic Ray in Capetown's Avatar
    Real Name
    Ray Hendler
    Join Date
    Jan 2009
    Location
    South Africa
    Posts
    2,036

    Default Re: Create an AEX file and delete all scripts and udf’s

    Thanks Ira
    At first glance right now it looks perfect.

  5. #5
    Member
    Real Name
    brett sinclair
    Join Date
    Aug 2002
    Location
    Wellington, New Zealand
    Posts
    858

    Default Re: Create an AEX file and delete all scripts and udf’s

    Oh, and I guess there is always this one here - CompileDB from a few decades ago.

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

    Default Re: Create an AEX file and delete all scripts and udf’s

    The one Brett shared some years ago complies to aex and later reverses that if you need to.
    I have not tried the one by Ira yet, so can not compare the 2.

    I will try it later this week.
    Dave Mason
    dave@aldausa.com
    Skype is dave.mason46

Similar Threads

  1. AEX udf/script enum method?
    By Peter.Greulich in forum Alpha Five Version 8
    Replies: 3
    Last Post: 11-12-2014, 11:20 PM
  2. Compiling Scripts into an AEX File
    By Ted Giles in forum General Questions
    Replies: 10
    Last Post: 10-17-2012, 01:41 PM
  3. Access to scripts in .aex files
    By Mike Wilson in forum Alpha Five Version 11 - Desktop Applications
    Replies: 2
    Last Post: 04-10-2012, 08:56 PM
  4. Turning Scripts into UDF's
    By MoGrace in forum Database Design
    Replies: 4
    Last Post: 05-18-2007, 12:06 PM
  5. aex - compiled scripts
    By Terry Morgan in forum Alpha Five Version 5
    Replies: 4
    Last Post: 01-15-2003, 03:37 PM

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
  •