MsgBox % SubStr("123abc789", 4, 3) ; Returns abc  ,第一个参数从第几个开始 第二个参数取多长字符串

;第二个参数:Specify 1 to start at the first character,
;			Specify 2 to start at the second,
;			Specify 0 extracts the last character , 
;			Specify  -1 extracts the two last characters 。

MsgBox % SubStr("123abc789", 1) ; Returns 123abc789 从第一个开始到结尾
MsgBox % SubStr("123abc789", 2) ; Returns 12 开头 从第二个开始到结尾
MsgBox % SubStr("123abc789", 0) ; Returns 9 尾部一个字符  
MsgBox % SubStr("123abc789",-1) ; Returns 89 尾部  两个

MsgBox % SubStr("[123abc789]", 2, -1) ; Returns 123abc789  掐头去尾



Ini2Object.ahk

Ini2Object(file)
{
	obj := {}, curSect := ""
	IfNotExist, %file%
		return
	Loop, Read, %file%
	{
		x := Trim(A_LoopReadLine), fc := SubStr(x, 1, 1)
		if !x || fc = ";"
			continue
		if fc = [
		{
			if SubStr(x, 0) != "]"
				return ; invalid
			
			curSect := SubStr(x, 2, -1)
		} else
		{
			if not p := InStr(x, "=")
				return ; invalid
			k := RTrim(SubStr(x, 1, p-1))
			v := LTrim(SubStr(x, p+1))
			obj[curSect, k] := v
		}
	}
	return obj
}