Can you help me if I can select only two digits from a 4 digits number
For example my number is 1152 I want to explain to extract only 51 in a if statement
Cspro logic
Re: Cspro logic
Hi Tsheringcee,
You can try something like:
Then you can do whatever you want with the extracted number as numeric on "my_digit" variable, or if you need it as string variable, you can use the "ls_extract" that is already as string.
Hope this could help you.
Regards.
You can try something like:
Code: Select all
string my_string, ls_extract;
numeric my_digit;
my_string = edit("9999",MY_NUMBER);
ls_extract = my_string[3:4];
my_digit = tonumber(ls_extract);
Hope this could help you.
Regards.
-
- Posts: 572
- Joined: July 9th, 2012, 11:32 am
- Location: Islamabad, Pakistan
Re: Cspro logic
Dear Tsheringcee;
Please see also this link.
http://www.csprousers.org/forum/viewtop ... umber#p835
a.
Please see also this link.
http://www.csprousers.org/forum/viewtop ... umber#p835
a.
-
- Posts: 1801
- Joined: December 5th, 2011, 11:27 pm
- Location: Washington, DC
Re: Cspro logic
If you go with the suggestion from jfigueroa, here is a comment on the logic. When extracting substrings, the second part after the colon is the number of characters requested, not the ending character. So you would write:
ls_extract = my_string[3:2];