from Custom import CustomBase import API import decimal class int (CustomBase): stack = None def __init__(self, stack): self.stack = stack # __init__ def help(self): msg = "int\n" msg += "---\n\n" msg += "Takes r0 from the stack\n\n" msg += "Removes the decimal part of r0\n\n" msg += "Pushes the result to r0" API.showPopup('Custom function', msg, font=('Courier',API.helpFontSize)) # If you want to implement translated texts, you can use the API.t(textKey) function: # API.showPopup('Custom function', API.t(API.programName+'.CustomFunctions.square.btnHLP'), font=('Courier',API.helpFontSize)) # help def calculate(self): if self.stack.inputMode != 'DEC': API.toast('This operation is only supported in DEC mode') # If you want to implement translated texts, you can use the API.t(textKey) function: # API.toast(API.t(API.programName+'.CustomFunctions.square.onlySupportedinDEC')) return if self.stack.finishEntry() == -1: return # abort here because data in input line is invalid if self.stack.size() < 1: API.toast('This operation needs 1 argument') return x = self.stack.getRegister(0) x = x.to_integral_value(decimal.ROUND_DOWN) self.stack.pop(1) self.stack.push(x) # calculate # int