This function gets field name and returns its label (the text of the <field name>_t object). The label is returned without not-alphabetic symbols ("&Name:" is returned as "Name") to be ready for messages. If <field name>_t object doesn't exist (bad practice, but happens) then the function does its best to build a user-friendly label from the field's name ("first_name" ==>> "First Name").
Your application must have the functions uf_replace_all() (in the same class where you want to adduf_get_field_label() ) and IfNull() when you add this function.
/********************************************************************************************************************** Dscr: Gets field name and returns its label (the text of the "<field name>_t" object). The label is returned without not-alphabetic symbols ("&Name:" is returned as "Name") to be ready for messages. If "<field name>_t" object doesn't exist (bad practice, but happens) then the function does its best to build a user-friendly label from the field's name ("first_name" ==>> "First Name") to prevent ugly messages. *********************************************************************************************************************** Arg: adw - DataWindow to search in as_field_name *********************************************************************************************************************** Ret: string *********************************************************************************************************************** Developer: Michael Zuskin - http://linkedin.com/in/zuskin | http://code.intfast.ca/ **********************************************************************************************************************/ string ls_field_label
ls_field_label = adw.Describe(as_field_name + "_t.Text") if iin(ls_field_label, {"!", "?"}) /* there is NO text object named "<field name>_t" */ then // iin(): http://code.intfast.ca/viewtopic.php?f=4&t=6 // Try to save the situation and return something which can be used as the column's label: ls_field_label = as_field_name uf_replace_all(ref ls_field_label, "_", " ") // "first_name" ==>> "first name" // uf_replace_all(): http://code.intfast.ca/viewtopic.php?f=4&t=96 WordCap(ls_field_label) // "first name" ==>> "First Name" else // text object, named "<field name>_t", exists // Remove semicolon which exsist in many labels on free-form DW: if Right(ls_field_label, 1) = ":" then ls_field_label = Left(ls_field_label, Len(ls_field_label) - 1) // "First Name:" ==>> "First Name" end if // Remove ampersands which mark hot-key symbols, displayed to user underlined: uf_replace_all(ref ls_field_label, "&&", this.ClassName()) // save double-ampersand (which is displayed as one) from removing by next line uf_replace_all(ref ls_field_label, "&", "") uf_replace_all(ref ls_field_label, this.ClassName(), "&") // restore the saved ampersand (display it as one) // Remove other not-alphabetic symbols which can appear in the label: uf_replace_all(ref ls_field_label, "~n~r", " ") uf_replace_all(ref ls_field_label, "~r~n", " ") uf_replace_all(ref ls_field_label, "~n", " ") uf_replace_all(ref ls_field_label, "~r", " ") uf_replace_all(ref ls_field_label, "~"", "") end if