FANDOM


Calculators are basically programs which help the user to calculate and process numbers using the plus, minus, multiply and divide functions.


An example of the calculator program can be found here:


print ("Microcrap Calc\n")
local tEnv 
= {
        ["exit"] 
= function()
                bRunning 
= false
        end,
}
setmetatable( tEnv, { __index 
= getfenv() } )
local s 
= io.read()
        local nForcePrint 
= 0
        local func, e 
= loadstring( s )

        local func2, e2 
= loadstring( "return "..s )
                if not func then
                if func2 then
                        func 
= func2
                        e 
= nil
                        nForcePrint 
= 1
                end
        else
                if func2 then
                        func 
= func2
                end
        end
        if func then
            setfenv( func, tEnv )
        local tResults 
= { pcall( func ) }
        if tResults[1] then
                local n 
= 1
                while (tResults[n + 1] ~= nil) or (n <= nForcePrint) do
                        print( tostring( tResults[n + 1] ) )
                        n 
= n + 1
                end
        else
                print( tResults[2] )
        end
    else
        print( e )
    end

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.