pineCalc- Calculator for Pine
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Toshi-Toshi-Shiba
//@version=5
indicator("pineCalc- Calculator for Pine",overlay=true)

mathType= input.string("Add",options=["Add","Subtract","Divide","Multiply","Modulo"])
float numberToAdd1= input.float(0.0)
float numberToAdd2= input.float(0.0)



calculator(num1,num2) =>
    switch mathType
        "Add" => calculation= math.round(num1 + num2,4)
        "Subtract" => calculation= math.round(num1 - num2,4)
        "Divide" => calculation= math.round(num1 / num2,4)
        "Multiply" => calculation= math.round(num1 * num2,4)
        "Modulo" =>  calculation=  math.round(num1 % num2,4)

addedValue= calculator(num1=numberToAdd1,num2=numberToAdd2)
number1String= str.tostring(numberToAdd1)
number2String= str.tostring(numberToAdd2)
calculatorValueString= str.tostring(addedValue)


//PLOT GRAPHICAL USER INTERFACE AS TABLE
calculatorGui= table.new(position=position.top_right,columns=2,rows=5,bgcolor=#000000,frame_color=color.gray,border_color=color.gray,border_width=3,frame_width=3)
table.cell(calculatorGui,column=0,row=0,text="pineCalc",text_color=color.yellow,text_size=size.normal)
table.cell(calculatorGui,column=0,row=1,text="Math Type: ",text_color=color.white)
table.cell(calculatorGui,column=0,row=2,text="Number to " + mathType + " 1 ",text_color=color.white)
table.cell(calculatorGui,column=0,row=3,text="Number to " + mathType + " 2 ",text_color=color.white)
table.cell(calculatorGui,column=0,row=4,text="Math Result: ",text_color=color.green)
table.cell(calculatorGui,column=1,row=0,text=" v1.0 ",text_color=color.yellow,text_size=size.normal)
table.cell(calculatorGui,column=1,row=1,text=mathType,text_color=color.white)
table.cell(calculatorGui,column=1,row=2,text=number1String,text_color=color.white)
table.cell(calculatorGui,column=1,row=3,text=number2String,text_color=color.white)
table.cell(calculatorGui,column=1,row=4,text=calculatorValueString,text_color=color.green)




//      PYTHON CODE
//
//
// def calculatorAdding(num1,num2) :
//      if mathType == "Add" :
//        calculation= num1 + num2
//      elif mathType == "Subtract"
//        calculation= num1 - num2
//      
//  return calculation
//
// print(calculatorAdding(numberToAdd1,numberToAdd2)
//

