I have created one variable of Data Type Code and Length 20,I want to know that whther in the end of this string any numeric value consist or not.Is it possible?If yes then How can I do this?
I haven't tested this function yet but it should do the trick with whichever way you choose to implement.
GetEndStrNum(StrVar : Text[1024];VAR EndNumVar : Integer) : Boolean
CLEAR(EndNumVar); //Prevent any mistake with a possible, previously, stored value
StrVarClean := DELCHR(DELCHR(StrVar,'<'),'>'); //Remove any trailing spaces
StrLenVar := STRLEN(StrVarClean);
IF StrLenVar = 0 THEN
EXIT(FALSE);
//****Use this if you know your strings will have a SINGLE digit end****
IF StrVarClean[StrLenVar] IN ['0'..'9'] THEN BEGIN
EndNumVar := (StrVarClean[StrLenVar] - 48);
EXIT(TRUE);
END ELSE
EXIT(FALSE);
//**********************************************************************
//***And this if you know your strings can contain MULTI-digit ending***
FOR i := StrLenVar DOWNTO 1 DO
IF NOT (StrVarClean[i] IN ['0'..'9']) THEN
IF EVALUATE(EndNumVar, DELSTR(StrVarClean, 1, i)) THEN
EXIT(TRUE)
ELSE
EXIT(FALSE);
//**********************************************************************
I have created one variable of Data Type Code and Length 20,I want to know that whther in the end of this string any numeric value consist or not.Is it possible?If yes then How can I do this?
Try this:
MESSAGE ('End of String is numeric? ' + FORMAT (Variable[STRLEN (Variable)] IN ));
Think the shortest coding so far & fits the exact requirements
NAV - Norton Anti Virus
ERP Consultant (not just Navision) & Navision challenger
Comments
var
integer
CodeString -- var --
code
Technical Consultant, MS Dynamics NAV
Try this:
MESSAGE ('End of String is numeric? ' + FORMAT (Variable[STRLEN (Variable)] IN ));
Think the shortest coding so far & fits the exact requirements
ERP Consultant (not just Navision) & Navision challenger