TGC Codebase Backup



Full Screen Calculator by Anonymous Coder

6th Aug 2007 16:50
Summary

a simple full screen calculator



Description

A calculator that can add, subtract, multiple, or divide! it doesn't have buttons or special gadgets but it works, with 200+ lines of code.



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    `SimpCalc
`this program was made by Adam Mazzarella and can
`be reproduced without permission from owner
`Made By Adam Mazzarella
`Start Time: 1:27 8/6/2007
`Finish Time: 4:12 8/6/2007
`Elapsed Time: 2h 45m

remstart


     (---------------------------------------------------------)
     (                                                         )
     (         111111                           111111         )
     (       l1   11             +            11   11          )
     (            11             +                 11          )
     (            11          +++++++              11          )
     (            11             +                 11          )
     (            11             +                 11          )
     (        1111111111                       1111111111      )
     (                                                         )
     (---------------------------------------------------------)




To use this program you must make it into an exe.
                  ^
               effectively

remend

`Variables
first# = 1
eql# = 0
run# = 0
calculate# = 0
again# = 0
disp# = 0


`Loop
do
    sync
    if first# = 1
        if file exist(firstrun$) = 1
            sync
            run# = 1
            sync
        else
            sync
            gosub _first_run
            run# = 1
            sync
        endif
        first# = 0
    endif
    if run# = 1
        sync
        gosub _run
        calculate# = 1
        run# = 0
        sync
    endif
    if calculate# = 1
        sync
        gosub _calculate
        disp# = 1
        calculate# = 0
        sync
    endif
    if disp# = 1
        sync
        gosub _disp
        again# = 1
        disp# = 0
        sync
    endif
    if again# = 1
        sync
        gosub _again
        again# = 0
        sync
    endif
    sync
loop

`Routines
_first_run:
sync
open to write 1, "firstrun"
write string 1, "This is a VERY simple Calculator... made in 3 hours(most was editing + revising)!"
close file 1
sync
print "You are running this for the first time so I shall instruct you on how to use it"
print ""
print "Press Any Key to Continue"
wait key
sync
cls
sync
print "To use this program, type in the information prompted"
print ""
print "(+-*/)"
print "This means..."
print "     Plus (+)"
print "     Minus (-)"
print "     Times (*)"
print "     Divided by (/)"
print ""
print "Press Any Key to Continue"
wait key
sync
cls
sync
print "If the program askes you a question, answer it by either saying"
print "y"
print "Or"
print "n"
print "And press Enter"
print ""
print "Press Any Key to Continue"
wait key
sync
cls
sync
print "That's about it for the tutorial... but there is one test to complete..."
print ""
print "Press Any Key to Continue"
wait key
sync
cls
sync
print "Do you want to exit to windows(type 1) or finish and go to calculator(type 2)?"
input " - ", ques1$
if ques1$ = "1"
end
endif
sync
return


_run:
sync
cls
text 900, 2, "# = "+str$(eql#)+""
input "1'st Number to Calculate - ", numb1#
sync
cls
sync
text 900, 2, "# = "+str$(eql#)+""
text 830, 15, "1st Number = "+str$(numb1#)+""
input "(+-*/) - ", sign$
sync
cls
sync
text 900, 2, "# = "+str$(eql#)+""
text 830, 15, "1st Number = "+str$(numb1#)+""
input "2'nd Number to Calculate - ", numb2#
sync
cls
text 900, 2, "# = "+str$(eql#)+""
text 830, 15, "1st Number = "+str$(numb1#)+""
text 830, 28, "2nd Number = "+str$(numb2#)+""
sync
return


_calculate:
if sign$ = "+"
    eql# = numb1# + numb2#
endif
if sign$ = "-"
    eql# = numb1# - numb2#
endif
if sign$ = "*"
    eql# = numb1# * numb2#
endif
if sign$ = "/"
    eql# = numb1# / numb2#
endif
return


_disp:
cls
if sign$ = "+"
set text size 32
text 1, 1, ""+str$(numb1#)+" + "+str$(numb2#)+" = "+str$(eql#)+""
set text size 12
text 830, 2, "1st Number = "+str$(numb1#)+""
text 830, 15, "2nd Number = "+str$(numb2#)+""
text 900, 28, "# = "+str$(eql#)+""
endif
if sign$ = "-"
set text size 32
text 1, 1, ""+str$(numb1#)+" - "+str$(numb2#)+" = "+str$(eql#)+""
set text size 12
text 830, 2, "1st Number = "+str$(numb1#)+""
text 830, 15, "2nd Number = "+str$(numb2#)+""
text 900, 28, "# = "+str$(eql#)+""
endif
if sign$ = "*"
set text size 32
text 1, 1, ""+str$(numb1#)+" * "+str$(numb2#)+" = "+str$(eql#)+""
set text size 12
text 830, 2, "1st Number = "+str$(numb1#)+""
text 830, 15, "2nd Number = "+str$(numb2#)+""
text 900, 28, "# = "+str$(eql#)+""
endif
if sign$ = "/"
set text size 32
text 1, 1, ""+str$(numb1#)+" / "+str$(numb2#)+" = "+str$(eql#)+""
set text size 12
text 830, 2, "1st Number = "+str$(numb1#)+""
text 830, 15, "2nd Number = "+str$(numb2#)+""
text 900, 28, "# = "+str$(eql#)+""
endif
wait key
return


_again:
cls
run# = 1
eql# = 0
return