Forum | | | | Gary12345 | Hi,
simpler code, simple question:
$I MatheLeicht.inc
Window 0,0-600,400
Window Style 15
Window Title "Taschenrechner by gary12345"
declare edittext$
var edit1& = CREATE("Edit",%HWND,edittext$,10,10,550,30)
var button1& = CREATE("Button",%HWND,"+",20,50,100,50)
var button2& = CREATE("Button",%HWND,"-",150,50,100,50)
var button3& = CREATE("Button",%HWND,":",280,50,100,50)
var button4& = CREATE("Button",%HWND,"X",410,50,100,50)
var button5& = CREATE("Button",%HWND,"Wurzel",20, 120,100,50)
var button6& = CREATE("Button",%HWND,"ADreieck",150,120,100,50)
var button7& = CREATE("Button",%HWND,"AQuadrat",280,120,100,50)
var button8& = CREATE("Button",%HWND,"ARechteck",410,120,100,50)
var button9& = CREATE("Button",%HWND,"AKreis",20,190,100,50)
var button10& = CREATE("Button",%HWND,"ATrapez",150,190,100,50)
var button11& = CREATE("Button",%HWND,"AParallelogr.",280,190,100,50)
var button12& = CREATE("Button",%HWND,"VKegel",410,190,100,50)
While 1
WaitInput
IF clicked(Button1&)
edittext$ = "+"
EndIf
EndWhile
As I said, I go step for step to and Please you not around the right code, separate circa Notes (z.B. in welchem Part the Help I nachlesen solle,etc.)
trouble1:
Help in XPROFAN To Edit:
n : LongInt - lever the übergeordneten Fensters
s : String - Vorgabetext
X1,Y1 : Integer - left upper corner the Eingabefeldes
X2,Y2 : Integer - Size the Eingabefeldes (Sonderfunktion; see Text)
now have I these row: edittext$ = "+" this String is the Vorgabetext s. Why fügt not with Click one Buttons a "+" hinzu?
Hello |
| | | | |
| | Julian Schmidt | Versuchs time by Settext! |
| | | | |
| | Gary12345 | thanks, on it have I again not virtual. Sorry. becomes funken. Teste it now time o.O |
| | | | |
| | Gary12345 | | | | | |
| | Gary12345 | CompileMarkSeparation $I MatheLeicht.inc
Window 0,0-600,400
WindowStyle 15
WindowTitle "Taschenrechner by Gary12345"
declare Ergebnis!
var edit1& = CREATE("Edit",%HWND,"",10,10,550,30)
var button1& = CREATE("Button",%HWND,"+",20,50,100,50)
var button2& = CREATE("Button",%HWND,"-",150,50,100,50)
var button3& = CREATE("Button",%HWND,":",280,50,100,50)
var button4& = CREATE("Button",%HWND,"X",410,50,100,50)
var button5& = CREATE("Button",%HWND,"Wurzel",20, 120,100,50)
var button6& = CREATE("Button",%HWND,"ADreieck",150,120,100,50)
var button7& = CREATE("Button",%HWND,"AQuadrat",280,120,100,50)
var button8& = CREATE("Button",%HWND,"ARechteck",410,120,100,50)
var button9& = CREATE("Button",%HWND,"AKreis",20,190,100,50)
var button10& = CREATE("Button",%HWND,"ATrapez",150,190,100,50)
var button11& = CREATE("Button",%HWND,"AParallelogr.",280,190,100,50)
var button12& = CREATE("Button",%HWND,"VKegel",410,190,100,50)
var buttonGo& = CREATE("Button",%HWND,"Rechnen",210,250,100,50)
While 1
WaitInput
IF clicked(button1&)
settext edit1&, gettext$(edit1&) + "+"
EndIf
If clicked(button2&)
settext edit1&, gettext$(edit1&) + "-"
EndIf
If clicked(button3&)
settext edit1&, gettext$(edit1&) + "/"
EndIf
If clicked(button4&)
settext edit1&, gettext$(edit1&) + "*"
EndIf
If clicked(buttonGo&)
Ergebnis! = val(gettext$(edit1&))
print Ergebnis!
EndIf
EndWhile
Nächstes trouble:
wished now the Result in float konvertieren (means with @val()). but Why rechnet not?
EDIT: have a supposition: can it on it lying, that + no floatwert his can? |
| | | | |
| | Julian Schmidt | naturally functions not. Val() konvertiert only a Zeichenkette to a number. You could the so solve, that you a Zählervariable erstelltst. and each rake- operation directly on these Variable ausführst. at that pressing the Result-Button can you then The Variable spend and zurücksetzten.
alternatively would The Solution with a Parser possible. |
| | | | |
| | Gary12345 | will be me tomorrow time informieren. be today To tired for. |
| | | | |
| | Gary12345 | what one Parser is, white I now. what a Zählevariable is , can I only slightly suppose. means You want, I whom Text of edit in a extra Variable abspeichere, these then to float umwandle and then rechnet? understand not so.
Hello! |
| | | | |
| | Julian Schmidt | in the Help find You one simple example to a Taschenrechner without Parser. The Grundidee thereby is, that you a vain Variable prepares, and each operation on The ausführst and then the Result ausgibst. example: you have a Taschenrechner with Buttons of numbers 0-9 and +, -, *, /, Clear. on the beginning is the Variable Ans! same 0. once You on the Button "+" press. becomes this Operator in a further Variable stored. once You now on a number click, becomes Ans! with the gespeicherten Operator and the squeezed number extended and !Ans as Result outputted.
The Grundüberlegung with one Parser is, that one The most complicated Formel in Bestandteile (substr) zerleget, The to the schema "Variable Operator Variable" aufgebaut are. one goes thereby Rückwärts to and seek to the on the tiefsten verschachtelten Rechenoperation to whom regulate the maths. speak Klammer to Potenz to point to Strich. this process becomes as long as repeatedly To no Operators More zufinden are. here an example: 8*2+(7-4) 16+(7-4) 16+3 19
here an example [...] |
| | | | |
| | Jörg Sellmeyer | i'd you too recommend, you first on The Grundrechenarten To limit and only simple Rechenoperation auszugeben, To You the principle at program so half-way understood have. 10 Button with the Digits of 0-9 are quick prepares. then yet 4 for Operanden and of/ one for =. You can zB each Buttonkick input in a list Save and at Click on the Ergebnisbutton, The list work out.
The input by Button of 72 + 8 - 4 yields then a list of: "72" "+" "8" "-" "4"
If the Ergebnisbutton pressed becomes wandelst You the then in a Rechenoperation circa.+ the same make You then with Multiplikation and Division.
If the functions, can you you too on simple Kombinationsaufgaben ranwagen. zB 8 * 12 + 7 here must You then The whole list first durcharbeiten, around the Rechenregeln anzuwenden. You "parst" means The list.
as nächstes can you still clinging install. there becomes the Parsen already something costly. Julians example needed incidentally yet no clinging, there it with the Rechenregeln automatich functions:
first so, are clinging necessary and there's naturally one other Result:
in the drop would I with of/ one Gridlist works and the Klammernblocks into next slot settle:
slot 1 | slot 2 | slot 3 | 8 | * | ( | | 2 | | + | | 7 | ) | - | 4
|
there do you need then only on each slot your Parserprozedur utilize and erhälst each korrekte Results. but always a step to the others. Erstmal The simple Grundrechenarten.
[OFFTOPIC]puh - is the one Umstand with the scheduler but now Have I it at least geschnallt... unfortunately functions by me the "Vorschau"-Button not. goes the others too so or is the one local trouble by me?[/OFFTOPIC] |
| | | Windows XP SP2 XProfan X4... und hier mal was ganz anderes als Profan ... | 02/02/13 ▲ |
| |
| | | The Preview Btn. goes by me even here strain ausm bed aufm Handy gg.
shows Preview überm editor - bisl up-scrolling, needed JS.
|
| | | | |
| | Jörg Sellmeyer | I Have JS activate and nevertheless no Preview |
| | | Windows XP SP2 XProfan X4... und hier mal was ganz anderes als Profan ... | 02/02/13 ▲ |
| |
|
AnswerTopic-Options | 18.528 Views |
Themeninformationenthis Topic has 4 subscriber: |