Advertisement
Guest User

Untitled

a guest
Jan 17th, 2017
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 21.63 KB | None | 0 0
  1. --------------------------
  2. --Dubs's Text Calculator--
  3. -------Version: 1.9-------
  4. --------------------------
  5. --[[notes
  6. lua function
  7. ]]--
  8. --options
  9. local usecolor = true
  10. local docutscenes = true
  11. local autoclear = false
  12. local autoclearinterval = 20
  13. local cutsceneinterval = 0.25
  14. local using_touchlua_app = true
  15. local createfiles = true
  16. --code
  17. require "draw"
  18. function print2(input)
  19.     io.write(input.."\n")
  20. end
  21. function print(input)
  22.     if input==nil then input="" end
  23.     if input==true then input="true" end
  24.     if input==false then input="false" end
  25.     local file=io.open("calculator logs.txt","a+")
  26.     if file:read()=="" then file:write(input)
  27. else do file:write("\n"..input) end end
  28.     file:close()
  29.     print2(input)
  30. end
  31. function clearlog()
  32.     file=io.open("calculator logs.txt","w")
  33.     file:write()
  34.     file:close()
  35. end
  36. crashcount=0
  37. local match="[1234567890/-*^+().#]"
  38. local notmatch=[=[[qwertyuiopasdfghjklzxcvbnm:;$&@?!'"{}_\|~<>€£¥]]=]
  39. local x=0
  40. if using_touchlua_app and docutscenes then cutsceneinterval=cutsceneinterval*1000 end
  41. if not io.open("calculator logs.txt","r") and createfiles then
  42.    file=io.open("calculator memory.txt","w")
  43.    file:close()
  44. end
  45. if not io.open("calculator memory.txt","r") and createfiles then
  46.    file=io.open("calculator memory.txt","w")
  47.    file:write("-----------------\nCalculator Recall\n-----------------\n")
  48.    file:close()
  49. end
  50. ::cls::
  51. os.execute("cls") clearlog()
  52. prev=nil
  53. function callable(f)
  54.    return function(...)
  55.        error, result = pcall(f, ...)
  56.        if error then
  57.            return true
  58.        else
  59.            return false
  60.        end
  61.    end
  62. end
  63. function get(getFile)
  64.    local file=io.open(getFile,"r")
  65.    local getOut=file:read("*a")
  66.    file:close()
  67.    print("[[[start get]]]")
  68.    print()
  69.    print(getOut)
  70.    print()
  71.    print("[[[end get]]]")
  72. end
  73. function slowprint(text,delay)
  74.    delay=delay or 125
  75.    for x=1,string.len(text) do
  76.        char=string.sub(text,x,x)
  77.        io.write(char)
  78.        sleep(delay)
  79.    end
  80. end
  81. function factorial(n)
  82.    n=tonumber(n)
  83.    return n > 0 and n * factorial(n-1) or 1
  84. end
  85. function percent(perc,tot)
  86.    return (perc/100)*tot
  87. end
  88. function ee(zero,to)
  89.    return zero*(10^to)
  90. end
  91. function simplify(calcin)
  92.    a,b=calcin:match"(.+)/(.+)"u,v=a,b while v+0>0 do t=u u=v v=t%v end
  93.    return a+0==a/u and a.."/"..b or a/u.."/"..b/u
  94. end
  95. function split(inputstr, sep)
  96.    if sep == nil then
  97.        sep = "%%"
  98.    end
  99.    local t={} ; i=1
  100.    for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
  101.        t[i] = str
  102.        i = i + 1
  103.    end
  104.    return t
  105. end
  106. function IsPrime(n)
  107.    for i = 2, n^(1/2) do
  108.        if (n % i) == 0 then
  109.            return false
  110.        end
  111.    end
  112.    return true
  113. end
  114. function GetFileSize( filename )
  115.    local fp = io.open( filename )
  116.    if fp == nil then
  117.        return nil
  118.    end
  119.    local filesize = fp:seek( "end" )
  120.    fp:close()
  121.    return filesize
  122. end
  123. function PrimeDecomp( n )
  124.    local f = {}
  125.    if IsPrime( n ) then
  126.        f[1] = n
  127.        return f
  128.    end
  129.    local i = 2
  130.    repeat
  131.        while n % i == 0 do
  132.            f[#f+1] = i
  133.            n = n / i
  134.        end
  135.        repeat
  136.            i = i + 1
  137.        until IsPrime( i )
  138.    until n == 1
  139.    return f
  140. end
  141. function Factors( n )
  142.    local f = {}
  143.    for i = 1, n/2 do
  144.        if n % i == 0 then
  145.            f[#f+1] = i
  146.        end
  147.    end
  148.    f[#f+1] = n
  149.    return f
  150. end
  151. if not using_touchlua_app or not callable(sleep) then
  152.    local clock = os.clock
  153.    function sleep(n)  -- seconds
  154.        local t0 = clock()
  155.        while clock() - t0 <= n do end
  156.    end
  157. end
  158. function print_r ( t )
  159.    local print_r_cache={}
  160.    local function sub_print_r(t,indent)
  161.        if (print_r_cache[tostring(t)]) then
  162.            print(indent.."*"..tostring(t))
  163.        else
  164.            print_r_cache[tostring(t)]=true
  165.            if (type(t)=="table") then
  166.                for pos,val in pairs(t) do
  167.                    if (type(val)=="table") then
  168.                        print(indent.."["..pos.."] => "..tostring(t).." {")
  169.                        sub_print_r(val,indent..string.rep(" ",string.len(pos)+8))
  170.                        print(indent..string.rep(" ",string.len(pos)+6).."}")
  171.                    else
  172.                        print(indent.."["..pos.."] => "..tostring(val))
  173.                    end
  174.                end
  175.            else
  176.                print(indent..tostring(t))
  177.            end
  178.        end
  179.    end
  180.    sub_print_r(t,"  ")
  181. end
  182. if usecolor and using_touchlua_app then
  183.    sys.setbgcolor(draw.black)
  184.    sys.setcolor(draw.red)
  185. end
  186. if usecolor and using_touchlua_app then
  187.    sys.setbgcolor(draw.black)
  188.    sys.setcolor(draw.green)
  189. end
  190. if docutscenes then
  191.    print("Booting") print("- - -")
  192.    sleep(cutsceneinterval)
  193.    os.execute("cls") clearlog()
  194.    print("Booting") print("| - -")
  195.    sleep(cutsceneinterval)
  196.    os.execute("cls") clearlog()
  197.    print("Booting") print("| | -")
  198.    sleep(cutsceneinterval)
  199.    os.execute("cls") clearlog()
  200.    print("Booting") print("| | |")
  201.    sleep(cutsceneinterval)
  202. end
  203. ::reclc::
  204. os.execute("cls")
  205. if not slowp then print("Enter an equation. * is multiply, / is divide, ^ followed by a number is an exponent. Type help to get advanced functions.") end
  206. if slowp==true then calcin=string.gsub(string.lower(calcin),"slowprint ","") local file=io.open("calculator logs.txt","r") log=file:read("*a") file:close() io.write("Enter an equation. * is multiply, / is divide, ^ followed by a number is an exponent. Type help to get advanced functions.") print(log) sleep(5000) slowprint(calcin,200) io.write("\n") slowp=false end
  207. clearlog()
  208. ::recalc::
  209. print("-------------")
  210. ::redocalc::
  211. calcin = io.read()
  212. if string.match(string.lower(calcin),"debug") then
  213.    ::drawdebug::
  214.    if usecolor and using_touchlua_app then
  215.        sys.setbgcolor(draw.black)
  216.        sys.setcolor(draw.red)
  217.    end
  218.    os.execute("cls")
  219.    print("Debug mode enabled. Anti-crash safeguards disabled while in this mode. Debug commands enabled while in this mode. Scary red font enabled while in this mode. Type exit to leave.")
  220.    ::redebug::
  221.    print("=============")
  222.    io.write("debug> ")
  223.    local debugin=io.read()
  224.    debugin=string.lower(debugin)
  225.    if string.match(debugin,"panic") and createfiles==true then
  226.        file=io.open("calculator memory.txt","w")
  227.        file:write("-----------------\nCalculator Recall\n-----------------\n")
  228.        file:close()
  229.        clearlog()
  230.        goto drawdebug
  231.    end
  232.    if debugin=="exit" then
  233.        if usecolor and using_touchlua_app then
  234.            sys.setbgcolor(draw.black)
  235.            sys.setcolor(draw.green)
  236.        end
  237.        goto cls
  238.    end
  239.    if debugin=="cls" then goto drawdebug end
  240.    if debugin=="console" or debugin=="lua" then
  241.        if usecolor and using_touchlua_app then
  242.            sys.setcolor(draw.blue)
  243.            os.execute("cls")
  244.            while true do
  245.                io.write("Lua> ")
  246.                local luaIn=io.read()
  247.                if luaIn=="exit" then break end
  248.                load(luaIn)()
  249.            end
  250.            goto drawdebug
  251.        end
  252.    end
  253.    if string.match(debugin,"get") then
  254.        if string.match(debugin,"history") then
  255.            get("calculator memory.txt")
  256.            goto redebug
  257.        elseif string.match(debugin,"logs") then
  258.            get("calculator logs.txt")
  259.            goto redebug
  260.        end
  261.    end
  262.    if string.match(debugin,"sqrt") then
  263.        debugin=string.lower(debugin)
  264.        input=debugin
  265.        debugin = string.gsub(debugin,"sqrt","")
  266.        debugin=math.sqrt(debugin)
  267.        print("="..debugin)
  268.        glrb=debugin
  269.        debugin=input
  270.        goto redebug
  271.    elseif string.match(debugin,"factors") then
  272.        debugin=string.lower(debugin)
  273.        glrb=debugin
  274.        debugin = string.gsub(debugin,"factors","")
  275.        debugin=Factors(debugin)
  276.        print_r(debugin)
  277.        goto redebug
  278.    elseif string.match(debugin,"primefacs") then
  279.        debugin=string.lower(debugin)
  280.        glrb=debugin
  281.        debugin = string.gsub(debugin,"primefacs","")
  282.        debugin=tonumber(debugin)
  283.        debugin=PrimeDecomp(debugin)
  284.        print_r(debugin)
  285.        goto redebug
  286.    elseif string.match(debugin,"%%") then
  287.        input=debugin
  288.        tab=split(debugin)
  289.        perc=tab[1]
  290.        tot=tab[2]
  291.        glrb=percent(perc,tot)
  292.        print("="..glrb)
  293.        debugin=input
  294.        goto redebug
  295.    elseif string.match(debugin,"ee") then
  296.        input=debugin
  297.        tab=split(debugin,"ee")
  298.        zero=tab[1]
  299.        to=tab[2]
  300.        glrb=ee(zero,to)
  301.        print("="..glrb)
  302.        debugin=input
  303.        goto redebug
  304.    elseif string.match(debugin,"simplify") then
  305.        input=debugin
  306.        debugin=string.gsub(debugin,"simplify","")
  307.        glrb=simplify(debugin)
  308.        print("="..glrb)
  309.        debugin=input
  310.        goto redebug
  311.    elseif string.match(debugin,"factorial") then
  312.        input=debugin
  313.        debugin=string.gsub(debugin,"factorial","")
  314.        debugin=string.lower(debugin)
  315.        glrb=factorial(debugin)
  316.        print("="..glrb)
  317.        debugin=input
  318.        goto redebug
  319.    elseif string.match(debugin,"intocm") then
  320.        input=debugin
  321.        debugin=string.gsub(debugin,"intocm","")
  322.        glrb=debugin*2.54
  323.        print("="..glrb)
  324.        debugin=input
  325.        goto redebug
  326.    elseif string.match(debugin,"cm>in") then
  327.        input=debugin
  328.        debugin=string.gsub(debugin,"cm>in","")
  329.        glrb=debugin/2.54
  330.        print("="..glrb)
  331.        debugin=input
  332.        goto redebug
  333.    elseif string.match(debugin,"ft>m") then
  334.        input=debugin
  335.        debugin=string.gsub(debugin,"ft>m","")
  336.        glrb=debugin*3.28
  337.        print("="..glrb)
  338.        debugin=input
  339.        goto redebug
  340.    end
  341.    func = assert(load("return " .. debugin))
  342.    glrb = func()
  343.    if string.match(glrb,"-") then
  344.        print("=("..glrb..")")
  345.    else do
  346.            print("="..glrb)
  347.        end
  348.    end
  349.    goto redebug
  350. end
  351. if calcin=="an equation" then
  352.    os.execute("cls") clearlog()
  353.    slowprint("Good job.") sleep(3000) slowprint("\nYou win.") sleep(3000) slowprint("\nI'm out.") sleep(3000) slowprint("\nGG.") sleep(3000) os.exit()
  354. end
  355. if prevcalcin==calcin then crashcount=crashcount+1 end
  356. if prevcalcin~=calcin then crashcount=0 end
  357. if crashcount>=10 then error("keyspam detected.") end
  358. prevcalcin = calcin
  359. if string.match(string.lower(calcin),"slowprint ") then slowp=true goto reclc end
  360. local file=io.open("calculator logs.txt","a+")
  361. file:write("\n"..calcin)
  362. file:close()
  363. calcin=string.lower(calcin)
  364. if string.match(calcin,"panic") and createfiles==true then
  365.    file=io.open("calculator memory.txt","w")
  366.    file:write("-----------------\nCalculator Recall\n-----------------\n")
  367.     file:close()
  368.     clearlog()
  369.     goto cls
  370. elseif calcin=="cls" or calcin=="clear" then x=x+1 if x==20 and autoclear then os.execute("cls") clearlog()  goto recalc else end  goto cls
  371. elseif string.match(calcin,"#") and not prev then goto recalc
  372. elseif calcin=="clearmem" and createfiles==true then
  373.     os.execute("cls") clearlog()
  374.     print("Would you like to clear the calculator's memory file? \n(yes/no)")
  375.     if string.lower(io.read())~="yes" then goto reclc end
  376.     os.execute("cls") clearlog()
  377.     print("Are you absolutely sure that you want to clear the calculator's memory file? \n(yes/no)")
  378.     if string.lower(io.read())~="yes" then goto reclc end
  379.     os.execute("cls") clearlog()
  380.     print("Last chance to stop. Are you sure that you would like to clear the calculator's memory file? \n(yes/no)")
  381.     if string.lower(io.read())~="yes" then goto reclc end
  382.     os.execute("cls") clearlog()
  383.     print("Alright. Clearing calculator's memory file...") print("- - -") sleep(cutsceneinterval) os.execute("cls") clearlog()
  384.     print("Alright. Clearing calculator's memory file...") print("| - -") sleep(cutsceneinterval) os.execute("cls") clearlog()
  385.     print("Alright. Clearing calculator's memory file...") print("| | -") sleep(cutsceneinterval) os.execute("cls") clearlog()
  386.     print("Alright. Clearing calculator's memory file...") print("| | |") sleep(cutsceneinterval) os.execute("cls") clearlog()
  387.     file=io.open("calculator memory.txt","w")
  388.     file:write("-----------------\nCalculator Recall\n-----------------\n")
  389.     file:close()
  390.     print([=[Calculator's memory file "calculator memory.txt" has been cleared.]=])
  391.    print("Press any button to continue.")
  392.    io.read()
  393.    goto cls
  394. elseif calcin=="" or calcin==" " then x=x+1 if x==20 and autoclear then os.execute("cls") clearlog()  goto recalc else end  goto recalc
  395. elseif string.match(calcin,",") then
  396.    calcin=string.gsub(calcin,",","")
  397. elseif string.match(calcin,"=") then
  398.    calcin=string.gsub(calcin,"=","")
  399. elseif calcin=="time" then
  400.    os.execute("cls")
  401.    local file=io.open("calculator logs.txt","r")
  402.    log=file:read("*a")
  403.    file:close()
  404.    io.write("Enter an equation. * is multiply, / is divide, ^ followed by a number is an exponent. Type help to get advanced functions.")
  405.    local log=string.gsub(log,"\ntime","")
  406.    print(log)
  407.    time=os.date("%I:%M:%S %p on %A, %B %d, %Y")
  408.    print(time)
  409.    goto recalc
  410. elseif calcin=="help" then print("-------------")print([=[time = get the date and time
  411. sqrt = type this, followed by a number, to get that
  412.       number's square root (i.e. sqrt10)
  413. factors = type this, followed by a number, to get that
  414.           number's factors (i.e. factors10)
  415. simplify = type this, followed by a fraction, to get the
  416.           simplified version of that fraction (i.e.  
  417.           simplify2/4)
  418. factorial = type this, followed by a number, to get the
  419.            result of multiplying a series of descending
  420.            numbers, starting with the given number (i.e.
  421.            factorial5)
  422. cmtoin = type this, followed by a number in centimeters,
  423.         to convert that number to inches (i.e. cmtoin42)
  424. intocm = type this, followed by a number in inches, to
  425.         convert that number to centimeters (i.e. intocm8)
  426. mtoft = type this, followed by a number in meters, to
  427.        convert that number to feet (i.e. mtoft5)
  428. fttom = type this, followed by a number in feet, to
  429.        convert that number to meters (i.e. fttom16)
  430. # = substitute for the previous result
  431. slowprint = type this, followed by a space and some
  432.            text, to print out that text after 5 seconds
  433.            (i.e. slowprint hello)
  434. % = type a number, followed by %, followed by another
  435.    number, to get the number that is the first number's
  436.     percentage of the second number (i.e. 10%20)
  437. pi = substitute for the first 14 digits of pi (i.e. pi*pi)
  438. ee = substitute for [first number]*10^[second number]
  439.      (i.e. 2ee4)
  440. sq = substitute for ^2 (i.e. 2sq)
  441. cu = substitute for ^3 (i.e. 3cu)
  442. clear = type this to clear the screen
  443. cls = alias for clear
  444. primefacs = type this, followed by a number, to get the
  445.             prime factors of that number (i.e. primefacs10)
  446. clearmem = clear the "calculator memory.txt" file]=])
  447. end
  448. if not string.match(calcin,match) or string.match(calcin,"=") then goto recalc
  449. elseif string.match(calcin,match) then
  450.     if not string.match(calcin,"sqrt") then
  451.         calcin=string.gsub(calcin,"sq","^2")
  452.     end
  453.     calcin=string.gsub(calcin,"pi",math.pi)
  454.     if prev then
  455.         calcin = string.gsub(calcin,"#",prev)
  456.     end
  457.     --start
  458.     if string.match(calcin,"sqrt") and string.match(calcin,"[0123456789]") and not string.match(calcin," ") then
  459.         calcin=string.lower(calcin)
  460.         input=calcin
  461.         calcin = string.gsub(calcin,"sqrt","")
  462.         if string.match(calcin,notmatch) or string.match(calcin,"[/-*^+()#]") then goto recalc end
  463.         pc,calcin=pcall(math.sqrt,calcin)
  464.         if not pc then goto recalc end
  465.         print("="..calcin)
  466.         glrb=calcin
  467.         calcin=input
  468.         goto skipcalcu
  469.     elseif string.match(calcin,"factors") and string.match(calcin,"[0123456789]") and not string.match(calcin," ") then
  470.         calcin=string.lower(calcin)
  471.         glrb=calcin
  472.         calcin = string.gsub(calcin,"factors","")
  473.         if string.match(calcin,notmatch) or string.match(calcin,"[/-*^+()#]") then goto recalc end
  474.         pc,calcin=pcall(Factors,calcin)
  475.         if not pc then goto recalc end
  476.         print_r(calcin)
  477.         goto noprev
  478.     elseif string.match(calcin,"primefacs") and string.match(calcin,"[0123456789]") and not string.match(calcin," ") then
  479.         calcin=string.lower(calcin)
  480.         glrb=calcin
  481.         calcin = string.gsub(calcin,"primefacs","")
  482.         if string.match(calcin,notmatch) or string.match(calcin,"[/-*^+()#]") then goto recalc end
  483.         calcin=tonumber(calcin)
  484.         pc,calcin=pcall(PrimeDecomp,calcin)
  485.         if not pc then goto recalc
  486.             print_r(calcin)
  487.             goto noprev
  488.         elseif string.match(calcin,"%%") and string.match(calcin,match) and not string.match(calcin," ") then
  489.             input=calcin
  490.             tab=split(calcin)
  491.             if string.match(tab[1],notmatch) or string.match(tab[1],"[/-*^+()#]") then goto recalc end
  492.             if string.match(tab[2],notmatch) or string.match(tab[2],"[/-*^+()#]") then goto recalc end
  493.             perc=tab[1]
  494.             tot=tab[2]
  495.             pc,glrb=pcall(percent,perc,tot)
  496.             if not pc then goto recalc end
  497.             print("="..glrb)
  498.             calcin=input
  499.             goto skipcalcu
  500.         elseif string.match(calcin,"ee") and string.match(calcin,match) and not string.match(calcin," ") then
  501.             input=calcin
  502.             tab=split(calcin,"ee")
  503.             if string.match(tab[1],notmatch) or string.match(tab[1],"[/-*^+()#]") then goto recalc end
  504.             if string.match(tab[2],notmatch) or string.match(tab[2],"[/-*^+()#]") then goto recalc end
  505.             zero=tab[1]
  506.             to=tab[2]
  507.             pc,glrb=pcall(ee,zero,to)
  508.             if not pc then goto recalc end
  509.             print("="..glrb)
  510.             calcin=input
  511.             goto skipcalcu
  512.         elseif string.match(calcin,"simplify") and string.match(calcin,match) and string.match(calcin,"/") and not string.match(calcin," ") then
  513.             input=calcin
  514.             calcin=string.gsub(calcin,"simplify","")
  515.             if string.match(calcin,notmatch) or string.match(calcin,"[-*^+()#]") then goto recalc end
  516.             pc,glrb=pcall(simplify,calcin)
  517.             if not pc then goto recalc end
  518.             print("="..glrb)
  519.             calcin=input
  520.             goto skipcalcu
  521.         elseif string.match(calcin,"factorial") and string.match(calcin,match) and not string.match(calcin," ") then
  522.             input=calcin
  523.             calcin=string.gsub(calcin,"factorial","")
  524.             calcin=string.lower(calcin)
  525.             if string.match(calcin,notmatch) or string.match(calcin,"[-*^+()#]") then goto recalc end
  526.             pc,glrb=pcall(factorial,calcin)
  527.             if not pc then goto recalc end
  528.             print("="..glrb)
  529.             calcin=input
  530.             goto skipcalcu
  531.         elseif string.match(calcin,"intocm") and string.match(calcin,match) and not string.match(calcin," ") then
  532.             input=calcin
  533.             calcin=string.gsub(calcin,"intocm","")
  534.             if string.match(calcin,notmatch) or string.match(calcin,"[-*^+()#]") then goto recalc end
  535.             glrb=calcin*2.54
  536.             print("="..glrb)
  537.             calcin=input
  538.             goto skipcalcu
  539.         elseif string.match(calcin,"cm>in") and string.match(calcin,match) and not string.match(calcin," ") then
  540.             input=calcin
  541.             calcin=string.gsub(calcin,"cm>in","")
  542.             if string.match(calcin,notmatch) or string.match(calcin,"[-*^+()#]") then goto recalc end
  543.             glrb=calcin/2.54
  544.             print("="..glrb)
  545.             calcin=input
  546.             goto skipcalcu
  547.         elseif string.match(calcin,"ft>m") and string.match(calcin,match) and not string.match(calcin," ") then
  548.             input=calcin
  549.             calcin=string.gsub(calcin,"ft>m","")
  550.             if string.match(calcin,notmatch) or string.match(calcin,"[-*^+()#]") then goto recalc end
  551.             glrb=calcin*3.28
  552.             print("="..glrb)
  553.             calcin=input
  554.             goto skipcalcu
  555.             --end
  556.         elseif string.match(calcin,"sq") and string.match(calcin,match) then calcin=string.gsub(calcin,"sq","^2")
  557.         elseif string.match(calcin,"cu") and string.match(calcin,match) then calcin=string.gsub(calcin,"cu","^3")
  558.         elseif string.match(calcin,"pi") and string.match(calcin,match) then calcin=string.gsub(calcin,"pi",math.pi)
  559.         elseif string.match(calcin,"/0") then goto recalc
  560.         elseif string.match(calcin,"#") and string.match(calcin,match) and prev~=nil then
  561.             calcin = string.gsub(calcin,"#",prev)
  562.         end
  563.     end
  564. end
  565. if string.match(calcin,notmatch) or string.match(calcin,"]") then goto recalc end
  566. if unexpected_condition then goto recalc end
  567. pc,func = pcall(assert,load("return " .. calcin))
  568. if not pc then goto recalc end
  569. glrb = func()
  570. if tostring(glrb)==tostring(calcin) then goto recalc end
  571. if string.match(glrb,"-") then
  572.     print("=("..glrb..")")
  573. else do
  574.         print("="..glrb)
  575.     end
  576. end
  577. ::skipcalcu::
  578. prev=glrb
  579. calcin=tostring(calcin)
  580. date=os.date()
  581. if createfiles then
  582.     file=io.open("calculator memory.txt","a+")
  583.     if string.match(glrb,"-") then
  584.         file:write("\n"..date.."\n"..calcin.." = ("..glrb..")\n")
  585.     else do
  586.             file:write("\n"..date.."\n"..calcin.." = "..glrb.."\n")
  587.         end
  588.     end
  589.     file:close()
  590. end
  591. ::noprev::
  592. x=x+1 if x==20 and autoclear then os.execute("cls") clearlog()  goto recalc else end
  593. goto recalc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement