妹子准备开学了,叫我写个点名软件,用来抽学生回答问题。说起来自己都有点罪恶感,自己上学时最烦被点到名字做题啦,回答问题啦,经常被老师鄙视。
那做就做咯,但是我从来没搞过桌面开发额,虽说主业也搞的不咋地,这个方面确实完全不会。其实吧我想,这个东西没啥意思啊,用个数组放一放,随机数做index,然后取一取咯,但是GUI我觉得好麻烦的,印象停留在java课上用swing写界面的感觉。
想着就这么个东西,不想用java了,vb,c#之类的我也不会啊,于是乎我发现了这货。Small Basic
http://www.oschina.net/p/smallbasic
据说是一款儿童编程语言,儿童就儿童了,能完成任务就ok了。
其实一进去就感觉不错,很有爱的界面,果然儿童向。而且,语法提示很完全,边栏还有各个函数的解释,参数返回值的解释,应该说上手很快呀,都不需要什么文档了,当然本身也没什么东西。然后我就在那边瞎摸索,捣鼓半天终于写了个能用的东西。
GraphicsWindow.Show()
GraphicsWindow.CanResize=0
GraphicsWindow.Width=400
GraphicsWindow.Height=400
GraphicsWindow.Title="小林老师点名"
GraphicsWindow.FontSize = 64
GraphicsWindow.MouseDown = MouseDownEvent
GraphicsWindow.MouseUp = MouseUpEvent
Path = Program.Directory
pic = ImageList.LoadImage(Path + "\finger.png")
GraphicsWindow.DrawResizedImage(pic,100,50,200,200)
Path = Program.Directory
pic = ImageList.LoadImage(Path + "\student.png")
GraphicsWindow.DrawResizedImage(pic,30,300,80,80)
name="sample"
i=1
While (name <> "")
name = File.ReadLine("nameList",i)
'TextWindow.WriteLine(i)
If (name <> "") Then
nameArray[i]=name
i=i+1
Endif
EndWhile
stuNum = Array.GetItemCount(nameArray)
stuNumCalled = 0
Sub MouseDownEvent
MX = GraphicsWindow.MouseX
MY = GraphicsWindow.MouseY
If(MX>100 And MX<300 And MY >50 And MY<250) Then
pic = ImageList.LoadImage(Path + "\finger_n.png")
GraphicsWindow.DrawResizedImage(pic,100,50,200,200)
EndIf
EndSub
Sub MouseUpEvent
MX = GraphicsWindow.MouseX
MY = GraphicsWindow.MouseY
If(MX>100 And MX<300 And MY >50 And MY<250) Then
GraphicsWindow.Clear()
pic = ImageList.LoadImage(Path + "\finger.png")
GraphicsWindow.DrawResizedImage(pic,100,50,200,200)
pic = ImageList.LoadImage(Path + "\student.png")
GraphicsWindow.DrawResizedImage(pic,30,300,80,80)
start:
index = Math.GetRandomNumber(stuNum)
If (nameArray[index]<>"") Then
GraphicsWindow.DrawText(130,300,nameArray[index])
nameArray[index]=""
stuNumCalled=stuNumCalled+1
ElseIf (stuNumCalled <> stuNum) Then
Goto start
Else
GraphicsWindow.DrawText(150,300,"End")
EndIf
EndIf
EndSub
最后就是这样啦,按一下就随机出现个名字,符合需求了,可以交差了~
其实还真个是挺有趣的东西。