Difference between revisions of "Reading a Substring from a variable"
From ArcoWiki
(Created page with "This is used to extract a sub-string from a string.<br/> *Extracting a Feature: ::<code><span style="color: green; text-decoration: none;">$$Declaring Base Variable</span><br...") |
|||
Line 21: | Line 21: | ||
::::::<code>char_list[i]=ASSIGN/str2</code> | ::::::<code>char_list[i]=ASSIGN/str2</code> | ||
::::<code>ENDDO</code> | ::::<code>ENDDO</code> | ||
+ | |||
+ | [[Category:Dmis_Tutorial]] |
Revision as of 15:17, 4 August 2016
This is used to extract a sub-string from a string.
- Extracting a Feature:
$$Declaring Base Variable
DECL/CHAR,100,str1,str2
str1=ASSIGN/'My full String'
$$Reading the word from char #4 to char #7
str2=ASSIGN/SUBSTR(str1,4,7)
- This is used to read a string “char by char”:
$$Declaring Base Variable
DECL/CHAR,100,str1,str2,char_list[15]
DECL/INTGR,len_string,i
str1=ASSIGN/'My full String'
len_string=ASSIGN/LEN(str1)
$$Loop to read single char
DO/i,1,len_string
str2=ASSIGN/SUBSTR(str1,i,i)
char_list[i]=ASSIGN/str2
ENDDO