Dipol Calc
Dipol Calc
Hi all...
Here is my first example written in FNX Basic.
code:
`/dipol length/by aurelW
dim cap$ as string
dim freq as integer
dim length as single
`dim btn(1) as button
cap$="Dipol by Aurel"
`/open window form
OBJECT WIN as FORM
caption=cap$
Object but as button
left=10
top=10
caption="Calc"
onclick=clicked
End Object
END OBJECT
`/domodal or show.window
WIN.ShowModal
SUB clicked()
`frequency(MHz)
freq=62
`dipol length (m)
length=142.5/freq
Showmessage "Dipol length: "+str$(length)+" m"
END SUB
Here is my first example written in FNX Basic.
code:
`/dipol length/by aurelW
dim cap$ as string
dim freq as integer
dim length as single
`dim btn(1) as button
cap$="Dipol by Aurel"
`/open window form
OBJECT WIN as FORM
caption=cap$
Object but as button
left=10
top=10
caption="Calc"
onclick=clicked
End Object
END OBJECT
`/domodal or show.window
WIN.ShowModal
SUB clicked()
`frequency(MHz)
freq=62
`dipol length (m)
length=142.5/freq
Showmessage "Dipol length: "+str$(length)+" m"
END SUB
Dipol Calc
Nice program!
It would be perfect if you add some editfields, so that the user can input his data ( frequency etc.), and also some labels, which describe the input values!
It would be perfect if you add some editfields, so that the user can input his data ( frequency etc.), and also some labels, which describe the input values!
Dipol Calc
Thanks Fazer!
I dont know command for editbox and for labels
it is same like for button ?
I dont know command for editbox and for labels
it is same like for button ?
Dipol Calc
I`m think that is better now.
code:
`dipol length/by aurelW
dim cap$ as string
dim freq as integer
dim length as single
dim freq$ as string
`---------------------------------
cap$="Dipol by Aurel"
`----------------------------------
`open window form
OBJECT WIN as FORM
caption=cap$
Object but as Button
left=200
top=10
caption="Calc"
onclick=clicked
End Object
Object Label1 As Label
Caption = "Enter frequency"
left = 20
top=10
End Object
Object Edit1 AS Edit
Text = "MHz"
Left = 20
Top = 40
End Object
END OBJECT
`show window
WIN.ShowModal
SUB clicked()
getstring()
freq=VAL(freq$)
`dipol length (m)
length=142.5/freq
Showmessage "Dipol length: "+str$(length)+" m"
END SUB
SUB getstring()
freq$= Edit1.text
END SUB
code:
`dipol length/by aurelW
dim cap$ as string
dim freq as integer
dim length as single
dim freq$ as string
`---------------------------------
cap$="Dipol by Aurel"
`----------------------------------
`open window form
OBJECT WIN as FORM
caption=cap$
Object but as Button
left=200
top=10
caption="Calc"
onclick=clicked
End Object
Object Label1 As Label
Caption = "Enter frequency"
left = 20
top=10
End Object
Object Edit1 AS Edit
Text = "MHz"
Left = 20
Top = 40
End Object
END OBJECT
`show window
WIN.ShowModal
SUB clicked()
getstring()
freq=VAL(freq$)
`dipol length (m)
length=142.5/freq
Showmessage "Dipol length: "+str$(length)+" m"
END SUB
SUB getstring()
freq$= Edit1.text
END SUB
Dipol Calc
I mess up Edit1,refresh:
`dipol length/by aurelW
dim cap$ as string
dim freq as integer
dim length as single
dim freq$ as string
`---------------------------------
cap$="Dipol by Aurel"
`----------------------------------
`open window form
OBJECT WIN as FORM
caption=cap$
Object but as Button
left=200
top=10
caption="Calc"
onclick=clicked
End Object
Object Label1 As Label
Caption = "Enter frequency ( MHz )"
left = 20
top=10
End Object
Object Edit1 AS Edit
Text = ""
Left = 20
Top = 40
End Object
END OBJECT
`show window
WIN.ShowModal
SUB clicked()
getstring()
freq=VAL(freq$)
`dipol length (m)
length=142.5/freq
Showmessage "Dipol length: "+str$(length)+" m"
END SUB
SUB getstring()
freq$= Edit1.text
END SUB
`dipol length/by aurelW
dim cap$ as string
dim freq as integer
dim length as single
dim freq$ as string
`---------------------------------
cap$="Dipol by Aurel"
`----------------------------------
`open window form
OBJECT WIN as FORM
caption=cap$
Object but as Button
left=200
top=10
caption="Calc"
onclick=clicked
End Object
Object Label1 As Label
Caption = "Enter frequency ( MHz )"
left = 20
top=10
End Object
Object Edit1 AS Edit
Text = ""
Left = 20
Top = 40
End Object
END OBJECT
`show window
WIN.ShowModal
SUB clicked()
getstring()
freq=VAL(freq$)
`dipol length (m)
length=142.5/freq
Showmessage "Dipol length: "+str$(length)+" m"
END SUB
SUB getstring()
freq$= Edit1.text
END SUB
Dipol Calc
[quote author=aurelW link=1210188785/0#2 date=1210246349]Thanks Fazer!
I dont know command for editbox and for labels
it is same like for button ?
[/quote]
I have made some additions:
`---------------------------------------------
` begin of code
`/dipol length/by aurelW
dim cap$ as string
dim freq as double
dim length as double
`dim btn(1) as button
cap$="Dipol by Aurel"
`/open window form
OBJECT WIN as FORM
caption=cap$
Object lblfreq as Label
left=10 : top=13: width= 40
caption="frequency [MHz]:"
End Object
Object editFreq as edit
left=95 : top=10 : width= 40
End Object
Object lbllen as Label
left=10 : top=33: width= 40
caption="length [1/ freq]:"
End Object
Object editlen as edit
left=95 : top=30 : width= 40
End Object
Object but as button
left=10
top=85
caption="Calc"
onclick=clicked
End Object
END OBJECT
`/domodal or show.window
WIN.ShowModal
SUB clicked()
`frequency(MHz)
freq= val( editFreq.Text)
`dipol length (m)
length= val(editlen.Text)/freq
Showmessage "Dipol length: "+str$(length)+" m"
END SUB
`end of code
`-------------------------------------------------------------
Now this is a rough (quick and dirty) version. You can make now a little bit of fine tuning, if you have understood my additions.
Good luck !
Fazer
I dont know command for editbox and for labels
it is same like for button ?
[/quote]
I have made some additions:
`---------------------------------------------
` begin of code
`/dipol length/by aurelW
dim cap$ as string
dim freq as double
dim length as double
`dim btn(1) as button
cap$="Dipol by Aurel"
`/open window form
OBJECT WIN as FORM
caption=cap$
Object lblfreq as Label
left=10 : top=13: width= 40
caption="frequency [MHz]:"
End Object
Object editFreq as edit
left=95 : top=10 : width= 40
End Object
Object lbllen as Label
left=10 : top=33: width= 40
caption="length [1/ freq]:"
End Object
Object editlen as edit
left=95 : top=30 : width= 40
End Object
Object but as button
left=10
top=85
caption="Calc"
onclick=clicked
End Object
END OBJECT
`/domodal or show.window
WIN.ShowModal
SUB clicked()
`frequency(MHz)
freq= val( editFreq.Text)
`dipol length (m)
length= val(editlen.Text)/freq
Showmessage "Dipol length: "+str$(length)+" m"
END SUB
`end of code
`-------------------------------------------------------------
Now this is a rough (quick and dirty) version. You can make now a little bit of fine tuning, if you have understood my additions.
Good luck !
Fazer
Dipol Calc
you were faster than me !
Nice! You have now a better structure in your code !
Nice! You have now a better structure in your code !
Dipol Calc
Thanks again.
I love structured becose is much easier to understand
for beginers.
I love structured becose is much easier to understand
for beginers.
Dipol Calc
By the way...FNX basic code look
like Media basic code.
like Media basic code.
Dipol Calc
Final version of example with check error is:
code:
`dipol length/by aurelW
dim cap$ as string
dim freq as integer
dim length as single
dim freq$ as string
`---------------------------------
cap$="Dipol by Aurel"
`----------------------------------
`open window form
OBJECT WIN as FORM
caption=cap$
Object but as Button
left=200
top=10
caption="Calc"
onclick=clicked
End Object
Object Label1 As Label
Caption = "Enter frequency ( MHz )"
left = 20
top=10
End Object
Object Edit1 AS Edit
Text = ""
Left = 20
Top = 40
End Object
END OBJECT
`show window
WIN.ShowModal
SUB clicked()
getstring()
freq=VAL(freq$)
If freq=0 then Showmessage "Division by Zero!"
If freq=0 then exit sub
`dipol length (m)
length=142.5/freq
Showmessage "Dipol length: "+str$(length)+" m"
END SUB
SUB getstring()
freq$= Edit1.text
If freq$="" then Showmessage "You enter nothig!Try again!"
END SUB
code:
`dipol length/by aurelW
dim cap$ as string
dim freq as integer
dim length as single
dim freq$ as string
`---------------------------------
cap$="Dipol by Aurel"
`----------------------------------
`open window form
OBJECT WIN as FORM
caption=cap$
Object but as Button
left=200
top=10
caption="Calc"
onclick=clicked
End Object
Object Label1 As Label
Caption = "Enter frequency ( MHz )"
left = 20
top=10
End Object
Object Edit1 AS Edit
Text = ""
Left = 20
Top = 40
End Object
END OBJECT
`show window
WIN.ShowModal
SUB clicked()
getstring()
freq=VAL(freq$)
If freq=0 then Showmessage "Division by Zero!"
If freq=0 then exit sub
`dipol length (m)
length=142.5/freq
Showmessage "Dipol length: "+str$(length)+" m"
END SUB
SUB getstring()
freq$= Edit1.text
If freq$="" then Showmessage "You enter nothig!Try again!"
END SUB