随机点名器(刚开始)请大佬指点
import win.ui;import console;
/*DSG{{*/
winform = win.form(text="随机点名器";right=799;bottom=449)
winform.add(
btnOpen={cls="button";text="打开文件";left=363;top=199;right=463;bottom=249;z=3};
btnPointName={cls="button";text="点名";left=174;top=199;right=274;bottom=249;z=2};
姓名={cls="static";left=278;top=47;right=548;bottom=147;align="center";border=1;center=1;color=255;font=LOGFONT(h=-64;name='楷体');notify=1;transparent=1;z=1}
)
/*}}*/
winform.姓名.text = "会是谁?"
winform.btnPointName.disabled = true;
import fsys.dlg;
winform.btnOpen.oncommand = function(id,event){
var path = fsys.dlg.open("文本文件|*.txt","请选择学生名单文件",,winform);
if( path ){
var 全体姓名 = string.load(path);
姓名列表 = string.split(全体姓名,'<\r\n>');
winform.btnPointName.disabled = false;
}
}
/*
if( 姓名列表 != null ){
winform.btnPointName.disabled = false;
}
else{
winform.btnPointName.disabled = true;
}*/
//创建定时器
import win.timer;
var 定时器 = win.timer(winform);
定时器.onTimer = function(){
幸运数字 = math.random(1,#姓名列表);
winform.姓名.text = 姓名列表[幸运数字];
}
//点名的开关
var flag = true;
winform.btnPointName.oncommand = function(id,event){
if( flag ){
定时器.enable(10);
flag = false;
}
else{
定时器.disable();
flag = true;
if( #姓名列表 != 1 ){
table.remove(姓名列表,幸运数字);
//console.print("现在还剩"+#姓名列表+"人")
}
}
}
winform.show();
win.loopMessage();
页:
[1]