How make repeated commands compact?

Posted by Orogan on Wed 05 Nov 2008 12:42 PM — 3 posts, 14,579 views.

#0
Lets say I need to do:

a = "n1"
b = "n2"
Note ("sum = " ..(a + b))

And this a couple of times in a script with different n1 and n2.
Lazy as I am, I want put something in my script that lets
me type 'dosum (n1,n2)' and it would do the same as above.

How would i go about this?
The example above is just to explain what I want to do,
I'll try and work my way from there to what I need.
Australia Forum Administrator #1
You need to make your own function for this, eg.


function dosum (n1, n2)

local total  -- local variable to hold results

  total = n1 + n2

  return total

end -- function


Or, more compactly in this case:


function dosum (n1, n2)
  return n1 + n2
end -- function


#2
Did tought it was that simple :)
The scripts I took a look at made it seem more difficult to pas the values.


Thanks for the help.