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

Xbasic Script Tidy-up

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

    Xbasic Script Tidy-up

    I thought it would be a good idea to have a clear out of some of the redundant scripts and functions from my data dictionary.

    I have got them into a table and can display the list in an Xdialog Box. Is it possible to tell Xbasic to delete any of the selected scripts/functions from this dialog box as I cant find any obvious method in the help file??

    Code:
    sys_obj_filename = "c:\my databases\aviation\txt\enumeration.txt"
    IF file.exists(sys_obj_filename) THEN
    	file.remove(sys_obj_filename)
    END IF
    sys_obj_list = <<%str%
    Copy
    Export
    Join
    Update
    append
    import
    library
    mark
    menu
    post
    query
    report
    script
    udf
    %str%
    FOR each tag in sys_obj_list
    	statusbar.set_text("processing "+tag)
    	tag = alltrim(tag)
    	evaluate_template(evaluate_string("{tag}_list = :a5.{tag}_enum(8)"))
    	evaluate_template(evaluate_string("save_to_file({tag}_list+crlf(),\"{sys_obj_filename}\",.t.)"))
    next
    t = table.open("enum_sys_obj",FILE_RW_EXCLUSIVE)
    t.zap(.t.)
    t.close()
    t = table.open("enum_sys_obj")
    t.Import_Ascii_Table(sys_obj_filename,0,.t.)
    DIM SHARED varC_sys_obj as C
    DIM SHARED varC_result as C
    auto_list_varC_sys_obj = table.external_record_content_get("enum_sys_obj","Object_Name","","")
    temp_count = w_count(auto_list_varC_sys_obj,crlf())
    DELETE a_varC_sys_obj
    DIM a_varC_sys_obj[temp_count] as c
    a_varC_sys_obj.initialize(auto_list_varC_sys_obj)
    heading_string = "Select Scripts to Delete"
    ok_button_label = "&OK"
    cancel_button_label = "&Cancel"
    varC_result = ui_dlg_box("Script Maintenance",<<%dlg%
    {region}
    {text=113,1:heading_string};
    {endregion};
    {region}
    | [%E%.98,25varC_sys_obj^#a_varC_sys_obj];
    {endregion};
    {line=1,0};
    {region}
    <*15=ok_button_label!OK> <15=cancel_button_label!CANCEL>
    {endregion};
    %dlg%)
    if varC_result = "ok" then
    	'
    	'delete selected scripts from dictionary file *.ddd
    	'
            '
    end if
    --
    Support your local Search and Rescue Unit, Get Lost!

    www.westrowops.co.uk

    #2
    Re: Xbasic Script Tidy-up

    http://alphafivewiki.com/Dictionary+...ns+and+Methods
    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


      #3
      Re: Xbasic Script Tidy-up

      thanks Al,

      I tried the examples in the Alphapedia, but I get as far as tbl = dictionay.open() and get error message Not Supported.

      Also, where can I find a list of all the different item names in the dictionary? (so far I have "FRMI", "QBES", "TLBR" and "Menu")
      Last edited by Graham Wickens; 01-09-2012, 08:02 AM. Reason: add question
      --
      Support your local Search and Rescue Unit, Get Lost!

      www.westrowops.co.uk

      Comment


        #4
        Re: Xbasic Script Tidy-up

        Personally, I would export all of the scripts/functions, build a new database, add the tables/sets, import the functions and scripts that you want.
        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


          #5
          Re: Xbasic Script Tidy-up

          Originally posted by Graham Wickens View Post
          thanks Al,

          I tried the examples in the Alphapedia, but I get as far as tbl = dictionay.open() and get error message Not Supported.

          Also, where can I find a list of all the different item names in the dictionary? (so far I have "FRMI", "QBES", "TLBR" and "Menu")
          1. You got the error because a table needs to be open first - ie command is run from a form...
          The instructions mention that...

          2. I haven't seen a list of those. If you find one let me know....
          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


            #6
            Re: Xbasic Script Tidy-up

            Finian Lennon generated this list.
            Code:
            FRMI	FORM
            BRW0	BROWSE
            APND	APPEND
            REP0	REPORT
            SCRP	SCRIPT
            DRUL	RULE EVENTS
            UPDT	UPDATE
            MARK	MARK
            COPY	COPY
            QBES	QUERY
            RLTN	JOIN
            POST	POST
            EXPT	EXPORT
            GPAL	GLOBAL COLORS
            MENU	MENU
            TLBR	TOOLBAR
            GUDF	UDF
            GBMP	TOOLBAR BITMAPS
            LBLI	LABEL
            SMZS	SUMMARY
            RANG	RANGE
            IMPT	IMPORT
            XTBS	XTAB
            FRUL	FIELD RULE
            SAVU	SAVED SETTINGS
            Last edited by aschone; 01-10-2012, 11:18 PM.
            Andrew

            Comment


              #7
              Re: Xbasic Script Tidy-up

              First I export only the scripts I want to have to a text file.
              Next I run the below code to delete all scripts in the database.
              Last I import the scripts I exported in the first step back into the database.

              I use this code to wipe out all scripts/udf's a database. Test, Test, Test before you use this.
              I forgot to mention that you should test this first before using it in a live database.
              Code:
              FUNCTION pf_Delete_Scripts_UDFs as L ()
              
              	pf_Delete_Scripts_UDFs = .f.
              	DIM vDbC as C
              	vDbC = a5.get_path() + chr(92) + file.filename_parse(a5.get_name(),"N")
              	
              	' Make and add new table to db
              	'ui_msg_box("pf_Delete_Scripts_UDFs()",vDbC + ".alb" + crlf() + file.exists(vDbC + ".alb") )
              	file.copy(vDbC + ".alb", vDbC + "_code.dbf")
              	file.copy(vDbC + ".alm", vDbC + "_code.fpt")
              	file.copy(vDbC + ".alx", vDbC + "_code.cdx")
              	file_add_to_db(vDbC + "_code.dbf")
              
              	' Remove scrips and UDFs
              	DIM vCodeP as P
              	DIM vFilterC
              	vCodeP = table.open(vDbC + "_code")
              	vFilterC = "type = 'scrp' .or. type = 'gudf'"
              	vCodeP.delete_range(vFilterC)
              	vCodeP.pack()
              	vCodeP.close()
              
              	' Replace al* files with new dictionary
              	file.copy(vDbC + "_code.dbf", vDbC + ".alb")
              	file.copy(vDbC + "_code.fpt", vDbC + ".alm")
              	file.copy(vDbC + "_code.cdx", vDbC + ".alx")
              
              	' Erase temp table
              	table_remove( table.actual_filename_get( vDbC + "_code" ) )
              	file_drop_from_db( table.actual_filename_get( vDbC + "_code" ) )
              	
              	pf_Delete_Scripts_UDFs = .t.
              	
              END FUNCTION
              Andrew

              Comment


                #8
                Re: Xbasic Script Tidy-up

                Thanks Finian and Andrew,

                I am indeed using a TEST database.
                --
                Support your local Search and Rescue Unit, Get Lost!

                www.westrowops.co.uk

                Comment


                  #9
                  Re: Xbasic Script Tidy-up

                  Andrew,
                  That is a very handy script I wish I had a few weeks ago! I wanted to share the same scripts and functions with several applications and so I made several databases to split up the scripts, functions and bitmaps into separate libraries, leaving only the menus and toolbars specific to the individual database apps. I put these files in a subdirectory of the A5 program files and then attached them as libraries. I can still tweak the scripts in each app or add new ones now and have the change available to all of them. Had I thought to export them all first into a text file would have made the job much easier as well.
                  Robin

                  Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

                  Comment


                    #10
                    Re: Xbasic Script Tidy-up

                    Question: Can all these TYPE codes be used to generate lists in the same way your script does? The SAVU is interesting here if it can somehow be exported and imported from one app to another.

                    Edit: Found the answer here for A5_LOAD_SETTINGS()
                    Robin

                    Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

                    Comment


                      #11
                      Re: Xbasic Script Tidy-up

                      Finian Lennon's Copy Object Utilities has the capability to transfer Saved Settings (SAVU type); I have never tested this.

                      http://msgboard.alphasoftware.com/al...ject-Utilities

                      I think you can generate lists based on the TYPE codes, but you would first have to convert the Data Dictionary to a table by changing the extensions. *Then you could open the table and see whats inside.

                      I have a junk database that I run this function from. The function will prompt the name of a table or set. Then data dictionaries will be copied to the junk database, added as a normal table and then the default browse will open showing the actual records. I found this helpful when I was trying to correct set definitions where the parent table name was changed.

                      Code:
                      'Date Created: 14-Mar-2011 04:09:43 PM
                      'Last Updated: 01-Dec-2011 10:18:34 AM
                      'Created By  : andy
                      'Updated By  : andy
                      FUNCTION f_BrwsDataDict AS C ( )
                      	
                      	OPTION STRICT
                      	OPTION ENCRYPTED_TOKENS
                      	ON ERROR GOTO ERR_HANDLER
                      	
                      	DIM vFilenameC as C
                      	DIM vTitleC as C
                      	DIM vTypeC as C
                      	DIM vDefaultC as C
                      	DIM vExistC as C
                      	vTitleC = "Data dictionary"
                      	vTypeC = "Table(*.dbf)|Set(*.set)"
                      	vDefaultC = "" 'a5.Get_Path()
                      	vExistC = "X"
                      	
                      	vFilenameC = ui_get_file(vTitleC, vTypeC, vDefaultC, vExistC)
                      	IF vFilenameC = "" THEN
                      		END
                      	ELSE
                      		'ui_msg_box("",vFilenameC)
                      	END IF
                      	
                      	DIM vDbfP as P
                      	DIM vDbfP.Orig as C
                      	DIM vDbfP.New as C
                      	
                      	DIM vFptP as P
                      	DIM vFptP.Orig as C
                      	DIM vFptP.New as C
                      	
                      	DIM vCdxP as P
                      	DIM vCdxP.Orig as C
                      	DIM vCdxP.New as C
                      	
                      	DIM vPathC as C
                      	DIM vBasenameC as C
                      	DIM vExtensionC as C
                      	vPathC = file.filename_parse(vFilenameC,"DP")
                      	vBasenameC = file.filename_parse(vFilenameC,"N")
                      	vExtensionC = file.filename_parse(vFilenameC,"E")
                      	
                      	'.ddd = .dbf
                      	'.ddm = .fpt
                      	'.ddx = .cdx
                      	
                      	'.set = .dbf
                      	'.sem = .fpt
                      	'.sex = .cdx
                      
                      	SELECT
                      		CASE vExtensionC = ".DBF"
                      			vDbfP.Orig = vPathC + vBasenameC + ".ddd"
                      			vFptP.Orig = vPathC + vBasenameC + ".ddm"
                      			vCdxP.Orig = vPathC + vBasenameC + ".ddx"
                      		CASE vExtensionC = ".SET"
                      			vDbfP.Orig = vPathC + vBasenameC + ".set"
                      			vFptP.Orig = vPathC + vBasenameC + ".sem"
                      			vCdxP.Orig = vPathC + vBasenameC + ".sex"
                      		CASE ELSE
                      			ui_msg_box("Error", "Unknown Extension" + crlf() + vExtensionC, UI_STOP_SYMBOL)
                      			END
                      	END SELECT
                      
                      	vDbfP.New = a5.get_path() + chr(92) + vBasenameC + "_Temp.dbf"
                      	vFptP.New = a5.get_path() + chr(92) + vBasenameC + "_Temp.fpt"
                      	vCdxP.New = a5.get_path() + chr(92) + vBasenameC + "_Temp.cdx"
                      
                      	'f_BrwsDataDict = vDbfP.Orig + crlf() + vDbfP.New + crlf() + vFptP.Orig + crlf() + vFptP.New + crlf() + vCdxP.Orig + crlf() + vCdxP.New
                      	
                      	file.copy(vDbfP.Orig,vDbfP.New)
                      	file.copy(vFptP.Orig,vFptP.New)
                      	file.copy(vCdxP.Orig,vCdxP.New)
                      	
                      	file_add_to_db(vDbfP.New)
                      	
                      	a5_open_default_browse(vDbfP.New)
                      	
                      	END
                      '-----------------------------------
                      'Error handler
                      '-----------------------------------
                      ERR_HANDLER:
                      	Dim err as N= error_code_get()
                      	Dim msg as C= "Error # "+ err + crlf() + error_text_get(err)
                      	msg = msg + crlf() + "Script: " + error_script_get()
                      	msg = msg + crlf() + "Line #: " + error_line_number_get()
                      
                      	trace.writeln(msg)
                      
                      	ui_msg_box("Error", msg, ui_attention_symbol)
                      	msg = ""
                      	
                      	END  
                      	
                      	
                      END FUNCTION
                      Andrew

                      Comment


                        #12
                        Re: Xbasic Script Tidy-up

                        Interesting data, but I was looking more for a way to copy the Database preference settings.
                        Robin

                        Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

                        Comment


                          #13
                          Re: Xbasic Script Tidy-up

                          I think the preferences are kept in the system registry.
                          There can be only one.

                          Comment

                          Working...
                          X