Dipol Calc

Here you can attach your files or example so others can use it, discussions needs to be done at the general board
Post Reply
aurelW
Posts: 14
Joined: Wed May 07, 2008 2:10 pm

Dipol Calc

Post: # 222Post aurelW
Wed May 07, 2008 7:33 pm

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


Fazer
Posts: 30
Joined: Tue Apr 29, 2008 12:43 pm

Dipol Calc

Post: # 223Post Fazer
Thu May 08, 2008 6:23 am

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!


aurelW
Posts: 14
Joined: Wed May 07, 2008 2:10 pm

Dipol Calc

Post: # 224Post aurelW
Thu May 08, 2008 11:32 am

Thanks Fazer!
I dont know command for editbox and for labels
it is same like for button ?

aurelW
Posts: 14
Joined: Wed May 07, 2008 2:10 pm

Dipol Calc

Post: # 225Post aurelW
Thu May 08, 2008 1:15 pm

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


aurelW
Posts: 14
Joined: Wed May 07, 2008 2:10 pm

Dipol Calc

Post: # 226Post aurelW
Thu May 08, 2008 1:20 pm

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


Fazer
Posts: 30
Joined: Tue Apr 29, 2008 12:43 pm

Dipol Calc

Post: # 227Post Fazer
Thu May 08, 2008 1:38 pm

[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



Fazer
Posts: 30
Joined: Tue Apr 29, 2008 12:43 pm

Dipol Calc

Post: # 228Post Fazer
Thu May 08, 2008 1:41 pm

you were faster than me !
Nice! You have now a better structure in your code !

aurelW
Posts: 14
Joined: Wed May 07, 2008 2:10 pm

Dipol Calc

Post: # 229Post aurelW
Thu May 08, 2008 1:57 pm

Thanks again.
I love structured becose is much easier to understand
for beginers.

aurelW
Posts: 14
Joined: Wed May 07, 2008 2:10 pm

Dipol Calc

Post: # 230Post aurelW
Thu May 08, 2008 1:59 pm

By the way...FNX basic code look
like Media basic code.

aurelW
Posts: 14
Joined: Wed May 07, 2008 2:10 pm

Dipol Calc

Post: # 231Post aurelW
Thu May 08, 2008 2:32 pm

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


Post Reply