Page Date
2004-05-18
DD-Software
Kapitel zurück / previous Chapter
Main Index
 
Seite zurück / previous page
Backward
Seite vor / next page
Forward
 
Seitenanfang/TopOfPage
Top
Seitenende/EndOfPage
Bottom
MyWbtHelp current version

Bruchrechnen




Bruchrechnen.wbt   Version 1.01  2003:09:28

Kleines Dialogprogramm zum Rechnen mit Brüchen
  • Echte und unechte Brüche (Zähler und Nenner vertauschbar).
  • kgV kleinstes gemeinsames Vielfaches.
  • ggT größter gemeinsamer Teiler.
  • Ergebnis kann in die Zwischenablage kopiert werden.
View Screenshot
Download Bruchrechnen.exe

Version History
  • 2003:09:28 v1.01
    - Added WinHide("") to hide the WinBatch runtime dll stub window.
    - Der Bruchstrich ist ein Click-Button (Tastenkombination [Alt+x]) zum Vertauschen von Zähler und Nenner.
  • 2003:09:25 v1.00
    - Initial release.



;------------------------------------------------------------------------------------------------------------------------------------------
; Bruchrechnen v1.01
;
; Detlev Dalitz.20030925.20030928
;------------------------------------------------------------------------------------------------------------------------------------------
#DefineSubRoutine udsBruchrechnen (iZaehler, iNenner)

If !IsNumber(iZaehler) Then iZaehler = 1
iZaehler = Max(1,Abs(iZaehler))
If !IsNumber(iNenner) Then iNenner = 1
iNenner = Max(1,Abs(iNenner))

If (iNenner>iZaehler)
   iA = +iNenner
   iB = +iZaehler
Else
   iA = +iZaehler
   iB = +iNenner
EndIf

While @TRUE
   iC = iA mod iB
   If !iC Then Break
   iA = iB
   iB = iC
EndWhile

iC = iB
iA = iZaehler/iC
iB = iNenner/iC

sAusgabe = StrCat(iZaehler,"/",iNenner)
Switch @TRUE
Case (iC>1)
   sAusgabe = StrCat(sAusgabe,"=",iA)
   If (iA mod iB) Then sAusgabe = StrCat(sAusgabe,"/",iB)
   Continue
Case ((iA>iB)&&(iA mod iB))
   sAusgabe = StrCat(sAusgabe,"=",iA/iB,"+",iA mod iB,"/",iB)
   Continue
Case (iB>=1)
   sAusgabe = StrCat(sAusgabe,"=",1.*iA/iB)
   Break
EndSwitch

iKGV = iZaehler*iNenner/iC
iGGT = iC

;ClipPut(StrCat(sAusgabe,@TAB,"ggT=",iC,@TAB,"kgV=",iZaehler*iNenner/iC))
#EndSubRoutine
;------------------------------------------------------------------------------------------------------------------------------------------


;------------------------------------------------------------------------------------------------------------------------------------------
#DefineSubRoutine MyDialogCallbackProc(MyDialog_Handle,MyDialog_Message,MyDialog_ID,rsvd1,rsvd2)

Switch MyDialog_Message
Case MSG_INIT
   DialogProcOptions(MyDialog_Handle,MSG_BUTTONPUSHED,@TRUE)
   iClipAvail = @FALSE
   Return(-1)
Case MSG_BUTTONPUSHED
   Switch MyDialog_ID
   Case 001
      iZaehler = DialogControlGet(MyDialog_Handle,008,DC_EDITBOX)
      iNenner = DialogControlGet(MyDialog_Handle,009,DC_EDITBOX)
      Continue
   Case 004
      iZaehler = DialogControlGet(MyDialog_Handle,009,DC_EDITBOX)
      iNenner = DialogControlGet(MyDialog_Handle,008,DC_EDITBOX)
      Continue
   Case 001
   Case 004
      udsBruchrechnen(iZaehler,iNenner)
      DialogControlSet(MyDialog_Handle,008,DC_EDITBOX,iZaehler)
      DialogControlSet(MyDialog_Handle,009,DC_EDITBOX,iNenner)
      DialogControlSet(MyDialog_Handle,010,DC_EDITBOX,sAusgabe)
      DialogControlSet(MyDialog_Handle,011,DC_EDITBOX,iGGT)
      DialogControlSet(MyDialog_Handle,012,DC_EDITBOX,iKGV)
      If !iClipAvail
         If (DialogControlGet(MyDialog_Handle,010,DC_EDITBOX)>"")
            DialogControlState(MyDialog_Handle,003,DCSTATE_REMOVESTYLE,DCSTYLE_DISABLED)
            iClipAvail = @TRUE
         EndIf
      EndIf
      Return(-2)
   Case 003
      ClipPut(StrCat(sAusgabe,@TAB,"ggT=",iC,@TAB,"kgV=",iZaehler*iNenner/iC))
      Return(-2)
   Case 002
      Return(-1)
   EndSwitch
   Return(-1)
EndSwitch
Return(-1)
#EndSubRoutine
;------------------------------------------------------------------------------------------------------------------------------------------



;------------------------------------------------------------------------------------------------------------------------------------------
; Main
;------------------------------------------------------------------------------------------------------------------------------------------
WinHide("") ; Hide the WinBatch stub application window.
IntControl(49,3,1,0,0) ; Add system menus to WIL popup windows.
;------------------------------------------------------------------------------------------------------------------------------------------
; Init Dialog constants.
MSG_INIT=0                ; The one-time initilization
MSG_TIMER=1               ; Timer event
MSG_BUTTONPUSHED=2        ; Pushbutton or Picturebutton
DC_EDITBOX=3              ; EDITBOX MULTILINEBOX
DCSTATE_REMOVESTYLE=4     ; Remove control style
DCSTYLE_DISABLED=2        ; Set Control Disabled
;------------------------------------------------------------------------------------------------------------------------------------------
; Default values, must not, but may help to understand ...
;iZaehler = 30
;iNenner = 27
;------------------------------------------------------------------------------------------------------------------------------------------
MyDialogFormat=`WWWDLGED,6.1`
MyDialogCaption=`Bruchrechnen`
MyDialogX=-01
MyDialogY=-01
MyDialogWidth=288
MyDialogHeight=053
MyDialogNumControls=014
MyDialogProcedure=`MyDialogCallbackProc`
MyDialogFont=`DEFAULT`
MyDialogTextColor=`DEFAULT`
MyDialogBackground=`DEFAULT,240|236|192`
MyDialogConfig=1
MyDialog001=`051,021,036,012,PUSHBUTTON,DEFAULT,"&Rechnen",2,11,32,"MS Sans Serif|5632|40|34","0|128|128","240|236|192"`
MyDialog002=`051,035,036,012,PUSHBUTTON,DEFAULT,"&OK",1,12,0,"MS Sans Serif|5632|40|34","0|128|128","240|236|192"`
MyDialog003=`051,007,036,012,PUSHBUTTON,DEFAULT,"&Clipboard",3,11,2,"MS Sans Serif|5632|40|34","0|128|128","240|236|192"`
MyDialog004=`007,027,036,003,PUSHBUTTON,DEFAULT,"&x",5,16,128,DEFAULT,DEFAULT,"0|0|0"`
MyDialog005=`003,005,044,042,GROUPBOX,DEFAULT,"&Eingabe",DEFAULT,1,0,"MS Sans Serif|5632|40|34","0|128|128","240|236|192"`
MyDialog006=`099,005,184,042,GROUPBOX,DEFAULT,"&Ausgabe",DEFAULT,3,0,"MS Sans Serif|5632|40|34","0|128|128","240|236|192"`
MyDialog007=`089,019,008,014,STATICTEXT,DEFAULT,"=",DEFAULT,0,512,"MS Sans Serif|13824|70|34","0|0|0",DEFAULT`
MyDialog008=`007,013,036,012,EDITBOX,"iZaehler",DEFAULT,DEFAULT,1,64,DEFAULT,DEFAULT,DEFAULT`
MyDialog009=`007,032,036,012,EDITBOX,"iNenner",DEFAULT,DEFAULT,2,64,DEFAULT,DEFAULT,DEFAULT`
MyDialog010=`103,021,126,012,EDITBOX,"sAusgabe",DEFAULT,DEFAULT,4,8,DEFAULT,DEFAULT,"240|236|192"`
MyDialog011=`243,013,036,012,EDITBOX,"iGGT",DEFAULT,DEFAULT,6,72,DEFAULT,DEFAULT,"240|236|192"`
MyDialog012=`243,031,036,012,EDITBOX,"iKGV",DEFAULT,DEFAULT,8,72,DEFAULT,DEFAULT,"240|236|192"`
MyDialog013=`231,033,012,008,STATICTEXT,DEFAULT,"&kgV",DEFAULT,7,DEFAULT,"MS Sans Serif|5632|40|34","0|128|128",DEFAULT`
MyDialog014=`231,015,012,008,STATICTEXT,DEFAULT,"&ggT",DEFAULT,5,DEFAULT,"MS Sans Serif|5632|40|34","0|128|128",DEFAULT`
MyDialogButtonPushed=Dialog("MyDialog")

:CANCEL
Exit
;------------------------------------------------------------------------------------------------------------------------------------------
;*EOF*




Page Date
2004-05-18
DD-Software
Kapitel zurück / previous Chapter
Main Index
 
Seite zurück / previous page
Backward
Seite vor / next page
Forward
 
Seitenanfang/TopOfPage
Top
Seitenende/EndOfPage
Bottom
MyWbtHelp current version