Description: add value to a var (has to contain a number)
Increment "{var} '{number}
var: the var to increment
number:the amount to increment
IncrementCmd function:
func IncrementCmd(args []string) { if len(args) < 2 { fmt.Println("not enogh args for increment") return } if args[1][0] != '\'' { fmt.Println("incorecct type for incrment") } varname := args[0][1:] val, ok := state.VarStorage[varname] if !ok { fmt.Println("varname: " + varname + " was not found.") return } val = val[1:] //debug line //fmt.Printf("val = %q\n", val) //check if they can be turned into numbers current, err := strconv.Atoi(val) if err != nil { fmt.Println("variable is not a number") return } inc, err := strconv.Atoi(args[1][1:]) if err != nil { fmt.Println("increment is not a number") return } current = current + inc // converts the string into a number were 1: (as strings are arrys of chars) uis everytihng past the " and then adds it to the vars value state.VarStorage[varname] = "\"" + strconv.Itoa(current) // return to string }