GUI enabling/disabling of controls: Difference between revisions

no edit summary
(→‎{{header|Perl 6}}: Minimal fixes to make runnable)
No edit summary
Line 1,495:
 
n.b. Open stack handlers would be prudent to initialise the default value and button states if this were to be saved for standalone execution.
 
=={{header|M2000 Interpreter}}==
Normally a function can't call other except something global or something defined in function (local). Using Call Local we call functions like function's part. When an event service function called (by event), interpreter provide the same name as the module's name, where form declared, so this call is a "local call". So a second local call inside event service function,also provide same name. So global local1 called as local, so code executed as part of CheckIt (but without same "current" stack, and other specific to execution object properties). Modules, functions, threads, events are all executed on "execution objects" which carries the execution code.
 
<lang M2000 Interpreter>
\\ this is global, but call as local in events, which means with local visibility for identifiers
\\ so thispos and this$ has to exist in caller 's context
 
Function Global 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
}
Module CheckIt {
Declare form1 form
Declare textbox1 textbox form form1
Declare buttonInc Button form form1
Declare buttonDec Button form form1
Method textbox1, "move", 2000,2000,4000,600
Method buttonInc, "move", 2000,3000,2000,600
Method buttonDec, "move", 4000,3000,2000,600
With textbox1,"vartext" as textbox1.value$, "Prompt", "Value:" ', "ShowAlways", True
With buttonInc,"Caption","Increment",
With buttonDec,"Caption","Decrement","Locked", True
textbox1.value$="0"
Function controlIncDec(what$){
With buttonInc, "locked", not val(what$)<10
With buttonDec, "locked", not val(what$)>0
}
finishEnter=false
Function TextBox1.ValidString {
\\ this function called direct from textbox
Read New &this$, &thispos
Call Local local1(textbox1.value$)
Call Local controlIncDec(this$)
}
Function TextBox1.Enable {
With TextBox1, "Enabled", true
finishEnter=false
}
Function TextBox1.Disable {
With TextBox1, "Enabled", false
finishEnter=true
}
Function TextBox1.Enter {
Call Local TextBox1.Disable()
}
Function buttonInc.Click {
if not finishEnter then Call Local TextBox1.Disable()
textbox1.value$=str$(val(textbox1.value$)+1, "")
if val(textbox1.value$)=0 then Call Local TextBox1.Enable()
}
function buttonDec.Click {
if not finishEnter then Call Local TextBox1.Disable()
textbox1.value$=str$(val(textbox1.value$)-1, "")
if val(textbox1.value$)=0 then Call Local TextBox1.Enable()
}
Call Local controlIncDec(textBox1.Value$)
Method form1, "show", 1
Declare form1 nothing
}
Checkit
 
</lang>
 
 
 
 
=={{header|Maple}}==
Anonymous user