Verb && script-call && "Print a message" type of verb (SOLVED)

I had a verb(spy) on an object(MissBleye).
At first the verb was not a script but rather a print a message "Spy is called"

I tested directly by the command bar. All seemed fine.

I tested by code

do(MissBleye,"spy")

And I had an object reference not set error

When by pure hazard I changed the verb spy by a script, all was good, and my script was successfully called

Is it a known error ?


do(MissBleye,"spy")

calls the script from attribute 'MissBleye'
and...

msg ("MissBleye.spy ")

calls the string from attribute 'spy' from the object 'MissBleye'

So 'do' calls script and 'msg' calls strings
If you try to call a string with 'do', you get the error(I think)

That's the best answer I can give.


The do() script executes a script attribute.

If you give it an attribute that isn't a script, it can't run it. So it gives an error message.

If you wanted to run the verb if it's a script, and display it if it's a string, you could use:

switch (TypeOf(MissBleye, "spy")) {
  case ("script") {
    do (MissBleye, "spy")
  }
  case ("string") {
    msg (GetString (MissBleye, "spy"))
  }
}

Or you could use the pages of code in defaultverb, like this:

do (PickOneObject (FilterByAttribute (AllCommands(), "property", "spy")), "script", QuickParams ("object", MissBleye))

(which will go as far as displaying the right default message if she doesn't have that verb at all)


Thank you @Forgewright and @mrangel for your explanation. I thought the "do" were for all verbs and "object.attribute" was only for attributes. I didn't realise that verbs were just special attributes that often will have script.


'Verbs' are actually just 'Script Attributes' (and extra coding to give them their Verb functionality: hyperlink buttons and etc)


This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums