diff --git a/cast.go b/cast.go new file mode 100644 index 0000000..cbcb978 --- /dev/null +++ b/cast.go @@ -0,0 +1,17 @@ +package main + +import "fmt" +import "strconv" +import "reflect" + +func pint64(a string) int64 { + i, err := strconv.ParseInt(a, 10, 64) // use base 10 for sanity + + if err != nil { + fmt.Println(err) + return 0 + } + + fmt.Printf("The type of sixtyFour is %v \n", reflect.TypeOf(i)) + return i +} diff --git a/main.go b/main.go index c208ea1..757a16d 100644 --- a/main.go +++ b/main.go @@ -213,8 +213,25 @@ func mainMouseClick(b *gui.ButtonMap) { log.Println("\tTRY TO ADD A NEW VIRTUAL MACHINE") log.Println("\tTRIGGER CREATE VM") gui.Data.State = "CREATE" - log.Println("\tTRIGGERING CREATE") event := pb.MakeAddVmEvent() + for key, entry := range gui.Data.AllEntries { + log.Println("\tdefaultEntryChange() Data.AllEntries =", key, entry) + log.Println("\tdefaultEntryChange() Data.AllEntries[key].Action =", entry.Action) + if (entry.Action == "Hostname") { + event.Vms[0].Hostname = entry.E.Text() + } + if (entry.Action == "Memory") { + event.Vms[0].Memory = pint64(entry.E.Text()) + } + log.Println("\tdefaultEntryChange() Data.AllEntries[key].E =", entry.E.Text()) + log.Println("\tdefaultEntryChange() Data.AllEntries[key].B =", entry.B) + if entry.B == b { + log.Println("defaultEntryChange() FOUND. Entry assigned to Button", b) + } + } + event.Account = b.Account + log.Println("\tTRIGGERING CREATE event=", event) + log.Println("\tTRIGGERING CREATE event.Account=", event.Account) prepareAndSend(event) } else if (b.Action == "CONFIG") { loadDefaultConfig()