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

Write Structure to File.

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

    #16
    Re: Write Structure to File.

    Keith and others:
    if you copy the attached code to a button on a form
    It will Pop up a list of tables in the database
    check to see if the directory "structures" exists
    If not it will create it
    Write the structure of the selected table to a text file.

    I put comments in the code to explain my directory structure.
    yours may be different so you might have to change the lines
    that get the paths.
    Charlie Crimmel

    Comment


      #17
      Re: Write Structure to File.

      This is a revision to the original script/function

      It now presents you with a dialog box. The Dialog box will show and alphabetized list of all the tables in the current database. You can select "ALL" which will send the table strutures to text file in the same folder as the database, or you can select each individual table you would want to send to a text file.

      FWIW

      Tom Baker
      Last edited by Tbaker; 09-12-2010, 11:42 AM. Reason: Wrong attachment uploaded - new one is here and in post #19

      Comment


        #18
        Re: Write Structure to File.

        Hi Tom,

        This is very neat.

        What is the extra line needed to show the decimal value?
        Regards
        Keith Hubert
        Alpha Guild Member
        London.
        KHDB Management Systems
        Skype = keith.hubert


        For your day-to-day Needs, you Need an Alpha Database!

        Comment


          #19
          Re: Write Structure to File.

          Keith

          Here is the revised script

          This is the one that should have gone out

          It has the decimal in this one.

          Sorry

          Tom Baker

          Comment


            #20
            Re: Write Structure to File.

            Here's my take on it...

            I used the original f_TablesFieldsIndexes function (now called f_TablesFieldsIndexesDoc) and added Documentation. You'll need to create a table (didnt' want to do this automatically - but it can be added) named tbltabledefs with a structure of

            fldname
            fldtype
            fldwidth
            flddecimal
            fldrules

            The function will write out the currently selected table structure to tbltabledefs. If there's data in tbltabledefs then it will ask to clear it.

            After the selected table's structure is written out to tbltabledefs you can create a report.

            I'm changing it a bit further to add a key to handle the structure for multiple tables.

            Comment


              #21
              Re: Write Structure to File.

              And I'll add my changes to Charlies code too...

              Comment


                #22
                Re: Write Structure to File.

                I added some features to Tom's Dump_tbl_structure function.

                The main changes are:
                - Ability to select from a list of tables if none is given. (Can double click the table name.)
                - Ability to output with tabs as separators so output can be cut and pasted into another table in design mode.
                - Added decimal values.
                - Automatically open the result file in whatever application is used to open .txt files. (I recommend WordPad or Notepad but quite often Word sets itself up as the default.)

                Code:
                'Date Created: 11-Sep-2010 03:48:00 PM
                'Last Updated: 12-Sep-2010 12:44:08 PM
                'Created By  : Tom Baker
                'Updated By  : Cal Locklin
                 
                FUNCTION Dump_tbl_structure as L ( Tablename="" as C, Format_for_pasting=.F. as L )
                 
                    DIM base_name as C
                    DIM dlg_text as C
                    DIM format_for_pasting as L
                    DIM hdr_txt as C
                    DIM msg as C
                    DIM ok_pressed as L
                    DIM padout as N
                    DIM struct as C
                    DIM tbl as P
                    DIM tbl as P
                    DIM tlist as C
                    DIM txt_file as C
                 
                    IF Tablename = ""
                        'Show list of ALL tables in the .adb folder - in the control panel or not.
                        'tlist = filefind.get( a5.Get_Path() + "\*.dbf", FILE_FIND_NOT_DIRECTORY, "n" )
                        'Show list of all tables in the control panel:
                        'Since they are in the Control Panel, table.open() works even if they are in a different folder.
                        tlist = A5.Table_Enum()
                        ok_pressed = .F.
                        dlg_text = <<%dlg%
                {ysize=.3}{units=F}{font=Arial,9,n}{sp};
                (Format_for_pasting){font=Arial,9,b}Format for pasting into design mode.{font=Arial,9,n}{sp}{sp}<%I=$$generic.help;B=N%Help>;
                {stretch=height,width}[.80,15tablename^#tlist!tch_*];
                {stickto=bottom,center}
                {sp};
                {justify=center}<*15OK> <15Cancel>
                {comment Putting "Format_for_pasting" in a second time and hiding it was the only way I could get the pasting to work when using double click}
                {condition=1=2}(Format_for_pasting)
                %dlg%
                 
                        DIM dlg_result as C
                        dlg_result = ui_dlg_box( "SELECT TABLE", dlg_text, <<%code%
                IF left( a_dlg_button, 4 ) = "tch_"
                    IF a_dlg_button = "tch_dblclick"
                        ok_pressed = .T.
                    ELSE
                        a_dlg_button = ""
                    END IF
                ELSEIF a_dlg_button = "Help"
                    msg = "This creates an output format that may not look as good in the printout "
                    msg = msg + "but any field(s) can be cut and pasted into the table design mode." + crlf(2)
                    msg = msg + "This can be handy for copying standard fields such as create and "
                    msg = msg + "change dates or address fields to other tables."
                    ui_msg_box( "INSTRUCTIONS", msg, ui_information_symbol )
                    a_dlg_button = ""
                ELSEIF a_dlg_button = "OK"
                    IF tablename = ""
                        msg = "Please select a table or press 'Cancel' to quit."
                        ui_msg_box( "SELECTION REQUIRED", msg, ui_attention_symbol )
                        a_dlg_button = ""
                    ELSE
                        ok_pressed = .T.
                    END IF
                END IF
                %code% )
                 
                       IF .not. ok_pressed
                            END'
                        END IF
                        base_name = Tablename
                 
                    END IF
                 
                    'If Tablename includes the path (JIC), get the "base_name" for display.
                    base_name = file.filename_parse( Tablename, "N" )
                 
                    hdr_txt = upper( base_name ) + " -> Table Structure" + crlf() + chr_multi( 45, 45 ) + crlf(2)
                 
                    txt_file = base_name + "_tbl_structure.txt"
                 
                    tbl = table.open( Tablename )
                    struct = tbl.Field_Info_Dump( "n,t,W,D" )
                    tbl.close()
                 
                    IF .not. format_for_pasting
                        DIM foo as C
                        DIM new_struct as C
                        DIM n1 as C
                        DIM n2 as C
                        DIM n3 as C
                        DIM n4 as C
                        new_struct = ""    'FYI
                        FOR EACH foo in struct
                            n1 = word( foo.value, 1, "," )
                            padout = 20 - len( n1 )
                            n1 = n1 + space( padout )
                            n2 = word( foo.value, 2, "," ) + space(2)
                            n3 = word( foo.value, 3, "," )
                            n4 = space(4) + word( foo.value, 4, "," )
                            SELECT                        'this allow for space for the length of the type field from 1 to 3 spaces
                                CASE len( n3 ) = 1
                                    n3 = space(2) + n3
                                CASE len( n3 ) = 2
                                    n3 = space(1) + n3
                                CASE ELSE
                                    n3 = n3
                            END SELECT
                            new_struct = new_struct + n1 + n2 + n3 + n4 + crlf()
                        NEXT
                        struct = new_struct
                    ELSE    'use tabs so field info can be cut and pasted to the table design mode.
                        struct = stritran( struct, ",", chr(9) )
                    END IF
                 
                    save_to_file( hdr_txt + struct, txt_file )
                    sys_open( txt_file )
                 
                END FUNCTION
                 
                dump_tbl_structure()
                NOTES:
                - The dump_tbl_structure() call at the end just allows you to test it in the code editor.
                - The second (Format_for_pasting) that is at the end of the "dlg_text" and hidden using "condition=1=2" (which is usually false:D) is there only because the value of Format_for_pasting always ended up false, even though the box remained checked, whenever a double click was used to select the table. After much trial and error, the only solution I could find was to add a second (Format_for_pasting). (Sometimes ya just have to do what works!:()
                Last edited by CALocklin; 09-12-2010, 01:30 PM.

                Comment


                  #23
                  Re: Write Structure to File.

                  Cal is there anyway that the list of DBFs are sorted alphabetically? Is there anyway to allow someone to dump to txt for all vs each one? This is a beauty!!!!! thanks.

                  Comment


                    #24
                    Re: Write Structure to File.

                    Holy cow! I don't even remember doing that. Of course, it was 7 years ago.

                    If you want the list sorted, just add this after the line "tlist = A5.Table_Enum()":

                    tlist = sortsubstr( tlist )

                    or ... change the line to:

                    tlist = sortsubstr( A5.Table_Enum() )

                    Hmmm, I didn't check this so I don't recall if the A5.Table_Enum() function returns the whole path or not. I don't think it does unless the table is not in the same folder as the application (.adb) file but I'm not sure.

                    As for dumping all to a text file, it could be done but would involve more time to add a loop and the appropriate prompts, checks, and logic to handle it all.

                    Comment


                      #25
                      Re: Write Structure to File.

                      thanks for the quick reply.....tried the sort and got this error...

                      sort error.jpg

                      Comment


                        #26
                        Re: Write Structure to File.

                        should have mentioned the DBF's are in same folder as the ADB

                        Comment


                          #27
                          Re: Write Structure to File.

                          tlist = sortsubstr( A5.Table_Enum() ,crlf())
                          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


                            #28
                            Re: Write Structure to File.

                            That did the trick....thanks. Al & Cal, both first rate!!!! You make this one of the best MB on the net.

                            Comment


                              #29
                              Re: Write Structure to File.

                              Thanks for showing that correction Al. I swear there's a missing spot somewhere in my memory. I forget to add that delimiter about 80% of the time when I use that sortsubstr() function - and I've used it quite a bit. I guess it just seems like something that should have a default.

                              Comment


                                #30
                                Re: Write Structure to File.

                                It's the same affliction I have - CRS - Can't Remember Stuff

                                Thank goodness it's in the documentation.
                                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

                                Working...
                                X