String Issue

vikram7_dabas
Member Posts: 611
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?
Vikram Dabas
Navision Technical Consultant
Navision Technical Consultant
0
Comments
-
maybe there is someting shorter, maybe not :whistle:
IF COPYSTR(StrVar,STRLEN(StrVar)) IN ['0','1','2','3','4','5','6','7','8','9'] THEN MESSAGE('Has numeric at the end') ELSE MESSAGE('Hello world');
0 -
i:=strlen(YourCode); while YourCode[i]in['0'..'9']do begin YourNumCode:=format(YourCode[i])+YourNumCode; i-=1; end;
0 -
Int
var
integer
CodeString -- var --
codeIF (EVALUATE(Int,COPYSTR(CodeString,STRLEN(CodeString),1))) THEN MESSAGE('has an integer at last') ELSE MESSAGE('Does not have an integer at last')
Sandeep Prajapati
Technical Consultant, MS Dynamics NAV0 -
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); //**********************************************************************
0 -
vikram7_dabas wrote: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 requirementsNAV - Norton Anti Virus
ERP Consultant (not just Navision) & Navision challenger0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions