Convert String

omyvadiya
Member Posts: 124
Hi,
How can i convert a dynamic string For Eg: A3BC TO ABBBC, 2A3B TO AABBB?
Thnx
How can i convert a dynamic string For Eg: A3BC TO ABBBC, 2A3B TO AABBB?
Thnx
0
Comments
-
With just NAV it will be a lot of C/AL coding, but you can look at the DotNet string object and use all the C# string conversion tools, maybe that will help.0
-
Hi Omy ,
As per the example provided by you , You can try the below mentioned code.OutputText:=''; i:=0; REPEAT i:=i+1; IF EVALUATE(Char1,COPYSTR(InputText,i,1)) THEN; j := Char1; IF ((j>=48) AND (j<=57)) THEN BEGIN IF EVALUATE(j,FORMAT(Char1)) THEN; REPEAT IF EVALUATE(Char2,COPYSTR(InputText,i+1,1))THEN; OutputText:=OutputText+FORMAT(Char2); j:=j-1; UNTIL j=1; END ELSE OutputText:=OutputText+FORMAT(Char1); UNTIL (i=STRLEN(InputText));
i,j are integers
Char1,Char2 are Characters
InputText and Output Text are Text variablesThanks and Regards
Rishi0 -
Thnx Rishi, it worked...
although i tried the below code: but didn'tworked:
Procedure Replace (stOrig : Text[250];stOld : Text[250];stNew : Text[250]) : Text[250]
IF stNew = stOld THEN
EXIT(stOrig);
i := 1;
len := STRLEN(stOrig);
len2 := STRLEN(stOld);
REPEAT
IF COPYSTR(stOrig,i,1) = COPYSTR(stOld,1,1) THEN
BEGIN
IF COPYSTR(stOrig,i,len2) = stOld THEN
BEGIN
st := st + stNew;
i := i + len2-1;
END
ELSE
st := st + COPYSTR(stOrig,i,1);
END
ELSE
st := st + COPYSTR(stOrig,i,1);
i := i + 1;
UNTIL i = len+1;
EXIT(st);0 -
Can you please tell me how would you call the function as you have taken 3 parameters.Thanks and Regards
Rishi0 -
By using a DotNET String object as variable in NAV the whole thing would look like:
dotNetString := dotNetString.Replace(navStr1,navStr2);
Variables:
Name DataType Subtype Length
dotNetString DotNet System.String.'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
navStr1 Text
navStr2 TextThomas Martin
NAV Developer0 -
thank you for this, this was a great way to replace " with IN (inch) in an export.thmartin wrote:By using a DotNET String object as variable in NAV the whole thing would look like:
dotNetString := dotNetString.Replace(navStr1,navStr2);
Variables:
Name DataType Subtype Length
dotNetString DotNet System.String.'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
navStr1 Text
navStr2 Textkind of fell into this...0
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