Frank, et al:

As for an object-oriented programming language, no Rev is *not* an object-oriented programming language, at least not in the traditional sense.


For example, in Rev, let's say we want to change the label of the button; we do this with a command like:


set the label of button "My Button" to "Hello"


In other words, we are giving an instruction to Rev, such that our script code changes the button's label. In more traditional OOP, we instead send a message to the button, asking it to change its own label; something more like (pseudo-code, not necessarily in any "real" programming language):


tell button "My Button" to set its label to "Hello"


At first the distinction may seem quite subtle, and you may not recognize the benefits to this, but consider that I want to create a new type of button with certain characteristics, one of which is that the label of the button always begin with a digit. I can enforce this by having the button reject an attempt to set its label to anything other than a string starting with a digit (again with the pseudo-code):


when asked to set my label to x
  if char 1 of x is a number then
    set the label of me to x
  else
    throw "Invalid Label"
  end if
end when asked to set my label


Note that the prior code would still work the same way, and would not need to know what kind of button it was dealing with (of course, it would have an exception raised with this kind of button, since "Hello" does not start with a digit...)


We can't currently do this with Rev.

In button script:

on setMyLabel labelName
  if char 1 of labelName is a number then
      set the label of me to labelName
      return empty
  end if
  return "Invalid label name:"&&labelName
end setMyLabel

elsewhere:

send "setMyLabel Hello" to button id targetButtonId

??

Rob Cozens CCW
Serendipity Software Company

"And I, which was two fooles, do so grow three;
 Who are a little wise, the best fooles bee."

from "The Triple Foole" by John Donne (1572-1631)

_______________________________________________
use-revolution mailing list
use-revolution@lists.runrev.com
http://lists.runrev.com/mailman/listinfo/use-revolution

Reply via email to