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

Useful Example Using XDialog

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

  • Useful Example Using XDialog

    Based on two message board threads:-

    http://msgboard.alphasoftware.com/al...ad.php?t=79608

    &

    http://msgboard.alphasoftware.com/al...ad.php?t=55813

    with code from Mike Wilson, Cal Locklin, Lenny Forziati, & Andy Dibble, here's a function which displays the field names & indexes for any selected table in a rollup/rolldown modeless xdialog - the code has just been cobbled together, but gives a useful example - Sure, it can be improved and expanded upon, but it's only an example. The juicy bit for me was Cal's addition of a check box to Mike's code in the first thread.

    Code:
    FUNCTION TablesFieldsIndexes AS C ( )
         DIM vTM AS C=""
         DIM vFM AS C=""
         DIM vIM AS C=""
         DIM tablename AS C
         DIM fieldname AS C = ""
         DIM idxname AS C = ""
         DIM dialog_box_title as C
         DIM dlg_Rolled_Down AS C
         DIM dlg_Rolled_Up AS C
         DIM event_Rolled_Up AS C
         DIM event_Rolled_Down AS C
         DIM sort_alpha AS L
     
         vTM = sortsubstr(a5.table_enum(),crlf(),"A")
         dialog_box_title = "Tables/Fields/Indexes"
     
         dlg_Rolled_Down = <<%dlg%
    {toolcaption}
    {can_exit=exit}
    {background=Pale Yellow}
    {position=remember=XD_TablesFieldsIndexes_Down}
    {font=Arial,10,b}
    {blueframe=1,1:Tables, Fields && Indexes}
    {region}
    {font=Arial,8,b} Tables: | Field Names:{font=Arial,9,n} (sort_alpha!tc_*?tablename!="")Sort Alpha{font=Arial,8,b} | Indexes:{font=Arial,10,n};
     [.25,30tablename^#vTM!tc_*] | [.30,30fieldname^#vFM!fc_*] | [.30,10idxname^#vIM!ic_*]
    {endregion};
    {condition=.t.}
    {line=1,0};
    {justify=center}<10Quit>{sp=5}<10Rollup>
    %dlg%
     
         dlg_Rolled_Up = <<%dlg%
    {can_exit=exit}
    {background=Pale Yellow}
    {position=remember=XD_TablesFieldsIndexes_Up}
    {font=Arial,8,n}
    {justify=center}
    <10,1Quit>{sp=5}<10,1Rolldown>
    %dlg%
     
         event_Rolled_Down = <<%code%
    IF left( a_dlg_button, 3 ) = "tc_"
         IF a_dlg_button = "tc_change"
              IF sort_alpha
                   vFM = sortsubstr(w_upper(lower(table.external_field_name_get(tablename))), crlf(), "a")
              ELSE
                   vFM = w_upper(lower(table.external_field_name_get(tablename,"N")))
              END IF
                   vIM = w_upper(lower(table.external_index_name_get(tablename)))
           END IF
                a_dlg_button = ""
    END IF
    IF a_dlg_button="Quit"
         ui_modeless_dlg_close("Tables/Fields/Indexes")
    END IF
    IF a_dlg_button = "Rollup"
         ui_modeless_dlg_box(dialog_box_title,dlg_Rolled_Up,event_Rolled_Up)
    END IF
    %code%
     
         event_Rolled_Up = <<%code%
    IF a_dlg_button = "Quit" 
         ui_modeless_dlg_close(dialog_box_title)
    END IF
    IF a_dlg_button = "Rolldown"
     ui_modeless_dlg_box(dialog_box_title,dlg_Rolled_Down,event_Rolled_Down)
    END IF
    %code%
     
     ui_modeless_dlg_box(dialog_box_title,dlg_Rolled_Down,event_Rolled_Down)
     
    END FUNCTION
    I've attached a import txt file of this function also.
    If It Works First Time, There's Something Wrong!!!

  • #2
    Re: Useful Example Using XDialog

    That's a great function, Chris. Thanks much!

    I made a few minor tweaks to suit my own taste, but substantively...
    • Field structure definitions have been added to the field name lookups.
    • Buttons have been added to allow one to paste in the table, field or index name into an xbasic script or the I.E.

    This effectively allows one to use this xdialog in replacement to the "insert field name" option in the code editor menu, with the benefit of having the index names right there and the rollup function to get the dialog out of the way, something not possible before. The only downside is that you have to 1st load the dialog from the I.E. interactively. If there is a way to customize the code editor toolbar or menu, let me know...

    Thanks again, Chris.

    Code:
    'Date Created: 16-May-2009 02:47:18 PM
    'Last Updated: 18-May-2009 01:33:28 PM
    'Created By  : Chris Hawkes
    'Updated By  : Peter Greulich
    
    FUNCTION f_TablesFieldsIndexes AS V ( )
    DIM vTM AS C=""
    DIM vFM AS C=""
    DIM vIM AS C=""
    DIM vTablename AS C
    DIM vFieldname AS C = ""
    DIM idxname AS C = ""
    DIM dialog_box_title as C
    DIM dlg_Rolled_Down AS C
    DIM dlg_Rolled_Up AS C
    DIM event_Rolled_Up AS C
    DIM event_Rolled_Down AS C
    DIM sort_alpha AS L
    
    vTM = sortsubstr(a5.table_enum(),crlf(),"A")
    dialog_box_title = "Tables/Fields/Indexes"
    
    dlg_Rolled_Down = <<%dlg%
    {toolcaption}
    {can_exit=exit}
    {background=Dirty White}
    {position=remember=XD_TablesFieldsIndexes_Down}
    {font=Arial,10,b}
    {blueframe=1,1:Tables, Fields && Indexes}
    {region}
    {font=Arial,8,b} Tables: | Field Names:{font=Arial,9,n} (sort_alpha!tc_*?vTablename!="")Sort Alpha{font=Arial,8,b} | Indexes:{font=Arial,10,n};
     [.25,30vTablename^#vTM!tc_*] | [.30,30vFieldname^#vFM!fc_*] | [.30,10idxname^#vIM!ic_*]
    {endregion};
    {condition=.t.}
    {line=1,0};
    {font=Arial,9}
    {justify=center}<10Table>{sp=5}<10Field>{sp=5}<10Index>{sp=5}
    {color=red}<10Close>{color=dark green}{sp=5}<10Rollup>
    %dlg%
    	
    dlg_Rolled_Up = <<%dlg%
    {can_exit=exit}
    {background=Dirty White}
    {position=remember=XD_TablesFieldsIndexes_Up}
    {font=Arial,9}
    {justify=center}
    {color=red}<10,1Close>{sp=5}{color=dark green}<10,1Rolldown>
    %dlg%
    	
    event_Rolled_Down = <<%code%
    IF left( a_dlg_button, 3 ) = "tc_"
    	IF a_dlg_button = "tc_change"
    		IF sort_alpha
    			vFM = sortsubstr(w_upper(lower(table.external_field_name_get(vTablename,"n, t, w, d  r"))), crlf(), "a")
    		ELSE
    			vFM = w_upper(lower(table.external_field_name_get(vTablename,"n, t, w, d  r")))
    		END IF
    		vIM = w_upper(lower(table.external_index_name_get(vTablename)))		
    	END IF
    	a_dlg_button = ""
    END IF
    
    IF a_dlg_button="Field"
    	:Code_Editor.activate()
    	sys_send_keys(EXTRACT_STRING(vFieldname,"",","))
    END IF
    
    IF a_dlg_button="Table"
    	:Code_Editor.activate()
    	sys_send_keys(vTablename)
    END IF
    
    IF a_dlg_button="Index"
    	:Code_Editor.activate()
    	sys_send_keys(idxname)
    END IF
    
    IF a_dlg_button="Close"
    	ui_modeless_dlg_close("Tables/Fields/Indexes")
    END IF
    
    IF a_dlg_button = "Rollup"
    	ui_modeless_dlg_box(dialog_box_title,dlg_Rolled_Up,event_Rolled_Up)
    END IF
    %code%
    	
    event_Rolled_Up = <<%code%
    IF a_dlg_button = "Close" 
    	ui_modeless_dlg_close(dialog_box_title)
    END IF
    
    IF a_dlg_button = "Rolldown"
    	ui_modeless_dlg_box(dialog_box_title,dlg_Rolled_Down,event_Rolled_Down)
    END IF
    %code%
    	
    ui_modeless_dlg_box(dialog_box_title,dlg_Rolled_Down,event_Rolled_Down)
    	
    END FUNCTION
    See attached screen shot...
    Peter
    AlphaBase Solutions, LLC

    Peter@AlphaBaseSolutions.com
    https://www.alphabasesolutions.com


    Comment


    • #3
      Re: Useful Example Using XDialog

      Hi Peter

      Wonderful addition.

      The only downside is that you have to 1st load the dialog from the I.E. interactively. If there is a way to customize the code editor toolbar or menu, let me know...
      Put this line

      {I=$a5_wrench}{DATA=!f_TablesFieldsIndexes()}Display Tables Fields Indexes

      in a text file called f_tablesfieldsindexes.code_editor and place it in the Control_Panel_Addins folder. Restart Alpha, go to the code editor, from the menu, click on the Code, Addins, Display Tables Fields Indexes menu item.

      Chris
      If It Works First Time, There's Something Wrong!!!

      Comment


      • #4
        Re: Useful Example Using XDialog

        Way cool.

        Thanks again, Chris.

        I'll try it tomorrow.
        Peter
        AlphaBase Solutions, LLC

        Peter@AlphaBaseSolutions.com
        https://www.alphabasesolutions.com


        Comment


        • #5
          Re: Useful Example Using XDialog

          Hi Peter

          I've modified the function again based on yours. This one puts in "" around the Tablename, Fieldname, & Index when the appropriate button is pressed. Also, the line in your function with the 'EXTRACT_STRING' has been changed.

          Code:
          'Date Created: 17-May-2009 11:59:43 AM
          'Last Updated: 19-May-2009 02:25:50 PM
          'Created By  : Chris Hawkes
          'Updated By  : Peter Greulich & Chris Hawkes
          FUNCTION f_TablesFieldsIndexes as L ()
           DIM vTM as C = ""
           DIM vFM as C = ""
           DIM vIM as C = ""
           DIM vTablename as C
           DIM vFieldname as C = ""
           DIM idxname as C = ""
           DIM dialog_box_title as C
           DIM dlg_Rolled_Down as C
           DIM dlg_Rolled_Up as C
           DIM event_Rolled_Up as C
           DIM event_Rolled_Down as C
           DIM sort_alpha as L
           vTM = sortsubstr(a5.table_enum(),crlf(),"A")
           dialog_box_title = "Tables/Fields/Indexes"
           dlg_Rolled_Down = <<%dlg%
          {toolcaption}
          {can_exit=exit}
          {background=Pale Yellow}
          {position=remember=XD_TablesFieldsIndexes_Down}
          {font=Arial,10,b}
          {blueframe=1,1:Tables, Fields && Indexes}
          {region}
          {font=Arial,8,b} Tables: | Field Names:{font=Arial,9,n} (sort_alpha!tc_*?vTablename!="")Sort Alpha{font=Arial,8,b} | Indexes:{font=Arial,10,n};
           [.25,30vTablename^#vTM!tc_*] | [.30,30vFieldname^#vFM!fc_*] | [.30,10idxname^#vIM!ic_*]
          {endregion};
          {condition=.t.}
          {line=1,0};
          {font=Arial,9}
          {justify=center}<10Table>{sp=5}<10Field>{sp=5}<10Index>{sp=5}
          {color=red}<10Close>{color=dark green}{sp=5}<10Rollup>
          %dlg%
           dlg_Rolled_Up = <<%dlg%
          {toolcaption}
          {can_exit=exit}
          {background=Pale Yellow}
          {position=remember=XD_TablesFieldsIndexes_Up}
          {font=Arial,9}
          {justify=center}
          {color=red}<10,1Close>{color=dark green}{sp=5}<10,1Rolldown>
          %dlg%
           event_Rolled_Down = <<%code%
          IF left(a_dlg_button,3) = "tc_"
           IF a_dlg_button = "tc_change"
            IF sort_alpha
             vFM = sortsubstr(w_upper(lower(table.external_field_name_get(vTablename,"n, t, w, d  r"))),crlf(),"a")
            ELSE
             vFM = w_upper(lower(table.external_field_name_get(vTablename,"n, t, w, d  r")))
            END IF
            vIM = w_upper(lower(table.external_index_name_get(vTablename)))  
           END IF
           a_dlg_button = ""
          END IF
          IF a_dlg_button = "Field"
           Code_Editor.activate()
           sys_send_keys(chr(34)+left(alltrim(vFieldname),at(chr(44),vFieldname,1)-1)+chr(34))
          END IF
          IF a_dlg_button = "Table"
           Code_Editor.activate()
           sys_send_keys(chr(34)+vTablename+chr(34))
          END IF
          IF a_dlg_button = "Index"
           Code_Editor.activate()
           sys_send_keys(chr(34)+idxname+chr(34))
          END IF
          IF a_dlg_button = "Close"
           ui_modeless_dlg_close("Tables/Fields/Indexes")
          END IF
          IF a_dlg_button = "Rollup"
           ui_modeless_dlg_box(dialog_box_title,dlg_Rolled_Up,event_Rolled_Up)
          END IF
          %code%
           event_Rolled_Up = <<%code%
          IF a_dlg_button = "Close"
           ui_modeless_dlg_close(dialog_box_title)
          END IF
          IF a_dlg_button = "Rolldown"
           ui_modeless_dlg_box(dialog_box_title,dlg_Rolled_Down,event_Rolled_Down)
          END IF
          %code%
           ui_modeless_dlg_box(dialog_box_title,dlg_Rolled_Down,event_Rolled_Down)
          END FUNCTION
          If It Works First Time, There's Something Wrong!!!

          Comment


          • #6
            Re: Useful Example Using XDialog

            Originally posted by ChrisHawkes View Post
            I've modified the function again based on yours. This one puts in "" around the Tablename, Fieldname, & Index when the appropriate button is pressed. Also, the line in your function with the 'EXTRACT_STRING' has been changed.
            Good. Although, I can see where you might want it either way. e.g.

            tbl = table.open("Projects")
            vID = tbl.id

            Where, in this case, the table name is in quotes, and the field name is without.
            Peter
            AlphaBase Solutions, LLC

            Peter@AlphaBaseSolutions.com
            https://www.alphabasesolutions.com


            Comment


            • #7
              Re: Useful Example Using XDialog

              Peter

              Spot on. For my own purposes I'll leave the tablename and indexname in quotes with the fieldname unquoted. Your use of the send_keys was quite inspirational - I would never have thought to do it that way - Another note in the tips book.

              Thanks
              If It Works First Time, There's Something Wrong!!!

              Comment


              • #8
                Re: Useful Example Using XDialog

                Originally posted by ChrisHawkes View Post
                Spot on. For my own purposes I'll leave the tablename and indexname in quotes with the fieldname unquoted.
                Agreed, Chris.

                Here is an updated version. I rejiggered things a bit. It now displays the index definitions + the db name in the title bar. The code for the index definition is a little crude, but I had a hard time trying to parse Get_Index_Definitions(), so I took the path of least resistance.

                Code:
                'Date Created: 16-May-2009 02:47:18 PM
                'Last Updated: 20-May-2009 03:48:28 PM
                'Created By  : Chris Hawkes
                'Updated By  : Peter Greulich
                
                FUNCTION f_TablesFieldsIndexes AS V ( )
                DIM vTM AS C=""
                DIM vFM AS C=""
                DIM vIM AS C=""
                DIM vTable AS C
                DIM vField AS C = ""
                DIM idxname AS C = ""
                DIM dialog_box_title as C
                DIM idxdef AS C = ""
                DIM vIDX AS C = ""
                DIM dlg_Rolled_Down AS C
                DIM dlg_Rolled_Up AS C
                DIM event_Rolled_Up AS C
                DIM event_Rolled_Down AS C
                DIM vSort AS L
                
                
                vTM = sortsubstr(a5.table_enum(),crlf(),"A")
                dialog_box_title = file.filename_parse(a5.Get_Name(),"n") + ": Tables/Fields/Indexes"
                
                dlg_Rolled_Down = <<%dlg%
                {toolcaption}
                {can_exit=exit}
                {background=Dirty White}
                {position=remember=XD_TablesFieldsIndexes_Down}
                {font=Arial,10,b}
                {blueframe=1,1:Tables, Fields && Indexes}
                {region}
                {font=Arial,8,b} Tables: ;
                {font=Arial,10,n}
                 [.25,30vTable^#vTM!tc_*]
                {endregion}
                {region}
                {font=Arial,8,b}
                 | Field Names:{font=Arial,9,n} (vSort!tc_*?vTable!="")Sort Alpha{font=Arial,8,b};
                {font=Arial,10,n}
                 | [.30,30vField^#vFM!fc_*]
                {endregion}
                {region}
                {font=Arial,8,b}
                 | Indexes:{font=Arial,10,n} ;
                 | [.30,10idxname^#vIM!ic_*] ;;;;;
                 | [.30,5idxdef^#idxdef]
                {endregion};
                {condition=.t.}
                {line=1,0};
                {font=Arial,9}
                {justify=center}<10Table>{sp=5}<10Field>{sp=5}<10Index>{sp=5}
                {color=red}<10Close>{color=dark green}{sp=5}<10Rollup>
                %dlg%
                
                dlg_Rolled_Up = <<%dlg%
                {can_exit=exit}
                {background=Dirty White}
                {position=remember=XD_TablesFieldsIndexes_Up}
                {font=Arial,9}
                {justify=center}
                {color=red}<10,1Close>{sp=5}{color=dark green}<10,1Rolldown>
                %dlg%
                    
                event_Rolled_Down = <<%code%
                IF a_dlg_button = "tc_change"
                    IF vSort
                        vFM = sortsubstr(w_upper(lower(table.external_field_name_get(vTable,"n, t, w, d  r"))), crlf(), "a")
                    ELSE
                        vFM = w_upper(lower(table.external_field_name_get(vTable,"n, t, w, d  r")))
                    END IF
                    vIM = w_upper(lower(table.external_index_name_get(vTable)))
                    idxdef = ""
                
                    a_dlg_button = ""
                END IF
                
                IF a_dlg_button = "ic_change"
                    t = table.open(vTable)
                    idx = t.index_primary_put(idxname)
                    vOrder = idx.order_get()
                    vFilter = idx.filter_get()
                    vFlags = idx.flags_get()
                    t.close()
                    
                    idxdef = "Order: " + vOrder + crlf() + "Filter: " + vFilter + crlf() + "Flags: " + vFlags
                    
                    a_dlg_button = ""
                END IF
                
                IF a_dlg_button="Field"
                    :Code_Editor.activate()
                    sys_send_keys(EXTRACT_STRING(vField,"",","))
                END IF
                
                IF a_dlg_button="Table"
                    :Code_Editor.activate()
                    sys_send_keys(chr(34)+vTable+chr(34))
                END IF
                
                IF a_dlg_button="Index"
                    :Code_Editor.activate()
                    sys_send_keys(chr(34)+idxname+chr(34))
                END IF
                
                IF a_dlg_button="Close"
                    ui_modeless_dlg_close(dialog_box_title)
                END IF
                
                IF a_dlg_button = "Rollup"
                    ui_modeless_dlg_box(dialog_box_title,dlg_Rolled_Up,event_Rolled_Up)
                END IF
                %code%
                    
                event_Rolled_Up = <<%code%
                IF a_dlg_button = "Close" 
                    ui_modeless_dlg_close(dialog_box_title)
                END IF
                
                IF a_dlg_button = "Rolldown"
                    ui_modeless_dlg_box(dialog_box_title,dlg_Rolled_Down,event_Rolled_Down)
                END IF
                %code%
                    
                ui_modeless_dlg_box(dialog_box_title,dlg_Rolled_Down,event_Rolled_Down)
                
                END FUNCTION
                - see attached image...
                Peter
                AlphaBase Solutions, LLC

                Peter@AlphaBaseSolutions.com
                https://www.alphabasesolutions.com


                Comment


                • #9
                  Re: Useful Example Using XDialog

                  Nice addition Peter.

                  I couldn't resist bolting on a bit more: A View Recs button, record counts, file size, and whether the table is open or not

                  Code:
                  'Date Created: 16-May-2009 02:47:18 PM
                  'Last Updated: 21-May-2009 12:49:21 AM
                  'Created By  : Chris Hawkes
                  'Updated By  : Chris Hawkes
                  'Much Improved By  : Chris Hawkes
                  '          "           : Peter Greulich
                  FUNCTION f_TablesFieldsIndexes AS V ()
                   DIM vTM as C = ""
                   DIM vFM as C = ""
                   DIM vIM as C = ""
                   DIM vTable as C
                   DIM vField as C = ""
                   DIM idxname as C = ""
                   DIM dialog_box_title as C
                   DIM idxdef as C = ""
                   DIM vIDX as C = ""
                   DIM vTabInf1 as C = ""
                   DIM vTabInf2 as C = ""
                   DIM dlg_Rolled_Down as C
                   DIM dlg_Rolled_Up as C
                   DIM event_Rolled_Up as C
                   DIM event_Rolled_Down as C
                   DIM vSort as L
                   DIM a_tbl as P
                   DIM SHARED varBrowse_layout as P
                   DIM enable_show_all as L
                   DIM t as P
                   DIM vFilter as C
                   DIM vOrder as C
                   DIM vFlags as C
                   vTM = sortsubstr(a5.table_enum(),crlf(),"A")
                   dialog_box_title = file.filename_parse(a5.Get_Name(),"n") + ": Tables/Fields/Indexes"
                   dlg_Rolled_Down = <<%dlg%
                  {toolcaption}
                  {can_exit=exit}
                  {background=Light Turquoise}
                  {position=remember=XD_TablesFieldsIndexes_Down}
                  {font=Arial,10,b}
                  {blueframe=1,1:Tables, Fields && Indexes}
                  {region}
                  {font=Arial,8,b} Tables: ;
                  {font=Arial,10,n}
                   [.25,30vTable^#vTM!tc_*]
                  {endregion}
                  {region}
                  {font=Arial,8,b}
                   | Field Names:{font=Arial,9,i} (vSort!tc_*?vTable!="")Sort Alpha{font=Arial,8,b};
                  {font=Arial,10,n}
                   | [.35,30vField^#vFM!fc_*]
                  {endregion}
                  {region}
                  {font=Arial,8,b}
                   | Indexes:{font=Arial,10,n} ;
                   | [.30,10idxname^#vIM!ic_*] ;;;;;
                   | [.30,5idxdef^#idxdef]
                  {endregion};
                  {region}
                    {text=30,2.5vTabInf1} | {text=30,2.5vTabInf2};
                   {endregion};
                  {condition=.t.}
                  {line=1,0};
                  {font=Arial,9,b}
                  {justify=center}{Color=violet}<11View Recs>{sp=4}{color=black}<11Table>{sp=4}<11Field>{sp=4}<11Index>{sp=4}
                  {color=red}<11Close>{color=dark green}{sp=4}<11Rollup>
                  %dlg%
                   dlg_Rolled_Up = <<%dlg%
                  {can_exit=exit}
                  {background=Dirty White}
                  {position=remember=XD_TablesFieldsIndexes_Up}
                  {font=Arial,9}
                  {justify=center}
                  {color=red}<10,1Close>{sp=5}{color=dark green}<10,1Rolldown>
                  %dlg%
                   event_Rolled_Down = <<%code%
                  IF a_dlg_button = "tc_change"
                   IF vSort
                    vFM = sortsubstr(w_upper(lower(table.external_field_name_get(vTable,"n, t, w, d  r"))),crlf(),"a")
                   ELSE
                    vFM = w_upper(lower(table.external_field_name_get(vTable,"n, t, w, d  r")))
                   END IF
                   vIM = w_upper(lower(table.external_index_name_get(vTable)))
                   vTabInf1 = ""
                   vTabInf2 = ""
                   a_tbl = table.open(vTable)
                   vTabInf1 = "            Records: "+alltrim(str(a_tbl.records_get()))+crlf()
                   vTabInf1 = vTabInf1+"Deleted Records: "+alltrim(str(a_tbl.records_deleted()))
                   a_tbl.close()
                   vTabInf2 = "Table Open: "+iif(table.in_use(vTable),"YES","NO")+crlf()
                   vTabInf2 = vTabInf2+"File Size: "+alltrim(str(file_get_size(dbDataPath()+"\\"+vTable+".dbf")/1024))+ " KB"
                   idxdef = ""
                   a_dlg_button = ""
                  END IF
                  IF a_dlg_button = "ic_change"
                   t = table.open(vTable)
                   idx = t.index_primary_put(idxname)
                   vOrder = idx.order_get()
                   vFilter = idx.filter_get()
                   vFlags = idx.flags_get()
                   t.close()
                   idxdef = "Order: " + vOrder + crlf() + "Filter: " + vFilter + crlf() + "Flags: " + vFlags
                   a_dlg_button = ""
                  END IF
                  IF a_dlg_button = "Field"
                   Code_Editor.activate()
                   sys_send_keys(EXTRACT_STRING(vField,"",","))
                  END IF
                  IF a_dlg_button = "Table"
                   Code_Editor.activate()
                   sys_send_keys(chr(34)+vTable+chr(34))
                  END IF
                  IF a_dlg_button = "View Recs"
                   IF is_object(varBrowse_layout) = .F.
                    query.filter = ""
                    query.order = ""
                    enable_show_all = .f.
                    varBrowse_layout = a5_open_default_Browse(vTable,query.filter,query.order,"Temporary Query","",enable_show_all)
                   END IF
                  END IF
                  IF a_dlg_button = "Index"
                   Code_Editor.activate()
                   sys_send_keys(chr(34)+idxname+chr(34))
                  END IF
                  IF a_dlg_button = "Close"
                   ui_modeless_dlg_close(dialog_box_title)
                  END IF
                  IF a_dlg_button = "Rollup"
                   ui_modeless_dlg_box(dialog_box_title,dlg_Rolled_Up,event_Rolled_Up)
                  END IF
                  %code%
                   event_Rolled_Up = <<%code%
                  IF a_dlg_button = "Close"
                   ui_modeless_dlg_close(dialog_box_title)
                  END IF
                  IF a_dlg_button = "Rolldown"
                   ui_modeless_dlg_box(dialog_box_title,dlg_Rolled_Down,event_Rolled_Down)
                  END IF
                  %code%
                   ui_modeless_dlg_box(dialog_box_title,dlg_Rolled_Down,event_Rolled_Down)
                  END FUNCTION
                  FUNCTION dbDataPath as C ()
                   IF a5.Get_Master_Path() = "" THEN
                    dbDataPath = a5.Get_Path()
                   ELSE
                    dbDataPath = a5.Get_Master_Path()
                   END IF
                  END FUNCTION
                  If It Works First Time, There's Something Wrong!!!

                  Comment


                  • #10
                    Re: Useful Example Using XDialog

                    Nice job, Chris! This has become a supremely useful little function. Thanks for your contribution and inspiration.
                    Peter
                    AlphaBase Solutions, LLC

                    Peter@AlphaBaseSolutions.com
                    https://www.alphabasesolutions.com


                    Comment


                    • #11
                      Re: Useful Example Using XDialog

                      Chris, latest additions really great. But scared me the number of tables that are opened by my main menu which has lots of dockpanels with data driven menus and other information in them. Time for a re-think, I think too much over-head there.

                      Comment


                      • #12
                        Re: Useful Example Using XDialog

                        I think for developers this is a very sweet function. I added {position=remember} to the body code to get it to open where i want it placed and this is for me now open at all time when I'm developing. Thank guys for this!
                        Mike W
                        __________________________
                        "I rebel in at least small things to express to the world that I have not completely surrendered"

                        Comment


                        • #13
                          Re: Useful Example Using XDialog

                          I made some modifications to the original function like adding a few buttons and made the xd sizeable so you could see the calc field rule definitions. Now besides viewing the default browse, you can check the indexes, update them, edit the field rules, pack the table if deleted records are found and even edit the table structure. Also you can save the info to a temp file, preview it and then optionally print it.

                          I gave the function a new name so you can import and test it.

                          CP_Info_07292016.txt
                          Robin

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

                          Comment


                          • #14
                            Re: Useful Example Using XDialog

                            Thank you for sharing. Robin,

                            I can make a better on my IDE xdialog with your codes.

                            my_A5Ide_Layout.jpg

                            Comment


                            • #15
                              Re: Useful Example Using XDialog

                              Is it possible to store this function in one place so that it's accessible to all work spaces or does the function need to be added to the code tab for each work space?
                              Alpha Anywhere v3.5
                              Version 12.3, Build 2999
                              MySql56 & DBF's

                              Alpha 4, 5, Anywhere

                              Ron Anusiewicz

                              Comment

                              Working...
                              X