Lendo um Substring de uma Variável

Da wiki ArcoWiki
Ir para: navegação, pesquisa

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