分页: 1 / 1

vim 脚本数据结构问题

发表于 : 2010-11-30 20:13
自由建客
没有指针,没有结构体,怎么搞啊?
我要一个

代码: 全选

菜单 {
	名称
	父菜单指针
	项列表指针
}

菜单项 {
	名称
	标题
	热键
	状态表达式
	操作表达式
}

typedef struct {
    String Name;
    Menu* Parent;
    MenuItem[] Item;
} Menu;

typedef struct {
    String Name;
    String Title;
    Char Key;
    String Status;
    String Opt;
} MenuItem;

//当我访问的时候
for (i=0; i<Length(MenuCurrent.Item); ++i) {
    if (key==MenuCurrent.Item[i].Key) {
        if (MenuCurrent.Item[i].Status=="Enable") {
            exit_enable=true;
            exe(MenuCurrent.Item[i].Opt);
        }
        break;
    }
}

Re: vim 脚本数据结构问题

发表于 : 2010-11-30 20:40
lilydjwg
有列表有字典你想怎么搞就怎么搞 :em02

Re: vim 脚本数据结构问题

发表于 : 2010-11-30 21:44
自由建客
for 那行没能搞懂,怎么写?

代码: 全选

	for in s:MenuCurrent.Item
		if a:key==s:MenuCurrent.Item[i].Key
			if eval(s:MenuCurrent.Item[i].Status)
				let l:enexit=1
				exe s:MenuCurrent.Item[i].Opt
			endif
			break
		endif
	endfor
	if l:enexit
		call s:MenuExit(l:encls)
	endif

Re: vim 脚本数据结构问题

发表于 : 2010-12-01 0:07
fanhe
那个.是字符串连接吧

多看看现成的plugin脚本就差不多了,我这两天为了把几个脚本搞兼容,折腾了好久

Re: vim 脚本数据结构问题

发表于 : 2010-12-01 0:35
xhy
弱类型语言要指针有什么用阿

Re: vim 脚本数据结构问题

发表于 : 2010-12-01 20:55
自由建客
不喜欢弱类型语言 :em20