8,452
edits
Paradox-01 (talk | contribs) m (scripting: turning a function with arguments into a command) |
Paradox-01 (talk | contribs) mNo edit summary |
||
Line 72: | Line 72: | ||
' this function can only be used inside the script where it was defined | ' this function can only be used inside the script where it was defined | ||
function simple_math (a, b, | function simple_math (a, b, operator) | ||
if | if operator = "+" then | ||
simple_math = a + b | simple_math = a + b | ||
elseif | elseif operator = "-" then | ||
simple_math = a - b | simple_math = a - b | ||
elseif | elseif operator = "/" then | ||
simple_math = a / b | simple_math = a / b | ||
elseif | elseif operator = "x" then | ||
simple_math = a * b | simple_math = a * b | ||
else | else | ||
logmessage " | logmessage "The used operator is not allowed. Choose one of the following:" & vbCrlf & "+ - / x" | ||
end if | end if | ||
end function | end function | ||
Line 125: | Line 125: | ||
oArgs.Add "a",siArgumentInput,"0" | oArgs.Add "a",siArgumentInput,"0" | ||
oArgs.Add "b",siArgumentInput,"0" | oArgs.Add "b",siArgumentInput,"0" | ||
oArgs.Add " | oArgs.Add "operator",siArgumentInput,"0" | ||
simple_math_Init = true | simple_math_Init = true | ||
end function | end function | ||
function simple_math_Execute( a, b, | function simple_math_Execute( a, b, operator ) | ||
' convert to double | ' convert to double | ||
a = cdbl(a) | a = cdbl(a) | ||
b = cdbl(b) | b = cdbl(b) | ||
if | if operator = "+" then | ||
simple_math_Execute = a + b | simple_math_Execute = a + b | ||
elseif | elseif operator = "-" then | ||
simple_math_Execute = a - b | simple_math_Execute = a - b | ||
elseif | elseif operator = "/" then | ||
simple_math_Execute = a / b | simple_math_Execute = a / b | ||
elseif | elseif operator = "x" then | ||
simple_math_Execute = a * b | simple_math_Execute = a * b | ||
else | else | ||
logmessage " | logmessage "The used operator is not allowed. Choose one of the following:" & vbCrlf & "+ - / x" | ||
end if | end if | ||
end function | end function |
edits