Thomas McGrath III wrote:

While trying to understand the best use for me for setProp/getProp I came across an idea or concept that I thought would be great.
I wanted to have a custom prop for each line in a field as in:
set the isAFolder of line 1 of me to "true"
Of course it did not work but I thought 'Wow' that would be useful.
I guess that some creative scripting would get similar results. (I do that now) but in the scope of this great discussion I thought a custom prop for each line and or word and or char would be really great for working with fields and providing that elusive 'word processor' attributes that keep coming up on the list.

How hard would this be? Or is it a completely 'wrong' use of custom props?

Rev's prety flexible so it's hard to have a "wrong" use of custom props.

But for things like characters in a field, if they're being updated in response to user typing then performance will be critical, and the native message path edges out even setProp for efficiency:

Native: 0.006ms
Send:   0.010ms
Do:     0.010ms
Prop:   0.009ms

(Times shown are per call, with modest overhead within the handler being called. Benchmark code is below; it was written hastily, so may be improved for greater accuracy.)

As useful as custom props are, they have limitations. For example, it may not be possible to use them for some of the word processing features people have requested, things like paragraph-level formatting and such.

The main benefits of custom props are as triggers for code that relates to a given object, and for neatly storing a variety of data elements.

When they make code simpler or easier to maintain, they're worth pursuing. But sometimes it's easier to just call a handler in a library.

---------------------------------------------------

Benchmark Code

Script of button in a stack:

on mouseUp
  put 100000 into n
  --
  put the millisecs into t
  repeat n
    doMe
  end repeat
  put (the millisecs - t)/n into t1
  --
  put the millisecs into t
  repeat n
    send "doMe" to this cd
  end repeat
  put (the millisecs - t )/n into t2
  --
  put the millisecs into t
  repeat n
    do "doMe"
  end repeat
  put (the millisecs - t)/n into t3
  --
  put the millisecs into t
  repeat n
    get the uWhat of this cd
  end repeat
  put (the millisecs - t)/n into t4
  --
  set the numberformat to "0.000"
  put "Native: "& t1 &"ms" &cr\
      &"Send:   "&t2 &"ms" &cr\
      &"Do:      "&t3 &"ms" &cr\
      &"Prop:    "&t4 &"ms"
end mouseUp


Script in card of that stack:

on doMe
  get "nothing"
  put "nothing" into it
end doMe

getProp uWhat
  get "nothing"
  put "nothing" into it
end uWhat



--
 Richard Gaskin
 Managing Editor, revJournal
 _______________________________________________________
 Rev tips, tutorials and more: http://www.revJournal.com
_______________________________________________
use-revolution mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution

Reply via email to