Buchempfehlung
MySQL kurz & gut
MySQL kurz & gut
Das preiswerte Taschen- buch stellt MySQL-rele- vante Inhalte systematisch und knapp dar, sodass es sich optimal zum Nach- schlagen beim Pro- grammieren eignet. [Mehr Infos...]
FreeBASIC-Chat
Es sind Benutzer im FreeBASIC-Chat online.
(Stand:  )
FreeBASIC bei Twitter
Twitter FreeBASIC-Nachrichten jetzt auch über Twitter erhalten. Follow us!

fb:porticula NoPaste

Info
Info / Hilfe
Liste
Übersicht / Liste
Neu
Datei hochladen
Suche
Quellcode suchen
Download
Dateidownload

Calculator

Uploader:Redakteurytwinky
Datum/Zeit:11.01.2011 23:23:07

' *******************************************
' Calculator - Uses EVAL.DLL
' *******************************************
' by jdebord
' translation to german by ytwinky
' button for pi added
dim i%, variable$, expression$, value, result

' -------------------------------------------
' Object description
' -------------------------------------------

' Main form

left    0, 300
top     0, 150
width   0, 485
height  0, 500
caption 0, "Calculator"

' Labels 1-4 (Variables)

for i% = 1 to 4
  alpha   i%
  left    i%, 16
  top     i%, 42 + (i% - 1) * 32
  width   i%, 24
  height  i%, 16
  caption i%, chr$(i% + 64) + " = "
next i%

' Labels 5-10

alpha   5
left    5, 16
top     5, 15
height  5, 16
caption 5, "Variablen"

alpha   6
left    6, 175
top     6, 15
height  6, 16
caption 6, "Eine Formel eingeben, dann Berechnen anklicken"

alpha   7
left    7, 175
top     7, 120
height  7, 16
caption 7, "Ergebnis"

alpha   8
left    8, 16
top     8, 190
height  8, 16
caption 8, "Zahlen"

alpha   9
left    9, 128
top     9, 190
height  9, 16
caption 9, "Operatoren"

alpha   10
left    10, 216
top     10, 190
height  10, 16
caption 10, "Funktionen"

' Edit 11-14 (Variables)

for i% = 11 to 14
  edit   i%
  left   i%, 48
  top    i%, 40 + (i% - 11) * 32
  width  i%, 113
  height i%, 24
  text   i%, str$(i% - 10)
next i%

' Edit 15-16 (Formula and Result)

edit   15
left   15, 175
top    15, 40
height 15, 24
width  15, 280
text   15, "A + B + C + D"

edit   16
left   16, 175
top    16, 137
height 16, 24
width  16, 280

' Button 21-29 (Digits 1-9)

for i% = 21 to 29
  button  i%
  height  i%, 25
  width   i%, 25
  caption i%, str$(i% - 20)
next i%

for i% = 21 to 23
  top  i%, 280
  left i%, 16 + (i% - 21) * 32
next i%

for i% = 24 to 26
  top  i%, 248
  left i%, 16 + (i% - 24) * 32
next i%

for i% = 27 to 29
  top  i%, 216
  left i%, 16 + (i% - 27) * 32
next i%

' Button 20 (Digit 0)

button  20
left    20, 32
top     20, 312
height  20, 25
width   20, 25
caption 20, "0"

' Button 30 (Decimal point)

button  30
left    30, 64
top     30, 312
height  30, 25
width   30, 25
caption 30, "."

' Button 31-32 (Parentheses)

for i% = 31 to 32
  button i%
  left   i%, 32 + (i% - 31) * 32
  top    i%, 344
  height i%, 25
  width  i%, 25
next i%

caption 31, "("
caption 32, ")"

' Button 33 (Backspace)

button  33
left    33, 32
top     33, 376
height  33, 25
width   33, 57
caption 33, "<---"
hint    33, "Letztes Zeichen löschen"

' Button 40-46 (Arithmetic operators)

for i% = 40 to 46
  button i%
  left   i%, 128
  top    i%, 216 + (i% - 40) * 32
  height i%, 25
  width  i%, 25
next i%

caption 40, "+" : hint 40, "Plus"
caption 41, "-" : hint 41, "Minus"
caption 42, "*" : hint 42, "Multiplizieren"
caption 43, "/" : hint 43, "Dividieren"
caption 44, "\" : hint 44, "Integer-Division"
caption 45, "%" : hint 45, "Modulo"
caption 46, "^" : hint 46, "Exponentiation"

' Button 50-57 (Logical operators)

for i% = 50 to 57
  button i%
  left   i%, 168
  top    i%, 216 + (i% - 50) * 32
  height i%, 25
  width  i%, 25
next i%

caption 50, "!"  : hint 50, "bitweises NOT"
caption 51, "&&" : hint 51, "bitweises AND"
caption 52, "|"  : hint 52, "bitweises OR"
caption 53, "$"  : hint 53, "bitweises XOR"
caption 54, "="  : hint 54, "bitweises EQV"
caption 55, "@"  : hint 55, "bitweises IMP"
caption 56, "<"  : hint 56, "Bit links rotieren"
caption 57, ">"  : hint 57, "Bit rechts rotieren"

' Button 60-66 (Standard functions)

for i% = 60 to 66
  button i%
  left   i%, 216
  top    i%, 216 + (i% - 60) * 32
  height i%, 25
  width  i%, 57
next i%

caption 60, "abs"   : hint 60, "Absolutwert"
caption 61, "sgn"   : hint 61, "Vorzeichen"
caption 62, "int"   : hint 62, "Integer-Anteil"
caption 63, "sqrt"  : hint 63, "Quadratwurzel"
caption 64, "exp"   : hint 64, "Exponent"
caption 65, "ln"    : hint 65, "Natürlicher Logarithmus"
caption 66, "log10" : hint 66, "Dezimaler Logarithmus"

' Button 70-76 (Trigonometric functions)

for i% = 70 to 76
  button i%
  left   i%, 280
  top    i%, 216 + (i% - 70) * 32
  height i%, 25
  width  i%, 57
next i%

caption 70, "sin"   : hint 70, "Sinus"
caption 71, "cos"   : hint 71, "Cosinus"
caption 72, "tan"   : hint 72, "Tangens"
caption 73, "asin"  : hint 73, "ArcusSinus"
caption 74, "acos"  : hint 74, "ArcusCosinus"
caption 75, "atan"  : hint 75, "ArcusTangens"
caption 76, "atan2" : hint 76, "ArcusTangens(y/x)"

' Button 80-85 (Hyperbolic functions)

for i% = 80 to 86
  button i%
  left   i%, 345
  top    i%, 216 + (i% - 80) * 32
  height i%, 25
  width  i%, 57
next i%

caption 80, "sinh"  : hint 80, "Hyperbolischer Sinus"
caption 81, "cosh"  : hint 81, "Hyperbolischer Cosinus"
caption 82, "tanh"  : hint 82, "Hyperbolischer Tangens"
caption 83, "asinh" : hint 83, "Hyperbolischer ArcusSinus"
caption 84, "acosh" : hint 84, "Hyperbolischer ArcusCosinus"
caption 85, "atanh" : hint 85, "Hyperbolischer ArcusTangens"
caption 86, "pi" : hint 86, "Pi, Kreiskonstante"

' Button 90-95 (Miscellaneous functions)

for i% = 90 to 95
  button i%
  left   i%, 410
  top    i%, 216 + (i% - 90) * 32
  height i%, 25
  width  i%, 57
next i%

caption 90, "deg"   : hint 90, "Radiant -> Altgrad(360°)"
caption 91, "rad"   : hint 91, "Altgrad(360°) -> Radiant"
caption 92, "rnd"   : hint 92, "Zufallszahl in [0,1)"
caption 93, "fact"  : hint 93, "Fakultät"
caption 94, "gamma" : hint 94, "Gamma-Funktion"
caption 95, "erf"   : hint 95, "Fehler-Funktion"

' Button 100-101 (Evaluate & Clear)

for i% = 100 to 101
  button i%
  top    i%, 72
  height i%, 25
  width  i%, 120
next i%

left 100, 175 : caption 100, "Berechnen"
left 101, 335 : caption 101, "Löschen"

' -------------------------------------------
' Assign subprograms to events
' -------------------------------------------

' Numbers, parentheses, backspace

label clk20, clk21, clk22, clk23, clk24, clk25, clk26
label clk27, clk28, clk29, clk30, clk31, clk32, clk33

on_click 20, clk20
on_click 21, clk21
on_click 22, clk22
on_click 23, clk23
on_click 24, clk24
on_click 25, clk25
on_click 26, clk26
on_click 27, clk27
on_click 28, clk28
on_click 29, clk29
on_click 30, clk30
on_click 31, clk31
on_click 32, clk32
on_click 33, clk33

' Arithmetic operators

label clk40, clk41, clk42, clk43, clk44, clk45, clk46

on_click 40, clk40
on_click 41, clk41
on_click 42, clk42
on_click 43, clk43
on_click 44, clk44
on_click 45, clk45
on_click 46, clk46

' Logical operators

label clk50, clk51, clk52, clk53, clk54, clk55, clk56, clk57

on_click 50, clk50
on_click 51, clk51
on_click 52, clk52
on_click 53, clk53
on_click 54, clk54
on_click 55, clk55
on_click 56, clk56
on_click 57, clk57

' Standard functions

label clk60, clk61, clk62, clk63, clk64, clk65, clk66

on_click 60, clk60
on_click 61, clk61
on_click 62, clk62
on_click 63, clk63
on_click 64, clk64
on_click 65, clk65
on_click 66, clk66

' Trigonometric functions

label clk70, clk71, clk72, clk73, clk74, clk75, clk76

on_click 70, clk70
on_click 71, clk71
on_click 72, clk72
on_click 73, clk73
on_click 74, clk74
on_click 75, clk75
on_click 76, clk76

' Hyperbolic functions

label clk80, clk81, clk82, clk83, clk84, clk85, clk86

on_click 80, clk80
on_click 81, clk81
on_click 82, clk82
on_click 83, clk83
on_click 84, clk84
on_click 85, clk85
on_click 86, clk86

' Miscellaneous functions

label clk90, clk91, clk92, clk93, clk94, clk95

on_click 90, clk90
on_click 91, clk91
on_click 92, clk92
on_click 93, clk93
on_click 94, clk94
on_click 95, clk95

' Evaluate and Clear

label clk100, clk101

on_click 100, clk100
on_click 101, clk101

' -------------------------------------------
' Main program
' -------------------------------------------

dll_on "eval.dll"
i% = dll_call0("InitFunc")

end

' -------------------------------------------
' Subprograms
' -------------------------------------------

' Numbers

clk20:
  text 15, text$(15) + "0"
return

clk21:
  text 15, text$(15) + "1"
return

clk22:
  text 15, text$(15) + "2"
return

clk23:
  text 15, text$(15) + "3"
return

clk24:
  text 15, text$(15) + "4"
return

clk25:
  text 15, text$(15) + "5"
return

clk26:
  text 15, text$(15) + "6"
return

clk27:
  text 15, text$(15) + "7"
return

clk28:
  text 15, text$(15) + "8"
return

clk29:
  text 15, text$(15) + "9"
return

clk30:
  text 15, text$(15) + "."
return

' Parentheses

clk31:
  text 15, text$(15) + "("
return

clk32:
  text 15, text$(15) + ")"
return

' Backspace

clk33:
  text 15, left$(text$(15), len(text$(15)) - 1)
return

' Arithmetic operators

clk40:
  text 15, text$(15) + " + "
return

clk41:
  text 15, text$(15) + " - "
return

clk42:
  text 15, text$(15) + " * "
return

clk43:
  text 15, text$(15) + " / "
return

clk44:
  text 15, text$(15) + " \ "
return

clk45:
  text 15, text$(15) + " % "
return

clk46:
  text 15, text$(15) + "^"
return

' Logical operators

clk50:
  text 15, text$(15) + " ! "
return

clk51:
  text 15, text$(15) + " & "
return

clk52:
  text 15, text$(15) + " | "
return

clk53:
  text 15, text$(15) + " $ "
return

clk54:
  text 15, text$(15) + " = "
return

clk55:
  text 15, text$(15) + " @ "
return

clk56:
  text 15, text$(15) + " < "
return

clk57:
  text 15, text$(15) + " > "
return

' Standard functions

clk60:
  text 15, text$(15) + "abs( "
return

clk61:
  text 15, text$(15) + "sgn("
return

clk62:
  text 15, text$(15) + "int("
return

clk63:
  text 15, text$(15) + "sqrt("
return

clk64:
  text 15, text$(15) + "exp("
return

clk65:
  text 15, text$(15) + "ln("
return

clk66:
  text 15, text$(15) + "log10("
return

' Trigonometric functions

clk70:
  text 15, text$(15) + "sin( "
return

clk71:
  text 15, text$(15) + "cos("
return

clk72:
  text 15, text$(15) + "tan("
return

clk73:
  text 15, text$(15) + "asin("
return

clk74:
  text 15, text$(15) + "acos("
return

clk75:
  text 15, text$(15) + "atan("
return

clk76:
  text 15, text$(15) + "atan2("
return

' Hyperbolic functions

clk80:
  text 15, text$(15) + "sinh( "
return

clk81:
  text 15, text$(15) + "cosh("
return

clk82:
  text 15, text$(15) + "tanh("
return

clk83:
  text 15, text$(15) + "asinh("
return

clk84:
  text 15, text$(15) + "acosh("
return

clk85:
  text 15, text$(15) + "atanh("
return

clk86:
  text 15, text$(15) + "(4*atan(1))"
return

' Miscellaneous functions

clk90:
  text 15, text$(15) + "deg( "
return

clk91:
  text 15, text$(15) + "rad("
return

clk92:
  text 15, text$(15) + "rnd()"
return

clk93:
  text 15, text$(15) + "fact("
return

clk94:
  text 15, text$(15) + "gamma("
return

clk95:
  text 15, text$(15) + "erf("
return

' Evaluate

clk100:

  variable$ = "A" : value = val(text$(11))
  i% = dll_call2("SetVariable", adr(variable$), adr(value))

  variable$ = "B" : value = val(text$(12))
  i% = dll_call2("SetVariable", adr(variable$), adr(value))

  variable$ = "C" : value = val(text$(13))
  i% = dll_call2("SetVariable", adr(variable$), adr(value))

  variable$ = "D" : value = val(text$(14))
  i% = dll_call2("SetVariable", adr(variable$), adr(value))

  expression$ = text$(15)

  i% = dll_call2("Eval", adr(expression$), adr(result))

  text 16, str$(result)

return

' Clear

clk101:
  text 15, ""
return