ソース<isPrime.d>
import "GUI"
import "math"
w = gui.window("IsPrime",[0,0,239,319])
menu = [
["&File",[
["E&xit", 'exit]
],
],
["&Help", [
["&Help", 'help],
"-",
["&About", 'about]
]
]
]
m = gui.menubar(w,[0,0,239,20],menu)
m.OnMenuSelect = func(item)
If item='exit Then
gui.exit()
ElseIf item='help Then
ElseIf item='about Then
gui.MsgBox(w,"isPrime ver.1.00 (C)2000,KEN.","About",Gui.mbOK + Gui.mbIconInformation )
EndIf
endfunc
l1 = gui.label(w, "Input Number!", [15,30,100,50])
e1 = gui.edit(w, "", [100,28,200,50])
b1 = gui.button(w, "Check!", [15,60,200,100])
p1 = gui.pane(w, [15,120,200,300])
p1.OnPaint=func()
p1.Pen={width:3, color:[255, 0, 0]}
p1.Font={name:"Arial", size:1000}
p1.DrawText(50,0,"?")
endfunc
p1.Repaint()
isPrime = func(x)
If x<2 Then Return false
EndIf
en=Int( math.sqrt(x) )
r=true
For i=2 To en
IF x-Int(x/i)*i=0 Then
r=false
EndIf
EndFor
If r=false Then Return false
Else Return true
EndIf
endfunc
b1.OnClick=func()
i=Int(e1.Text)
If isprime(i) Then
p1.OnPaint=func()
p1.Pen={width:3, color:[255, 0, 0]}
p1.Font={name:"Arial", size:1000}
p1.DrawText(50,0,"O")
endfunc
p1.Repaint()
Else
p1.OnPaint=func()
p1.Pen={width:3, color:[255, 0, 0]}
p1.Font={name:"Arial", size:1000}
p1.DrawText(50,0,"X")
endfunc
p1.Repaint()
EndIf
endfunc
e1.OnFocus = func()
p1.OnPaint=func()
p1.Pen={width:3, color:[255, 0, 0]}
p1.Font={name:"Arial", size:1000}
p1.DrawText(50,0,"?")
endfunc
p1.Repaint()
endfunc
gui.enter()