In a related project to my previous post 'Time Conversion', I am trying to parse the "DialedNumber" field, which can range from 12 characters to 3 characters. I am using the LONG() function to determine the string length. Below is my TI code:
IF(LONG(DialedNumber)=12);
NumberDialed='(' | subst(DialedNumber,2,3) | ') ' | subst(DialedNumber,6,3) | ' - ' | subst(DialedNumber,9,4);
ELSE;
IF(LONG(DialedNumber)=8);
NumberDialed=subst(DialedNumber,2,3) | ' - ' | subst(DialedNumber,5,4);
ELSE;
NumberDialed=DialedNumber;
ENDIF;
I'm sure there's probably a better way to do this (when I evaluate the code, I get an error message stating the following:)
Line 8: END OR ENDIF statement missing.
I'm also sure that my mistake is something that is something simple that I'm overlooking.
If anybody has a spare minute that they can take a look at the code and let me know if they have any suggestions, I would appreciate that. Thank you!
Parsing Strings of Variable Length
-
- Posts: 58
- Joined: Wed Nov 26, 2008 10:21 pm
- OLAP Product: OlapObjects Publisher 5.0
- Version: 9.5.1
- Excel Version: 2003
Parsing Strings of Variable Length
Richard Lee
Financial Systems Analyst
City of Millbrae
Financial Systems Analyst
City of Millbrae
-
- Site Admin
- Posts: 6647
- Joined: Sun May 11, 2008 2:30 am
- OLAP Product: TM1
- Version: PA2.0.9.18 Classic NO PAW!
- Excel Version: 2013 and Office 365
- Location: Sydney, Australia
- Contact:
Re: Parsing Strings of Variable Length
Tryshinymcshires wrote:In a related project to my previous post 'Time Conversion', I am trying to parse the "DialedNumber" field, which can range from 12 characters to 3 characters. I am using the LONG() function to determine the string length. Below is my TI code:
IF(LONG(DialedNumber)=12);
NumberDialed='(' | subst(DialedNumber,2,3) | ') ' | subst(DialedNumber,6,3) | ' - ' | subst(DialedNumber,9,4);
ELSE;
IF(LONG(DialedNumber)=8);
NumberDialed=subst(DialedNumber,2,3) | ' - ' | subst(DialedNumber,5,4);
ELSE;
NumberDialed=DialedNumber;
ENDIF;
I'm sure there's probably a better way to do this (when I evaluate the code, I get an error message stating the following:)
Line 8: END OR ENDIF statement missing.
I'm also sure that my mistake is something that is something simple that I'm overlooking.
If anybody has a spare minute that they can take a look at the code and let me know if they have any suggestions, I would appreciate that. Thank you!
Code: Select all
IF(LONG(DialedNumber)=12);
NumberDialed='(' | subst(DialedNumber,2,3) | ') ' | subst(DialedNumber,6,3) | ' - ' | subst(DialedNumber,9,4);
ELSEIF(LONG(DialedNumber)=8);
NumberDialed=subst(DialedNumber,2,3) | ' - ' | subst(DialedNumber,5,4);
ELSE;
NumberDialed=DialedNumber;
ENDIF;
"To them, equipment failure is terrifying. To me, it’s 'Tuesday.' "
-----------
Before posting, please check the documentation, the FAQ, the Search function and FOR THE LOVE OF GLUB the Request Guidelines.
-----------
Before posting, please check the documentation, the FAQ, the Search function and FOR THE LOVE OF GLUB the Request Guidelines.
-
- Posts: 58
- Joined: Wed Nov 26, 2008 10:21 pm
- OLAP Product: OlapObjects Publisher 5.0
- Version: 9.5.1
- Excel Version: 2003
Re: Parsing Strings of Variable Length
Alan-
Looks like I owe you two lunches. My gratitude for your quick and accurate responses! That worked perfectly! Thank you!
Looks like I owe you two lunches. My gratitude for your quick and accurate responses! That worked perfectly! Thank you!
Richard Lee
Financial Systems Analyst
City of Millbrae
Financial Systems Analyst
City of Millbrae