RosettaCodeData/Task/User-input-Graphical/M2000-Interpreter/user-input-graphical-2.m2000

52 lines
2.5 KiB
Plaintext

Module Checkit {
Declare Form1 Form
Declare Inp1 Textbox Form Form1
Declare Inp2 Textbox Form Form1
With Inp1, "Prompt", "String: ", "MaxCharLength", 30+8, "ShowAlways", 1, "ThisKind" as info$, "VarText" as Aname$
info$=" <write your name>"
With Inp2, "Prompt", "Integer: ", "MaxCharLength", 10+9, "VarText" as Feed$, "ThisKind"," sec", "ShowAlways", 1
feed$="0"
\\ local1, and Event service functions have module visibility.
\\ So they have to use Read New to make new references (shadow old), and use local (the same for SUBS)
\\ Event's service functions can't use parents Subs, but Local1 can be used (exist in a list visible to Events)
Function Local1 (new Feed$) {
\\ this function can be used from other Integer
\\ this$ and thispos, exist just before the call of this function
local sgn$
if feed$="" and this$="-" then thispos-- : exit
if left$(this$,1)="-" then sgn$="-": this$=mid$(this$, 2)
if this$<>Trim$(this$) then this$=Feed$ : thispos-- : exit
If Trim$(this$)="" then this$="0" : thispos=2 : exit
if instr(this$,"+")>0 and sgn$="-" then this$=filter$(this$, "+") : sgn$=""
if instr(this$,"-")>0 and sgn$="" then this$=filter$(this$, "-") : sgn$="-"
if filter$(this$,"0123456789")<>"" then this$=Feed$ : thispos-- : exit
if len(this$)>1 then While left$(this$,1)="0" {this$=mid$(this$, 2)}
this$=sgn$+this$
if this$="-0" then this$="-" : thispos=2
}
Function Inp1.ValidString {
Read New &this$
While left$(this$, 1)=" " { this$=mid$(this$, 2)}
info$=str$(30-Len(This$), "\<0\>")
}
Function Inp2.ValidString {
\\ this function called direct from textbox
Read New &this$, &thispos
Call Local local1(Feed$)
}
Function Form1.Unload {
Read New &Quit
If feed$<>"75000" Or Aname$="" then {
\\ open messagebox, pressing cancel quit Unload
Quit=Ask("Data isn't correct")=2
}
}
Method Inp1, "Move", 2000,2000, 6000, 600
Method Inp2, "Move", 2000,3000, 6000, 600
Method Form1, "Show", 1
If Feed$="75000" and Aname$<>"" Then Print "Thank You"
Declare Form1 Nothing
}
Checkit