//createValue will create a value struct for given key value pair.
createValue will create a value struct for given key value pair.
// createValue will create a value struct for given key value pair .
func createValue(k, v string) *value {
	var varCount, varStart, startIndex int
	val := &value{}
	if len(v) <= 3 { 
		val.content = append(val.content, v)
	} else {
		for i, c := range v {
			if c == textutils.OpenBraceChar && v[i-1] == textutils.DollarChar && v[i-2] != textutils.BackSlashChar {
				val.content = append(val.content, v[startIndex:i-1])
				varStart = i + 1
			} else if varStart > 0 && c == textutils.CloseBraceChar {
				startIndex = i + 1
				if varCount == 0 {
					val.vars = make(map[int]string)
				}
				val.vars[len(val.content)] = v[varStart:i]
				varStart = 0
				varCount++
				val.hasVars = true
			}
		}
		if varCount == 0 { 
			val.content = append(val.content, v)
		} else if varStart > 0 { 
			val.content = append(val.content, v[startIndex:])
		}
	}
	val.key = k
	return val
}
func createValue ( k , v string ) * value { var varCount , varStart , startIndex int val := & value { } if len ( v ) <= 3 { val . content = append ( val . content , v ) } else { for i , c := range v { if c == textutils . OpenBraceChar && v [ i - 1 ] == textutils . DollarChar && v [ i - 2 ] != textutils . BackSlashChar { val . content = append ( val . content , v [ startIndex : i - 1 ] ) varStart = i + 1 } else if varStart > 0 && c == textutils . CloseBraceChar { startIndex = i + 1 if varCount == 0 { val . vars = make ( map [ int ] string ) } val . vars [ len ( val . content ) ] = v [ varStart : i ] varStart = 0 varCount ++ val . hasVars = true } } if varCount == 0 { val . content = append ( val . content , v ) } else if varStart > 0 { val . content = append ( val . content , v [ startIndex : ] ) } } val . key = k return val }
createValue will create a value struct for given key value pair.
createValue will create a value struct for given key value pair .
// Min Length for variables to be present is 4 including a char for variable name //safe to check the i-1 and i-2 as the min length at this point is at-least 4 //if First variable then make map //reset varStart //increment variable counter // No variables were found // There may be existing variables but last one was identified without a end