home *** CD-ROM | disk | FTP | other *** search
- REM **********************************************************************
- REM **************** Exclusive Property of Softbridge ********************
- REM **********************************************************************
-
- dim msg$ 'Module-level variable, visible to all functions below
-
- function gcd% ( u%, v% )
- dim t%
-
- if ( u < v ) then t=u else t=v
- while ( (u mod t) <> 0) OR ( (v mod t) <> 0)
- t=t-1
- wend
-
- gcd = t
- end function
-
- function showdlg% (a%, b%)
-
- begin dialog enter2num 10,10,150,90
- caption " ** G C D **"
-
- text 3, 4, 40, 10, "first number"
- textbox 60, 2, 25, 12, .num1$
- text 3, 18, 70, 10, "second number"
- textbox 60, 18, 25, 12, .num2$
- text 5, 35, 130, 10, msg$
-
- ButtonGroup .but
- Button 100,50,40,15, "OK"
- Button 100,70,40,15, "Cancel"
- end dialog
-
- dim InputDlg as enter2num
- InputDlg.num1$=str$(a)
- InputDlg.num2$=str$(b)
- Dialog InputDlg
-
- a = val(InputDlg.num1$)
- b = val(InputDlg.num2$)
- showdlg = InputDlg.but
- end function
-
- SUB Main
- Const TRUE=1
- dim a%, b%, sa%, sb%, r%
-
- do
- do
- r = showdlg(a,b)
- if (r=1) then exit sub ' CANCEL
- msg$="BAD NUMBER(S), PLEASE RE-ENTER"
- loop while (a<=0 or b<=0)
-
- if (sa=a) and (sb=b) then exit sub ' no change, EXIT
- sa=a : sb = b ' save last numbers
- msg$= "answer= "+str$(gcd(a,b))
- loop while TRUE
- end sub
-