Alpha DevCon 2018
Results 1 to 25 of 25

Thread: Useful Example Using XDialog

  1. #1
    Member ChrisHawkes's Avatar
    Real Name
    Chris Hawkes
    Join Date
    Apr 2000
    Location
    Dorset, UK
    Posts
    295

    Default 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. #2
    Moderator Peter.Greulich's Avatar
    Real Name
    Peter Greulich
    Join Date
    Apr 2000
    Location
    Boston, MA
    Posts
    11,544

    Default 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...

  3. #3
    Member ChrisHawkes's Avatar
    Real Name
    Chris Hawkes
    Join Date
    Apr 2000
    Location
    Dorset, UK
    Posts
    295

    Default 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!!!

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

    Default Re: Useful Example Using XDialog

    Way cool.

    Thanks again, Chris.

    I'll try it tomorrow.

  5. #5
    Member ChrisHawkes's Avatar
    Real Name
    Chris Hawkes
    Join Date
    Apr 2000
    Location
    Dorset, UK
    Posts
    295

    Default 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!!!

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

    Default Re: Useful Example Using XDialog

    Quote 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.

  7. #7
    Member ChrisHawkes's Avatar
    Real Name
    Chris Hawkes
    Join Date
    Apr 2000
    Location
    Dorset, UK
    Posts
    295

    Default 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!!!

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

    Default Re: Useful Example Using XDialog

    Quote 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...

  9. #9
    Member ChrisHawkes's Avatar
    Real Name
    Chris Hawkes
    Join Date
    Apr 2000
    Location
    Dorset, UK
    Posts
    295

    Default 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!!!

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

    Default Re: Useful Example Using XDialog

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

  11. #11
    "Certified" Alphaholic Lance Gurd's Avatar
    Real Name
    Lance Gurd
    Join Date
    Jun 2005
    Location
    Southampton, UK
    Posts
    1,381

    Default 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.

  12. #12
    "Certified" Alphaholic Mike Wilson's Avatar
    Real Name
    mike wilson
    Join Date
    Apr 2005
    Location
    Michigan
    Posts
    4,126

    Default 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"

  13. #13
    "Certified" Alphaholic MoGrace's Avatar
    Real Name
    Robin
    Join Date
    Mar 2006
    Location
    Los Angeles
    Posts
    3,395

    Default 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

  14. #14
    "Certified" Alphaholic
    Real Name
    John Koh
    Join Date
    Jan 2004
    Location
    Maryland, USA
    Posts
    1,019

    Default 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

  15. #15
    "Certified" Alphaholic
    Real Name
    Ronald Anusiewicz
    Join Date
    Oct 2000
    Location
    Southampton, MA
    Posts
    1,489

    Default 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?

  16. #16
    "Certified" Alphaholic Mike Wilson's Avatar
    Real Name
    mike wilson
    Join Date
    Apr 2005
    Location
    Michigan
    Posts
    4,126

    Default Re: Useful Example Using XDialog

    Ron,
    I have an separate app I call shared_scripts and I place all my mainstay scripts that I use always, and then it's a simple matter of adding the library of that shared scripts to your current app.
    Mike W
    __________________________
    "I rebel in at least small things to express to the world that I have not completely surrendered"

  17. #17
    "Certified" Alphaholic MoGrace's Avatar
    Real Name
    Robin
    Join Date
    Mar 2006
    Location
    Los Angeles
    Posts
    3,395

    Default Re: Useful Example Using XDialog

    I'm working on adding a tabbed object so you can see the sets too.

    I put my shared scripts into an aex file and copy that to the addins_installed folder. The original functions in the library file can still be edited and then recompiled.
    Robin

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

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

    Default Re: Useful Example Using XDialog

    I think this thread has been hijacked.

  19. #19
    "Certified" Alphaholic MoGrace's Avatar
    Real Name
    Robin
    Join Date
    Mar 2006
    Location
    Los Angeles
    Posts
    3,395

    Default Re: Useful Example Using XDialog

    But Peter, you were the first to make changes...
    Robin

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

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

    Default Re: Useful Example Using XDialog

    Judging by your screen shot you built a completely different product, which is great. But I think it should go in its own thread.

  21. #21
    "Certified" Alphaholic MoGrace's Avatar
    Real Name
    Robin
    Join Date
    Mar 2006
    Location
    Los Angeles
    Posts
    3,395

    Default Re: Useful Example Using XDialog

    I didn't post a screenshot, and all I did was add some buttons and make it sizeable. If you want to move my posts, that's fine but the initial credit belongs to Chris.
    Robin

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

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

    Default Re: Useful Example Using XDialog

    Oh yeah, I guess you didn't. I guess I got mixed up.

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

    Default Re: Useful Example Using XDialog

    That was Jon Koh, posted his use of the code - nor sharing anything. Don't know what you call that ....so not hijacking, maybe bragging ?

  24. #24
    Moderator
    Real Name
    Alan Buchholz
    Join Date
    Oct 2000
    Location
    Delavan, Wisconsin
    Posts
    9,481

    Default Re: Useful Example Using XDialog

    Quote Originally Posted by Ray in Capetown View Post
    That was Jon Koh, posted his use of the code - nor sharing anything. Don't know what you call that ....so not hijacking, maybe bragging ?
    Or an evolving piece of software.
    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.

  25. #25
    "Certified" Alphaholic MoGrace's Avatar
    Real Name
    Robin
    Join Date
    Mar 2006
    Location
    Los Angeles
    Posts
    3,395

    Default Re: Useful Example Using XDialog

    My updated function is now posted here
    Robin

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

Similar Threads

  1. xDialog
    By johnkoh in forum Alpha Five Version 9 - Desktop Applications
    Replies: 12
    Last Post: 03-18-2009, 08:34 PM
  2. XDialog
    By tom@astrolabcix.co.uk in forum Alpha Five Version 7
    Replies: 11
    Last Post: 10-23-2006, 04:55 AM
  3. Calling a Modeless XDialog within a Modal XDialog
    By KeithW in forum Alpha Five Version 7
    Replies: 8
    Last Post: 07-16-2006, 10:18 PM
  4. xDialog
    By Terry Bryan in forum Alpha Five Version 6
    Replies: 2
    Last Post: 07-10-2005, 06:45 AM
  5. Xdialog
    By Jeff, Richards in forum Alpha Five Version 5
    Replies: 2
    Last Post: 11-01-2002, 11:45 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
  •