Necesitaba extraer sólo los números contenidos en un string leído de un label escrito por otra función:
GetProperty ("Panel_Articulos", "Label_Panel_Arti_RegNo", "Value") -> Puede contener:
"Registro número: 123" o "La base de datos contiene 24518 artículos." o "Seleccionados 6 artículos."
Lo solucioné así y ya me queda la función de usuario, y la comparto.
Hello everyone !!!
I needed to extract only the numbers contained in a string read from a label written by another function:
GetProperty ("Panel_Articles", "Label_Panel_Arti_RegNo", "Value") -> May contain:
"Record number: 123" or "The database contains 24518 articles." or "Selected 6 articles."
I solved it like this, and share:
Code: Select all
LOCAL nReg := OnlyNumbers ( GetProperty ("Panel_Articulos", "Label_Panel_Arti_RegNo", "Value"))
Code: Select all
// Funcion OnlyNumbers (cString) Retorna sólo los números contenidos en la cadena
// Devuelve tipo numérico
Function OnlyNumbers (cString)
LOCAL cOut := ""
If Pcount () == 0 .OR. Empty (cString)
Return Val ("0")
EndIf
For i := 1 To HMG_Len (cString)
If Hb_UsubStr (cString, i, 1) $ "1234567890"
cOut += Hb_UsubStr (cString, i, 1)
EndIf
Next
Return Val ( AllTrim ( cOut ))