Skip to content

Commit

Permalink
Fixed IsVar
Browse files Browse the repository at this point in the history
  • Loading branch information
gentee committed Nov 12, 2020
1 parent e221809 commit 551489f
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions script/embedded.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ var (
{Prototype: `Condition(str,str) bool`, Object: Condition},
{Prototype: `File(str) str`, Object: FileLoad},
{Prototype: `Form(str)`, Object: Form},
{Prototype: `IsObjVar(str) bool`, Object: IsVarObj},
{Prototype: `IsVarObj(str) bool`, Object: IsVarObj},
{Prototype: `IsVar(str) bool`, Object: IsVar},
{Prototype: `LogOutput(int,str)`, Object: LogOutput},
{Prototype: `Macro(str) str`, Object: Macro},
Expand Down Expand Up @@ -273,7 +273,7 @@ func FileLoad(rt *vm.Runtime, fname string) (ret string, err error) {
}

func GetVar(name string) (ret string, err error) {
if IsVar(name) {
if IsVar(name) != 0 {
id := len(dataScript.Vars) - 1
ret, err = Macro(dataScript.Vars[id][name])
}
Expand Down Expand Up @@ -330,11 +330,14 @@ func InitCmd(name string, pars ...interface{}) bool {
return true
}

func IsVar(key string) bool {
func IsVar(key string) int64 {
dataScript.Mutex.Lock()
defer dataScript.Mutex.Unlock()
_, ret := dataScript.Vars[len(dataScript.Vars)-1][key]
return ret
if ret {
return 1
}
return 0
}

func loadForm(data string, form *[]map[string]interface{}) error {
Expand Down

0 comments on commit 551489f

Please sign in to comment.