Reading a Substring from a variable

From ArcoWiki
Revision as of 07:30, 15 June 2018 by Slia (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

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