Line 202: |
Line 202: |
| ! Colors | | ! Colors |
| |- bgcolor="#E8F0E8" | | |- bgcolor="#E8F0E8" |
− | | Active | + | | |
| === Sergio's photographic equipment email === | | === Sergio's photographic equipment email === |
| I have a LOT of camera equipment (Camera, Lens, Filters, tripods, bags, etc.). I want to be able to create records of all of this equipment for personal inventory as well as insurance purposes. | | I have a LOT of camera equipment (Camera, Lens, Filters, tripods, bags, etc.). I want to be able to create records of all of this equipment for personal inventory as well as insurance purposes. |
Line 246: |
Line 246: |
| <hr><hr> | | <hr><hr> |
| | | |
| + | === Example: Making a Shared library function available & call-in it from a trigger or action === |
| {| class="wikitable" | | {| class="wikitable" |
| ! From forum email | | ! From forum email |
| |+ Considering scripting Memento | | |+ Considering scripting Memento |
| |- bgcolor="#E8F0E8" | | |- bgcolor="#E8F0E8" |
− | | | + | | stary-@live.com, Aug 10 2021 |
| If you want to extend Memento with JavaScript, I suggest you read the wiki, so you can learn how to do it. If you want to use the simplest scripts, you could try using a JavaScript field, but it doesn't have fancy global functions like set() or link() or libByName(), but it does have simple global functions like field(); | | If you want to extend Memento with JavaScript, I suggest you read the wiki, so you can learn how to do it. If you want to use the simplest scripts, you could try using a JavaScript field, but it doesn't have fancy global functions like set() or link() or libByName(), but it does have simple global functions like field(); |
| | | |
Line 276: |
Line 277: |
| https://wiki.mementodatabase.com/index.php/How:Write_scripts_in_JavaScript_for_Memento, or... | | https://wiki.mementodatabase.com/index.php/How:Write_scripts_in_JavaScript_for_Memento, or... |
| https://wiki.mementodatabase.com/index.php/Tips:Using_JavaScript_in_Memento | | https://wiki.mementodatabase.com/index.php/Tips:Using_JavaScript_in_Memento |
| + | |- bgcolor="#E8F0E8 |
| + | | |
| + | For a shared function definition, it should be... |
| + | <pre> |
| + | function sub(fieldname, fieldvalue) { |
| + | entry().set(fieldName, fieldValue); |
| + | } |
| + | </pre> |
| + | Then call that in a trigger, action, or whatever with this... |
| + | <pre> |
| + | sub("name", "bullet"); |
| + | </pre> |
| + | On Tue, Aug 10, 2021, 16:34 Bill Crews <bill.crews@gmail.com> wrote: |
| + | Hide quoted text |
| + | We know only what we can glean ... That there is a field named "name" and a value "bullet" that you want to go into that field. If it's a shared script, why does it call a global function field()? There is no such global function. There must be a "current entry" for that, and shared scripts (like most other things) don't work for JavaScript fields. |
| + | |
| + | If you tell us more, we can be of more help, but all I can do is guess that the following is what you want... |
| + | |
| + | It must be a trigger script or an action script located in an entry. This enables the entry() global function to work, so there is a "current" entry. |
| + | |
| + | So, <code> entry().set("name", "bullet"); </code> is all the script you need, if your objective is to set that field's value to "button". If you're wanting to do something else, you might consider telling what that is. |
| |} | | |} |
| | | |