|
|
def
SkipValidation1=True,
SkipValidation2=True
declare
Convertion form
declare
TEXTBOX1 TEXTBOX form
Convertion
declare
COMBO1 COMBOBOX form
Convertion
declare
TEXTBOX2 TEXTBOX form
Convertion
declare
COMBO2 COMBOBOX form
Convertion
layer
Convertion {
LineSpace
60
window
10, 12000, 5000;
Cls
1, 0
gradient
#aa9933,1
totalwidth=scale.x
}
boxwidth=totalwidth-2000
method
TEXTBOX1,
"MOVE",
1000, 1000, boxwidth
method
COMBO1,
"MOVE",
1000, 1800, boxwidth
method
TEXTBOX2,
"MOVE",
1000, 2600, boxwidth
method
COMBO2,
"MOVE",
1000, 3400, boxwidth
with
Convertion,
"TITLE",
"M2000 Example: Converter "
\\
ADJUST PROPERTIES FOR CONTROLS
\\
FROM SOME PROPERTIES WE WANT SOME IDENTIFIERS TO BOUND
TO
with
COMBO1,
"EDIT",
false,"UseOnlyTheList",
true,"ShowAlways",
false
with
COMBO1,
"ListText" as
ITEM1$,
"Text" as
COMBO1$,
"label","Units:"
ITEM1$={Centimeters
Meters
Kilometers
}
COMBO1$="Meters"
with
COMBO2,
"EDIT",
false,"UseOnlyTheList",
true,"ShowAlways",
false
with
COMBO2,
"ListText" as
ITEM2$,
"Text" as
COMBO2$,
"label","Units:"
ITEM2$={Inches
Feet
Yards
Miles
}
COMBO2$="Yards"
with
TEXTBOX1,
"Prompt",
"Metric: ",
"VarText" as
textbox1.value$
with
TEXTBOX1,
"ThisKind" as
TK1$,"ShowAlways",
true
TK1$="
"+Metric.GetSmall$(COMBO1$)
textbox1.value$="0"
with
TEXTBOX2,
"Prompt",
"U.S.: ",
"VarText" as
textbox2.value$
with
TEXTBOX2,
"ThisKind" as
TK2$,"ShowAlways",
true
TK2$="
"+US.GetSmall$(COMBO2$)
textbox2.value$="0"
const
fstr$="{0}
<=> {1}"
caption$=format$(fstr$,
combo1$,
combo2$)
FromText1=Metric.ConvertFunc(Combo1$,
US(combo2$))
FromText2=US.ConvertFunc(Combo2$,
Metric(combo1$))
Function
Local2(new
Feed$,
z)
{
\\
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
Z<>0
then
FEED$=this$:
INSERT Z FEED$=de$:
this$=FEED$:
thispos++
if
this$="-0"
then
this$="-" :
thispos=2
}
Function TextBox1.ValidString {
\\
this Function called direct from textbox
read
new &this$,
&thispos
if
SkipValidation1 then
exit function
local
de$=locale$(14)
this$=replace$(de$,
".",
this$)
local
Z=INSTR(this$,"."),
K$
if
Z>0
then
K$=FILTER$(this$,
".")
if
LEN(K$)+2<LEN(textbox1.value$)
then
this$=textbox1.value$
this$=replace$(de$,
".",
this$)
Z=INSTR(this$,
".")
K$=FILTER$(this$,
".")
END
if
if
z>0
then
thispos--
this$=K$
End
if
call
local local2(textbox1.value$,
Z)
}
Function TextBox2.ValidString {
\\
this Function called direct from textbox
read
new &this$,
&thispos
if
SkipValidation2 then
exit function
local
de$=locale$(14)
this$=replace$(de$,
".",
this$)
local
Z=INSTR(this$,
"."),
K$
if
Z>0
then
K$=FILTER$(this$,
".")
if
LEN(K$)+2<LEN(textbox2.value$)
then
this$=textbox2.value$
this$=replace$(de$,
".",
this$)
Z=INSTR(this$,
de$)
K$=FILTER$(this$,
de$)
END
if
if
z>0
then
thispos--
this$=K$
End
if
call
local local2(textbox2.value$,
Z)
}
Function
Combo1.dblclick
{
caption$=format$(fstr$,combo1$,
combo2$)
FromText1=Metric.ConvertFunc(Combo1$,
US(combo2$))
FromText2=US.ConvertFunc(Combo2$,
Metric(combo1$))
call
local TextBox2.Enter()
TK1$="
"+Metric.GetSmall$(COMBO1$)
method
Convertion,
"refreshall"
}
Function
Combo2.dblclick
{
caption$=format$(fstr$,
combo1$,
combo2$)
FromText1=Metric.ConvertFunc(Combo1$,
US(combo2$))
FromText2=US.ConvertFunc(Combo2$,
Metric(combo1$))
call
local TextBox1.Enter()
TK2$="
"+US.GetSmall$(COMBO2$)
method
Convertion,
"refreshall"
}
Function
TextBox1.Enter
{
SkipValidation2~
textbox2.value$=str$(Fromtext1(val(textbox1.value$,
locale$(14))),"")
SkipValidation2~
clipboard
textbox2.value$+"
"+combo2$
}
Function
TextBox2.Enter
{
SkipValidation1~
textbox1.value$=str$(Fromtext2(val(textbox2.value$,
locale$(14))),"")
SkipValidation1~
clipboard
textbox1.value$+"
"+combo1$
}
SkipValidation1=False
SkipValidation2=False
layer
Convertion {
thread
{
cursor
0, Height-1
print
over $(7, width),~(#FFFFFF),
Caption$+"
| "+str$(now,"long
time")
print
part $(4, width),~(#FFFFFF),
"George Karras 2020"
}
as T1
interval 1000/60
}
method
Convertion,
"SHOW",
1
threads
Erase
declare
Convertion nothing
|