あなたのソースコードはかなり不完全です。たとえば、データ型がありません。FreeBASIC では、格納したいデータの種類 ( Integer、Double、 String など) に応じて、いくつかのデータ型から選択します。さらに、サブプログラムが実際にどのように機能するかを定義していません。プロシージャ「減算」が何をすべきか、コードを指定しませんでした。
これは、小さな電卓の実際の例です。
' These two functions take 2 Integers (..., -1, 0, 1, 2, ...) and
' return 1 Integer as their result.
' Here we find the procedure declarations ("what inputs and outputs
' exist?"). The implementation ("how do these procedures actually
' work?") follows at the end of the program.
Declare Function Add (a As Integer, b As Integer) As Integer
Declare Function Subtract (a As Integer, b As Integer) As Integer
' == Begin of main program ==
Dim choice As Integer
Print "1. Add"
Print "2. Subtract"
Input "what is your choice? ", choice
' You could use "input" (see choice above) to get values from the user.
Dim As Integer x, y
x = 10
y = 6
If (choice = 1) Then
Print Add(x, y)
ElseIf (choice = 2) Then
Print Subtract(x, y)
Else
Print "Invalid input!"
End If
Print "Press any key to quit."
GetKey
End
' == End of main program ==
' == Sub programs (procedures = subs and functions) from here on ==
Function Add (a As Integer, b As Integer) As Integer
Return a + b
End Function
Function Subtract (a As Integer, b As Integer) As Integer
Return a - b
End Function