//—the DataWindow control, which is declared in the function declaration like this:
DataWindow adw_control
//The function returns –2 if the user's last entry cannot be accepted or if FindRequired returns an error. It returns –1 if an empty required column is found.
//It returns 1 if all required columns have data:
integer li_colnbr = 1
long ll_row = 1
string ls_colname, ls_textname
// Make sure the last entry is accepted
IF adw_control.AcceptText() = -1 THEN
adw_control.SetFocus()
RETURN -2
END IF
// Find the first empty row and column, if any
IF adw_control.FindRequired(Primary!, ll_row, li_colnbr, ls_colname, true) < 1 THEN
//If search fails due to error, then return
RETURN -2
END IF
// Was any row found?
IF ll_row <> 0 THEN
// Get the text of that column's label.
ls_textname = ls_colname + "_t.Text"
ls_colname = adw_control.Describe(ls_textname)
// Tell the user which column to fill in
MessageBox("Required Value Missing", "Please enter a value for '" + ls_colname + "', row " + String(ll_row) + ".", StopSign! )
// Make the problem column current.
adw_control.SetColumn(li_colnbr)
adw_control.ScrollToRow(ll_row)
adw_control.SetFocus()
RETURN -1
END IF
// Return success code if all required
// rows and columns have data
RETURN 1//The following code makes a list of all the row numbers and column names in dw_1 in which required columns are missing values.
//The list is displayed in the MultiLineEdit mle_required:
long ll_row = 1
integer colnbr = 0
string colname
mle_required.Text = ""
DO WHILE ll_row <> 0
colnbr++ // Continue searching at next column
// If there's an error, exit
IF dw_1.FindRequired(Primary!, ll_row, colnbr, colname, false) < 0 THEN EXIT
// If a row was found, save the row and column
IF ll_row <> 0 THEN
mle_required.Text = mle_required.Text + String(ll_row) + "~t" + colname + "~r~n"
END IF
// When FindRequired returns 0 (meaning
// no more rows found), drop out of loop
LOOP
Pregunto:Has marcado los campos en el DW como requerido?Si no lo has hecho, marcalo y prueba la funcion creo que asi te va a funcionaratento a tus comentarios--2012/1/12 Alberto Cuevas <betocuevas.net@gmail.com>
Amigos del estoy tratando de validar campos de un DW utilizando esta función:
http://www.lawebdelprogramador.com/foros/Power_Builder/628674-Validar_campos_vacios_en_un_datawindow.html
Pero no me valida nada.
Función:
global type f_checkrequired from function_object
end type
forward prototypes
global function integer f_checkrequired (datawindow adw_control)
end prototypes
global function integer f_checkrequired (datawindow adw_control);/////////////////////////////////////////////////////////////////
// /
// This function ensures that no required column in a /
// DataWindow control is empty (contains NULL). It takes /
// one argument: the DataWindow control. /
// /
// Return values: /
// /
// * -1 if validation fails /
// * 1 if required columns are filled in /
// /
/////////////////////////////////////////////////////////////////
integer li_colnbr = 1
long ll_row = 1
string ls_colname, ls_textname
///////////////////////////////////////////////////////////////
// /
// Make sure the last entry in the DataWindow control is /
// accepted before proceeding. /
// /
///////////////////////////////////////////////////////////////
IF adw_control.AcceptText() = -1 THEN
adw_control.SetFocus()
RETURN -1
END IF
///////////////////////////////////////////////////////////////
// /
// Now we can examine the required columns in each row of /
// the DataWindow control. /
// /
// The following function starts at row 1, column 1 in the /
// DW's primary buffer. Then it looks through each row /
// until it finds a required column that is empty. /
// /
///////////////////////////////////////////////////////////////
IF adw_control.FindRequired( primary!, ll_row, li_colnbr, &
ls_colname, true ) < 0 THEN
// If the search can't be done due to some error,
// then quit this script.
RETURN -1
END IF
///////////////////////////////////////////////////////////////
// /
// The preceding function updates the ll_row variable with /
// the number of the first row in which a required column was /
// found empty (or 0 if all rows were OK). Here's a test /
// to see if such a row was found. /
// /
///////////////////////////////////////////////////////////////
IF ll_row <> 0 THEN
// Get the text of that column's label.
ls_textname = ls_colname + "_t.Text"
ls_colname = adw_control.Describe(ls_textname)
// Tell the user which column to fill in.
MessageBox("Falta Valor Requerido","Por favor ingrese un valor para '" &
+ ls_colname +"', Fila " + string (ll_row) + ".", stopsign! )
// Make the problem column current.
adw_control.SetColumn(li_colnbr)
adw_control.ScrollToRow(ll_row)
adw_control.SetFocus()
RETURN -1
END IF
///////////////////////////////////////////////////////////////
// /
// If every column in every row checked out OK... /
// /
///////////////////////////////////////////////////////////////
RETURN 1
end function
Ing. Rafael Consuegra García
Especialista en Gerencia Financiera (FUAC)
Colombia
POSTDATA: Favor Confirmar el Recibo de este email
--
Ing. Rafael Consuegra García
Especialista en Gerencia Financiera (FUAC)
Colombia
POSTDATA: Favor Confirmar el Recibo de este email
0 comentarios:
Publicar un comentario
Nota: solo los miembros de este blog pueden publicar comentarios.