DEFINE ma_variable ARRAY[100] OF
RECORD
DEFINE ma_variable ARRAY[100]
OF RECORD
componente CHAR(50),
metodo ARRAY[100] OF CHAR(50)
END
RECORD
#--------------------#
FUNCTION LBrowseEx()
#--------------------#
DEFINE l_value CHAR(50)
DEFINE l_variable CHAR(50)
DEFINE l_row SMALLINT
DEFINE l_column SMALLINT
DEFINE l_table_width SMALLINT
DEFINE l_dialog_reference VARCHAR(10)
DEFINE l_table_reference VARCHAR(10)
DEFINE l_column_reference VARCHAR(10)
# Neste exemplo será construída uma grade onde o número de colunas
# pode ser indefinido.
LET l_table_width = 0
INITIALIZE ma_variable TO NULL
LET l_dialog_reference = _ADVPL_create_component(NULL,"LDIALOG")
CALL _ADVPL_set_property(l_dialog_reference,"SIZE",650,250)
CALL _ADVPL_set_property(l_dialog_reference,"TITLE","Ex.: LBROWSEEX")
LET l_table_reference = _ADVPL_create_component(NULL,"LBROWSEEX",l_dialog_reference)
CALL _ADVPL_set_property(l_table_reference,"ENABLE",TRUE)
CALL _ADVPL_set_property(l_table_reference,"EDITABLE",TRUE)
CALL _ADVPL_set_property(l_table_reference,"ALIGN","CENTER")
LET l_column_reference = _ADVPL_create_component(NULL,"LTABLECOLUMNEX",l_table_reference)
CALL _ADVPL_set_property(l_column_reference,"ALIGN","LEFT")
CALL _ADVPL_set_property(l_column_reference,"EDITABLE",FALSE)
CALL _ADVPL_set_property(l_column_reference,"COLUMN_WIDTH",100)
CALL _ADVPL_set_property(l_column_reference,"HEADER","Componente")
CALL _ADVPL_set_property(l_column_reference,"VARIABLE","componente")
LET l_table_width = l_table_width + 100
# Cria as linhas e colunas
FOR l_row = 1 TO 10
LET l_value = "componente ",l_row USING "<<&&&"
LET ma_variable[l_row].componente = l_value
FOR l_column = 1 TO 4
LET l_value = "metodo ",l_row USING "<<&&&",":",l_column USING "<<&&&"
LET ma_variable[l_row].metodo[l_column] = l_value
IF l_row = 1 THEN
# Na varíavel, a primeira posição é o valor e a segunda é o
# cabeçalho.
LET l_value = "Método ",l_column USING "<<&&&"
LET l_variable = "metodo[",l_column USING "<<<<<","]"
LET l_column_reference = _ADVPL_create_component(NULL,"LTABLECOLUMNEX",l_table_reference)
CALL _ADVPL_set_property(l_column_reference,"ALIGN","LEFT")
CALL _ADVPL_set_property(l_column_reference,"EDITABLE",TRUE)
CALL _ADVPL_set_property(l_column_reference,"COLUMN_WIDTH",50)
CALL _ADVPL_set_property(l_column_reference,"HEADER",l_value)
CALL _ADVPL_set_property(l_column_reference,"VARIABLE",l_variable)
CALL _ADVPL_set_property(l_column_reference,"EDIT_COMPONENT","LTEXTFIELD")
CALL _ADVPL_set_property(l_column_reference,"EDIT_PROPERTY","LENGTH",20)
CALL _ADVPL_set_property(l_column_reference,"EDIT_PROPERTY","PICTURE","@&")
# Efetua a soma das colunas somente na primeira linha.
LET l_table_width = l_table_width + 50
END IF
END FOR
END FOR
# Atualiza a grade com os tamanhos de colunas corretos, linhas e variável.
CALL _ADVPL_set_property(l_table_reference,"SIZE",l_table_width,250)
CALL _ADVPL_set_property(l_table_reference,"ADJUST_COLUMNS_WIDTH")
CALL _ADVPL_set_property(l_table_reference,"SET_ROWS",ma_variable,(l_row - 1))
CALL _ADVPL_set_property(l_table_reference,"REFRESH")
CALL _ADVPL_set_property(l_dialog_reference,"MAXIMIZED",FALSE)
CALL _ADVPL_set_property(l_dialog_reference,"ACTIVATE",TRUE) END FUNCTION |